:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #07101d;
    --panel: #101b2b;
    --panel-soft: #142238;
    --line: #21334c;
    --text: #f4f7fb;
    --muted: #8fa2bb;
    --accent: #49c7f5;
    --accent-strong: #3478f6;
    --danger: #fca5a5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); }
body.auth-pending #login-view, body.auth-pending #app-view { display: none !important; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.brand, .sidebar-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: white; background: linear-gradient(135deg, #38bdf8, #4f46e5); box-shadow: 0 8px 28px #2563eb55; }
.brand-mark-image { padding: 2px; object-fit: contain; background: #ffffff; }

.auth-loading { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #172b4a, var(--bg) 55%); }
.auth-loading-content { display: grid; justify-items: center; gap: 18px; color: var(--muted); font-size: 13px; }
.auth-loading-content p { margin: 0; }
.loading-spinner { width: 28px; height: 28px; border: 3px solid #28415f; border-top-color: var(--accent); border-radius: 50%; animation: auth-spin .75s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #2563eb44, transparent 32%), radial-gradient(circle at 90% 90%, #7c3aed33, transparent 35%); }
.login-card { width: min(100%, 430px); padding: 42px; border: 1px solid #ffffff18; border-radius: 24px; background: #0e1929e8; box-shadow: 0 28px 90px #0009; }
.login-card .brand { margin-bottom: 34px; }
.login-card h1 { margin: 0 0 8px; font-size: clamp(28px, 6vw, 38px); }
label { display: block; margin: 18px 0 8px; color: #c9d5e4; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #0a1422; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #38bdf822; }
textarea { resize: vertical; }
.security-note { margin: 22px 0 0; color: #6f829b; font-size: 12px; text-align: center; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 10px 15px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: var(--panel-soft); }
.button:hover { border-color: #426084; }
.button.primary { width: 100%; margin-top: 24px; border: 0; font-weight: 800; background: linear-gradient(135deg, var(--accent-strong), #5147de); }
.button.primary.compact { width: auto; margin-top: 0; }
.button:disabled { cursor: wait; opacity: .6; }
.button.small { padding: 8px 11px; font-size: 12px; }
.alert { margin: 18px 0; padding: 11px 13px; border: 1px solid #7f1d1d; border-radius: 9px; color: var(--danger); background: #7f1d1d40; font-size: 13px; }
.alert.success { border-color: #047857; color: #a7f3d0; background: #065f4640; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 16px; border-right: 1px solid var(--line); background: #0b1523; overflow-y: auto; }
.sidebar-brand { padding: 0 10px 28px; }
.nav-group-title { margin: 24px 11px 8px; color: #60748f; font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; margin: 2px 0; padding: 10px 11px; border: 0; border-radius: 9px; color: #9fb0c5; text-align: left; text-decoration: none; cursor: pointer; background: transparent; }
.nav-item:hover, .nav-item.active { color: white; background: #192a42; }
.nav-item span { width: 18px; color: var(--accent); text-align: center; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 16px 8px 4px; border-top: 1px solid var(--line); }
.avatar { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-weight: 900; background: #1e3a5f; }
.user-summary { min-width: 0; display: flex; flex: 1; flex-direction: column; font-size: 12px; }
.user-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-summary span { color: var(--muted); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: transparent; }

.workspace { min-width: 0; }
.topbar { min-height: 86px; display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 18px 32px; border-bottom: 1px solid var(--line); background: #091321cc; backdrop-filter: blur(14px); }
.topbar h2 { margin: 0; font-size: 23px; }
.session-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 12px #34d399; }
.content { padding: 28px 32px 42px; }
.welcome-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px; border: 1px solid #244367; border-radius: 18px; background: linear-gradient(120deg, #122743, #111c30); }
.welcome-panel h3 { margin: 0 0 7px; font-size: 26px; }
.welcome-panel p:last-child { margin: 0; }
.plan-badge { padding: 9px 14px; border: 1px solid #38bdf866; border-radius: 999px; color: #bae6fd; background: #0369a133; font-size: 12px; font-weight: 800; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.summary-card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.summary-card span { color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; margin-top: 10px; font-size: 25px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.panel.wide { grid-column: 1 / -1; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 9px; min-height: 95px; padding: 20px; }
.chip { align-self: flex-start; padding: 7px 10px; border: 1px solid #2b476a; border-radius: 999px; color: #bdd2eb; background: #10243c; font-size: 12px; }
.menu-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 20px; }
.menu-card { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #0c1726; }
.menu-card strong, .menu-card span { display: block; }
.menu-card span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.company-summary-panel { margin-bottom: 16px; }
.company-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; padding: 20px; }
.company-card { padding: 16px; border: 1px solid #294363; border-radius: 12px; background: #0c1929; }
.company-card h4 { margin: 0 0 5px; font-size: 15px; }
.company-card p { margin: 3px 0; color: var(--muted); font-size: 11px; }
.company-card strong { color: var(--text); }
.branch-list { display: grid; gap: 6px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.branch-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #bdd2eb; font-size: 12px; }
.branch-item small { color: var(--muted); }

.table-panel { min-height: calc(100vh - 145px); }
.table-tools { flex-wrap: wrap; }
.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; width: min(100%, 560px); }
.search-form { display: flex; gap: 8px; width: min(100%, 380px); }
.search-form input { min-width: 0; }
.table-scroll { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { max-width: 360px; padding: 12px 15px; border-bottom: 1px solid #1d2e44; text-align: left; vertical-align: top; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th { position: sticky; top: 0; color: #8fa6c1; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; background: #0d1929; }
tbody tr:hover { background: #14243a; }
.actions-column { min-width: 220px; }
.row-actions { display: flex; gap: 6px; max-width: none; overflow: visible; }
.row-action { white-space: nowrap; }
.tone-danger { border-color: #7f1d1d; color: #fecaca; background: #7f1d1d33; }
.tone-warning { border-color: #92400e; color: #fde68a; background: #78350f33; }
.tone-success { border-color: #047857; color: #a7f3d0; background: #065f4633; }
.empty-row { padding: 38px; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; color: var(--muted); font-size: 12px; }
.pagination div { display: flex; gap: 8px; }
.mobile-only { display: none; }

.freefire-card { max-width: 900px; margin: 0 auto; overflow: hidden; border: 1px solid #294a70; border-radius: 22px; background: linear-gradient(145deg, #12253d, #0d1727 62%); box-shadow: 0 24px 70px #0005; }
.freefire-header { display: flex; align-items: center; gap: 18px; padding: 30px 32px; border-bottom: 1px solid #28425f; background: radial-gradient(circle at 0 0, #2563eb44, transparent 42%); }
.freefire-icon { display: grid; flex: 0 0 auto; place-items: center; width: 62px; height: 62px; border: 1px solid #60a5fa66; border-radius: 18px; color: white; font-size: 18px; font-weight: 900; background: linear-gradient(135deg, #2563eb, #7c3aed); box-shadow: 0 12px 30px #2563eb55; }
.freefire-header h3 { margin: 0 0 7px; font-size: clamp(22px, 4vw, 30px); }
.freefire-header p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.freefire-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; padding: 28px 32px; }
.freefire-field label { margin: 0 0 8px; }
.freefire-field small { display: block; margin-top: 7px; color: #7189a5; font-size: 11px; }
.freefire-submit { min-height: 46px; white-space: nowrap; }
.freefire-submit span { font-size: 20px; line-height: 0; }
.freefire-card > .alert { margin: 0 32px 24px; }
.freefire-result-wrap { margin: 0 32px 32px; border: 1px solid #245b50; border-radius: 14px; background: #071d20aa; }
.freefire-result-title { display: flex; align-items: center; gap: 9px; padding: 13px 16px; border-bottom: 1px solid #245b50; color: #a7f3d0; font-size: 12px; font-weight: 800; }
.freefire-result-title .status-dot { width: 7px; height: 7px; }
.freefire-result { display: grid; gap: 1px; max-height: 520px; padding: 14px; overflow: auto; }
.freefire-data-row { display: grid; grid-template-columns: minmax(150px, .35fr) minmax(0, 1fr); gap: 18px; padding: 12px 10px; border-bottom: 1px solid #173c3b; }
.freefire-data-row:last-child { border-bottom: 0; }
.freefire-label { color: #83b9ad; font-size: 11px; font-weight: 800; text-transform: capitalize; }
.freefire-content { min-width: 0; color: #d7fff0; font-size: 13px; overflow-wrap: anywhere; }
.freefire-value { font-weight: 700; }
.freefire-nested { display: grid; gap: 1px; }
.freefire-player-card { display: flex; align-items: center; gap: 16px; padding: 22px; border: 1px solid #397b68; border-radius: 16px; background: linear-gradient(120deg, #123c3a, #10272d); box-shadow: inset 0 1px #ffffff12; }
.freefire-player-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 64px; height: 64px; border: 1px solid #fbbf2466; border-radius: 18px; font-size: 31px; background: linear-gradient(145deg, #f97316, #dc2626); box-shadow: 0 10px 25px #dc262655; }
.freefire-player-avatar img { width: 48px; height: 48px; object-fit: contain; }
.freefire-player-details { display: grid; min-width: 0; gap: 5px; }
.freefire-player-details caption, .freefire-player-details > span:first-child { color: #83b9ad; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.freefire-player-details strong { overflow: hidden; color: #f0fff9; font-size: 21px; text-overflow: ellipsis; white-space: nowrap; }
.freefire-player-id { color: #c5e7dc; font-size: 13px; }
.freefire-player-check { display: grid; place-items: center; width: 28px; height: 28px; margin-left: auto; border-radius: 50%; color: #06251d; font-weight: 900; background: #6ee7b7; }
.freefire-news-heading { display: none; align-items: end; justify-content: space-between; gap: 16px; margin: 8px 32px 18px; padding-top: 28px; border-top: 1px solid #28425f; }
.freefire-news-heading.freefire-visible { display: flex; }
.freefire-news-heading h3 { margin: 0; font-size: 22px; }
.freefire-news-heading a, .freefire-news-loading a { color: #7dd3fc; font-size: 12px; font-weight: 800; text-decoration: none; }
.freefire-news { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 32px 32px; }
.freefire-news.freefire-visible { display: grid; }
.freefire-news-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 15px; border: 1px solid #223b57; border-radius: 13px; color: var(--text); text-decoration: none; background: #0d1d30; transition: border-color .2s, transform .2s, background .2s; }
.freefire-news-card:hover { border-color: #3b82f6; transform: translateY(-2px); background: #122844; }
.freefire-news-mark { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: white; font-size: 11px; font-weight: 900; background: linear-gradient(135deg, #2563eb, #7c3aed); }
.freefire-news-copy { display: grid; min-width: 0; gap: 4px; }
.freefire-news-copy small { color: #7dd3fc; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.freefire-news-copy strong { overflow: hidden; font-size: 13px; line-height: 1.35; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.freefire-news-arrow { margin-left: auto; color: #7dd3fc; font-size: 18px; }
.freefire-news-loading { grid-column: 1 / -1; padding: 28px; color: var(--muted); text-align: center; }
@media (max-width: 720px) { .freefire-news-heading { align-items: start; flex-direction: column; margin-left: 20px; margin-right: 20px; } .freefire-news { grid-template-columns: 1fr; margin-left: 20px; margin-right: 20px; } }
@media (max-width: 560px) { .freefire-data-row { grid-template-columns: 1fr; gap: 5px; } }
@media (max-width: 720px) { .freefire-header, .freefire-form { padding: 24px 20px; } .freefire-form { grid-template-columns: 1fr; } .freefire-submit { width: 100%; } .freefire-card > .alert, .freefire-result-wrap { margin-left: 20px; margin-right: 20px; } }

.admin-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid #2b4160; border-radius: 16px; color: var(--text); background: #0e1929; box-shadow: 0 30px 100px #000c; }
.admin-dialog::backdrop { background: #020617c7; backdrop-filter: blur(3px); }
.admin-dialog form { max-height: calc(100vh - 42px); overflow-y: auto; }
.dialog-heading { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); background: #0e1929; }
.dialog-heading h3 { margin: 0; font-size: 20px; }
.admin-dialog .alert { margin: 18px 22px 0; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 22px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { margin-top: 0; }
.checkbox-field { display: flex; align-items: center; gap: 10px; min-height: 46px; margin: 20px 0 0; cursor: pointer; }
.checkbox-field input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-strong); }
.dialog-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: #0e1929; }

@media (max-width: 1000px) {
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .app-shell { grid-template-columns: 230px minmax(0, 1fr); }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; z-index: 20; left: -280px; width: 270px; transition: left .2s ease; box-shadow: 20px 0 70px #000a; }
    .sidebar.open { left: 0; }
    .mobile-only { display: grid; }
    .topbar { padding: 15px 18px; }
    .session-state { display: none; }
    .content { padding: 18px; }
    .summary-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .panel.wide { grid-column: auto; }
    .welcome-panel { align-items: flex-start; flex-direction: column; }
    .login-card { padding: 30px 24px; }
    .table-tools { align-items: stretch; flex-direction: column; }
    .table-actions { align-items: stretch; flex-direction: column; width: 100%; }
    .search-form { width: 100%; }
    .admin-form-grid { grid-template-columns: 1fr; }
    .form-field.full { grid-column: auto; }
}
