/* D2panel UI v3 — responsive light + dark themes */
:root {
  color-scheme: light;
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-3: #eef1f8;
  --text: #172033;
  --text-soft: #66728a;
  --text-faint: #8e98ab;
  --border: #e3e8f1;
  --primary: #4f68f5;
  --primary-2: #7c4dff;
  --primary-soft: #edf0ff;
  --success: #159b68;
  --success-soft: #e7f8f0;
  --danger: #dc4b5a;
  --danger-soft: #fff0f1;
  --warning: #c78a27;
  --shadow-sm: 0 3px 12px rgba(28, 43, 75, .045);
  --shadow-md: 0 12px 32px rgba(28, 43, 75, .075);
  --shadow-lg: 0 24px 70px rgba(28, 43, 75, .16);
  --sidebar-bg: #fff;
  --topbar-bg: rgba(255,255,255,.86);
  --radius: 17px;
  --radius-sm: 11px;
  --radius-xs: 8px;
}
html.dark-theme {
  color-scheme: dark;
  --bg: #090e1c;
  --surface: #111a2d;
  --surface-2: #151f35;
  --surface-3: #1b2942;
  --text: #f1f4ff;
  --text-soft: #a8b4ce;
  --text-faint: #7785a2;
  --border: rgba(151, 170, 211, .15);
  --primary: #5d82ff;
  --primary-2: #9258ff;
  --primary-soft: rgba(92, 118, 255, .15);
  --success: #35d18d;
  --success-soft: rgba(53, 209, 141, .12);
  --danger: #ff6679;
  --danger-soft: rgba(255, 102, 121, .13);
  --warning: #f0bb62;
  --shadow-sm: 0 4px 18px rgba(0,0,0,.12);
  --shadow-md: 0 14px 38px rgba(0,0,0,.22);
  --shadow-lg: 0 24px 70px rgba(0,0,0,.42);
  --sidebar-bg: #0b1120;
  --topbar-bg: rgba(9,14,28,.86);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .22s ease, color .22s ease;
}
body.app-body {
  background-image: radial-gradient(ellipse at 78% 0%, rgba(100, 116, 255, .055), transparent 34%);
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.ui-icon { display: inline-block; flex: 0 0 auto; vertical-align: middle; }
.muted { color: var(--text-soft); }
.nowrap { white-space: nowrap; }

/* App frame + sidebar */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 80;
  width: 258px; display: flex; flex-direction: column;
  padding: 24px 16px 16px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 30px rgba(20, 32, 60, .025);
}
.dark-theme .sidebar { box-shadow: 8px 0 32px rgba(0,0,0,.12); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 2px 9px 27px; color: var(--text); }
.sidebar-brand:hover { color: var(--text); text-decoration: none; }
.brand-mark {
  width: 78px; height: 78px; border-radius: 20px; display: grid; place-items: center;
  flex: 0 0 auto;
  background: url("site-logo.png?v=2") center / contain no-repeat;
  box-shadow: 0 6px 18px rgba(76, 89, 213, .18);
}
/* Keep the fallback label in markup for screen readers, but show the uploaded logo. */
.brand-mark span { opacity: 0; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 19px; letter-spacing: -.55px; font-weight: 800; }
.brand-copy small { margin-top: 4px; color: var(--text-soft); font-size: 11px; }
.sidebar-caption { padding: 0 12px 10px; color: var(--text-faint); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.sidebar-caption-spaced { margin-top: 25px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 5px; }
.side-link {
  position: relative; min-height: 45px; display: flex; align-items: center; gap: 12px;
  padding: 0 13px; border-radius: 12px; color: var(--text-soft); font-size: 13px; font-weight: 650;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}
.side-link .ui-icon { width: 19px; height: 19px; opacity: .92; }
.side-link:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; transform: translateX(2px); }
.side-link.active {
  color: #fff; background: linear-gradient(105deg, #3c75f7 0%, #5949e8 58%, #7045dc 100%);
  box-shadow: 0 8px 20px rgba(77, 91, 237, .24), inset 0 1px 0 rgba(255,255,255,.17);
}
.side-link.active .ui-icon { opacity: 1; }
.side-external { margin-left: auto; font-size: 15px; opacity: .55; }
.sidebar-bottom { margin-top: auto; }
.sidebar-security {
  display: flex; align-items: center; gap: 10px; padding: 12px 11px; margin-bottom: 13px;
  border: 1px solid var(--border); border-radius: 12px; color: var(--success); background: var(--surface-2);
}
.sidebar-security span { display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-security strong { color: var(--text); font-size: 10px; font-weight: 700; }
.sidebar-security small { color: var(--text-soft); font-size: 10px; margin-top: 3px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 9px 4px; border-top: 1px solid var(--border); }
.user-avatar {
  width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: 12px; color: #fff; font-size: 13px; font-weight: 800;
  background: linear-gradient(145deg, #526fff, #9852f5); box-shadow: 0 5px 14px rgba(89, 88, 230, .22);
}
.sidebar-user-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-user-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 12px; }
.sidebar-user-copy small { color: var(--text-soft); font-size: 10px; margin-top: 3px; }
.sidebar-logout { margin-left: auto; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--text-soft); }
.sidebar-logout:hover { color: var(--danger); background: var(--danger-soft); }
.sidebar-scrim { display: none; }

/* Top bar + content */
.app-main { min-height: 100vh; margin-left: 258px; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 50; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 13px clamp(20px, 3vw, 44px); background: var(--topbar-bg); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 15px; min-width: 0; }
.topbar-heading { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.topbar-heading strong { font-size: 15px; font-weight: 750; letter-spacing: -.15px; }
.topbar-heading small { color: var(--text-soft); font-size: 11px; margin-top: 4px; }
.topbar-kicker { color: var(--text-faint); font-size: 9px; letter-spacing: .14em; font-weight: 800; margin-bottom: 4px; }
.mobile-menu-btn { display: none; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface); color: var(--text-soft); cursor: pointer; font-size: 11px; font-weight: 700; transition: .18s ease;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.theme-icon { display: inline-flex; color: var(--primary); }
.theme-label { white-space: nowrap; }
.topbar-profile { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid var(--border); }
.user-avatar-small { width: 34px; height: 34px; border-radius: 50%; }
.topbar-profile > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-profile strong { color: var(--text); font-size: 12px; }
.topbar-profile small { color: var(--text-soft); font-size: 10px; margin-top: 3px; }
.page-content { width: 100%; max-width: 1740px; margin: 0 auto; padding: 28px clamp(20px, 3vw, 44px) 48px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 15px; flex-wrap: wrap; margin-bottom: 20px; }
.page-heading h1 { margin: 0; color: var(--text); font-size: clamp(23px, 2.1vw, 30px); line-height: 1.2; letter-spacing: -.8px; }
.page-heading p { margin: 7px 0 0; color: var(--text-soft); font-size: 13px; }
.page-heading-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* Hero banner */
.hero-banner {
  position: relative; isolation: isolate; overflow: hidden; min-height: 218px; display: flex; align-items: center;
  margin-bottom: 20px; padding: 30px clamp(22px, 3vw, 38px); border: 1px solid rgba(115, 132, 255, .22); border-radius: 21px;
  background-color: #111a35;
  background-image: linear-gradient(90deg, rgba(12,17,36,.98) 0%, rgba(13,20,47,.91) 40%, rgba(15,19,48,.35) 72%, rgba(13,18,42,.35) 100%), url("hero-banner-v4.webp");
  background-size: cover, auto 155%; background-position: center, right 43%; background-repeat: no-repeat;
  box-shadow: 0 16px 36px rgba(26, 36, 91, .13);
}
.hero-banner::before { content: ""; position: absolute; z-index: -1; inset: 0; background: radial-gradient(ellipse at 78% 50%, rgba(111, 74, 255, .19), transparent 44%); }
.hero-copy { position: relative; z-index: 1; max-width: 620px; }
.hero-kicker { display: inline-flex; align-items: center; gap: 7px; color: #9eb5ff; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero-kicker::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #62e0ad; box-shadow: 0 0 12px #62e0ad; }
.hero-copy h1 { margin: 12px 0 7px; color: #fff; font-size: clamp(26px, 3vw, 38px); line-height: 1.1; letter-spacing: -1.1px; }
.hero-copy h1 span { color: #8ea7ff; }
.hero-copy p { max-width: 520px; margin: 0; color: rgba(222,230,255,.76); font-size: 13px; }
.hero-actions { display: flex; gap: 9px; margin-top: 21px; flex-wrap: wrap; }
.hero-actions .btn-ghost { color: #e7eaff; border-color: rgba(210,220,255,.25); background: rgba(255,255,255,.07); }
.hero-actions .btn-ghost:hover { background: rgba(255,255,255,.14); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  position: relative; overflow: hidden; min-height: 116px; padding: 17px 18px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(99, 120, 255, .35); box-shadow: var(--shadow-md); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { color: var(--text-soft); font-size: 11px; font-weight: 700; }
.stat-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--primary); background: var(--primary-soft); }
.stat-value { margin-top: 9px; color: var(--text); font-size: 27px; font-weight: 800; line-height: 1; letter-spacing: -.7px; }
.stat-note { margin-top: 7px; color: var(--text-faint); font-size: 10px; }
.stat-card::after { content: ""; position: absolute; right: -25px; bottom: -40px; width: 105px; height: 75px; border-radius: 50%; background: var(--primary); opacity: .055; filter: blur(13px); }

/* Dashboard panels */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .9fr); gap: 16px; align-items: start; }
.panel-card, .card {
  min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
}
.panel-card { overflow: hidden; }
.panel-card.span-2 { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.panel-title-wrap { display: flex; align-items: center; gap: 11px; min-width: 0; }
.panel-icon { width: 37px; height: 37px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.panel-head h2 { margin: 0; color: var(--text); font-size: 15px; font-weight: 780; letter-spacing: -.25px; }
.panel-head p { margin: 3px 0 0; color: var(--text-soft); font-size: 11px; }
.panel-link { display: inline-flex; align-items: center; gap: 5px; color: var(--primary); font-size: 11px; font-weight: 750; white-space: nowrap; }
.panel-link:hover { color: var(--primary-2); }
.quick-actions { display: grid; grid-template-columns: 1fr; gap: 9px; }
.quick-action { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface-2); transition: .17s ease; }
.quick-action:hover { border-color: rgba(90,112,255,.4); background: var(--primary-soft); color: var(--primary); text-decoration: none; transform: translateX(2px); }
.quick-action .panel-icon { width: 34px; height: 34px; }
.quick-action span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.quick-action strong { font-size: 12px; }
.quick-action small { margin-top: 2px; color: var(--text-soft); font-size: 10px; }
.quick-action .quick-arrow { margin-left: auto; color: var(--text-faint); }
.recent-list { display: flex; flex-direction: column; }
.recent-row { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 11px 0; border-bottom: 1px solid var(--border); }
.recent-row:last-child { border-bottom: 0; padding-bottom: 0; }
.recent-row:first-child { padding-top: 0; }
.file-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 10px; color: var(--primary); background: var(--primary-soft); }
.recent-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.recent-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 12px; }
.recent-main small { color: var(--text-soft); font-size: 10px; margin-top: 3px; }
.recent-meta { color: var(--text-soft); font-size: 10px; white-space: nowrap; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.account-mini { display: grid; grid-template-columns: minmax(130px, 1.4fr) minmax(65px, .5fr) minmax(60px, .5fr); gap: 12px; align-items: center; }
.account-mini strong { color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-mini small { color: var(--text-soft); font-size: 10px; }

/* Page sections, cards and forms */
.container { width: 100%; max-width: 1740px; margin: 0 auto; padding: 28px clamp(20px, 3vw, 44px) 48px; }
h1, h2, h3 { color: var(--text); line-height: 1.25; }
h1 { font-size: 27px; margin: 0 0 16px; }
h2 { font-size: 19px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.card { margin-bottom: 17px; }
.card h2 { margin-top: 0; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--text-soft); font-size: 11px; font-weight: 750; }
input[type="text"], input[type="password"], input[type="file"], input[type="email"], input[type="number"], select, textarea {
  width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(87,111,255,.13); }
input[type="file"] { padding: 7px 9px; }
input[type="checkbox"] { accent-color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 39px;
  padding: 9px 15px; border: 1px solid transparent; border-radius: 10px;
  background: linear-gradient(105deg, #477cf8, #6449ed 75%, #7846df); color: #fff;
  font-size: 12px; font-weight: 750; cursor: pointer; text-decoration: none;
  box-shadow: 0 5px 14px rgba(79, 91, 235, .16); transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}
.btn:hover { color: #fff; filter: brightness(1.07); transform: translateY(-1px); text-decoration: none; box-shadow: 0 8px 19px rgba(79,91,235,.22); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn-ghost:hover { color: var(--primary); background: var(--primary-soft); border-color: rgba(90,112,255,.25); box-shadow: none; }
.btn-danger { background: linear-gradient(105deg, #e04c63, #c83256); box-shadow: 0 5px 14px rgba(224,76,99,.15); }
.btn-danger:hover { color: #fff; }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: 11px; border-radius: 8px; }
.btn-del-x, .acc-del { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--text-faint); font-size: 19px; line-height: 1; cursor: pointer; }
.btn-del-x:hover, .acc-del:hover { background: var(--danger-soft); color: var(--danger); }

/* Data tables */
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
table.data th { background: var(--surface-2); color: var(--text-soft); font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
table.data td { color: var(--text); }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--primary-soft); }
table.data a { font-weight: 650; }
.file-cell, .link-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { text-align: right !important; white-space: nowrap; }
.account-table { min-width: 820px; }
.account-main { display: flex; align-items: center; gap: 10px; min-width: 155px; }
.account-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 10px; color: #fff; font-size: 11px; font-weight: 800; background: linear-gradient(145deg, #367ff8, #8051e9); }
.account-main-copy { min-width: 0; display: flex; flex-direction: column; }
.account-main-copy strong { color: var(--text); font-size: 12px; }
.account-main-copy small { margin-top: 2px; color: var(--text-soft); font-size: 10px; }
.steam-id { color: var(--text-soft); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.metric-link { padding: 0; border: 0; background: transparent; color: var(--primary); font-weight: 800; cursor: pointer; }
.metric-link:hover { text-decoration: underline; }
.source-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--primary); background: var(--primary-soft); font-size: 10px; font-weight: 750; }

/* Pills, tabs, alerts */
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 750; line-height: 1.3; white-space: nowrap; }
.badge-yes { color: var(--primary); background: var(--primary-soft); }
.badge-no { color: var(--text-soft); background: var(--surface-3); }
.badge-count { color: var(--success); background: var(--success-soft); }
.badge-games-1 { color: #e05a68 !important; }
.badge-games-2 { color: #d38c2f !important; }
.badge-games-3 { color: #0d9eb5 !important; }
.badge-games-4 { color: #537df2 !important; }
.badge-games-5 { color: #1ba66f !important; }
.tabs, .admin-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border: 1px solid transparent; border-radius: 9px; color: var(--text-soft); font-size: 11px; font-weight: 700; }
.tab:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.tab.active { color: var(--primary); border-color: rgba(91,112,255,.2); background: var(--primary-soft); }
.panel { display: flex; flex-wrap: wrap; gap: 13px; align-items: center; justify-content: space-between; margin-bottom: 16px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-search { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 240px; }
.panel-search input[type="text"] { flex: 1; min-width: 150px; }
.flash { padding: 12px 15px; margin-bottom: 16px; border: 1px solid transparent; border-radius: 11px; font-size: 12px; }
.flash-error { color: var(--danger); background: var(--danger-soft); border-color: rgba(220,75,90,.2); }
.flash-success { color: var(--success); background: var(--success-soft); border-color: rgba(21,155,104,.2); }
.empty { padding: 44px 22px; text-align: center; color: var(--text-soft); }

/* API token card */
.token-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow-sm); }
.token-card-copy h3 { margin: 0 0 4px; color: var(--text); font-size: 13px; }
.token-card-copy p { margin: 0; color: var(--text-soft); font-size: 10px; }
.token-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.token-mask { padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text-soft); font-family: ui-monospace, monospace; letter-spacing: .08em; }

/* Account cards legacy support */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.acc-card { position: relative; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.acc-card:hover { border-color: rgba(91,112,255,.35); box-shadow: var(--shadow-sm); }
.acc-login { padding-right: 22px; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.acc-games { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.acc-games .games { font-size: 15px; font-weight: 800; }
.acc-games-hours { font-size: 12px; font-weight: 700; }
.acc-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.acc-meta { color: var(--text-soft); font-size: 10px; }
.acc-added-by { padding: 2px 7px; border-radius: 999px; color: var(--primary); background: var(--primary-soft); font-size: 10px; font-weight: 750; }
.acc-user-line { margin-top: 9px; padding-top: 7px; border-top: 1px dashed var(--border); text-align: center; font-size: 10px; font-weight: 750; }
.acc-user-blue { color: #4b87ef; }
.acc-user-gold { color: #d79b37; }
.acc-del { position: absolute; top: 5px; right: 5px; }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5,9,20,.68); backdrop-filter: blur(5px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: 100%; max-width: 440px; padding: 23px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow-lg); }
.modal h3 { margin: 0 0 8px; color: var(--text); font-size: 17px; }
.modal p { margin: 0 0 18px; color: var(--text-soft); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#gameIdsList { max-height: 300px; overflow-y: auto; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.toast { position: fixed; z-index: 150; right: 22px; bottom: 22px; padding: 12px 17px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-size: 12px; font-weight: 700; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

/* Admin */
.admin-tabs-wrap { margin-bottom: 20px; padding: 7px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.admin-tabs .tab { padding: 9px 13px; }
.admin-form-grid { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; gap: 12px; align-items: end; }
.admin-form-grid .form-row { margin: 0; }
.upload-card { margin-bottom: 20px; }
.upload-card h2 { margin-bottom: 14px; }
.user-role { color: var(--primary); background: var(--primary-soft); }
.user-blocked { color: var(--danger); background: var(--danger-soft); }

/* Authentication */
.auth-wrap { position: relative; min-height: 100vh; display: grid; place-items: center; overflow: hidden; padding: 28px 18px; background: var(--bg); }
.auth-wrap::before, .auth-wrap::after { content: ""; position: absolute; pointer-events: none; border-radius: 50%; filter: blur(2px); }
.auth-wrap::before { width: 560px; height: 560px; top: -230px; right: -110px; background: radial-gradient(circle, rgba(88,105,255,.16), transparent 68%); }
.auth-wrap::after { width: 520px; height: 520px; bottom: -270px; left: -160px; background: radial-gradient(circle, rgba(150,75,255,.13), transparent 68%); }
.auth-card { position: relative; z-index: 1; width: 100%; max-width: 430px; padding: 34px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 27px; }
.auth-brand .brand-mark { width: 52px; height: 52px; }
.auth-brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.auth-brand-copy strong { color: var(--text); font-size: 18px; }
.auth-brand-copy small { margin-top: 4px; color: var(--text-soft); font-size: 10px; }
.auth-card h1 { margin: 0 0 5px; color: var(--text); font-size: 24px; letter-spacing: -.6px; }
.auth-sub { margin: 0 0 23px; color: var(--text-soft); font-size: 12px; }
.auth-card .btn { width: 100%; margin-top: 3px; }
.auth-foot { margin: 19px 0 0; color: var(--text-soft); text-align: center; font-size: 11px; }
.auth-theme-toggle { position: absolute; z-index: 2; top: 22px; right: 22px; }

/* Responsive */
@media (max-width: 1180px) {
  .sidebar { width: 230px; }
  .app-main { margin-left: 230px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr) minmax(260px, .82fr); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel-card.span-2 { grid-column: auto; }
  .hero-banner { background-position: center, 70% center; }
}
@media (max-width: 760px) {
  .sidebar { width: 270px; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim.is-open { display: block; position: fixed; z-index: 70; inset: 0; background: rgba(4,8,18,.55); }
  .app-main { margin-left: 0; }
  .mobile-menu-btn { display: grid; place-items: center; }
  .topbar { min-height: 68px; padding: 10px 16px; }
  .topbar-kicker { display: none; }
  .topbar-heading small { display: none; }
  .topbar-profile { display: none; }
  .page-content { padding: 20px 16px 36px; }
  .hero-banner { min-height: 205px; padding: 24px 20px; background-size: cover, auto 115%; background-position: center, 72% center; }
  .hero-copy { max-width: 74%; }
  .hero-copy h1 { font-size: 26px; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 105px; padding: 14px; }
  .stat-value { font-size: 23px; }
  .token-card { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 480px) {
  .topbar-actions .theme-label { display: none; }
  .theme-toggle { width: 38px; height: 38px; justify-content: center; padding: 0; }
  .page-heading { align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-banner { min-height: 220px; background-size: cover, auto 90%; background-position: center, 72% center; }
  .hero-copy { max-width: 100%; }
  .hero-copy p { max-width: 260px; }
  .hero-copy h1 { max-width: 280px; font-size: 24px; }
  .panel-card, .card { padding: 15px; }
  .admin-form-grid { grid-template-columns: 1fr; }
  .account-mini { grid-template-columns: minmax(0, 1fr) auto; }
  .account-mini > :last-child { display: none; }
  .auth-card { padding: 25px 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Small utility helpers */
.inline-form { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.inline-form input[type="password"] { width: 132px; min-height: 32px; padding: 6px 8px; font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }


/* D2panel visual v5: the genuine hero portraits as account-user avatars. */
.user-avatar.user-avatar-image,
.account-avatar.user-avatar-image {
  display: block;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  object-fit: cover;
  object-position: center;
  padding: 0;
  border: 1px solid rgba(113, 139, 255, .5);
  background: var(--surface-2);
  box-shadow: 0 4px 12px rgba(67, 72, 185, .22);
  overflow: hidden;
}
.user-avatar.user-avatar-small.user-avatar-image { width: 34px; height: 34px; border-radius: 50%; }
.account-avatar.user-avatar-image { width: 32px; height: 32px; border-radius: 10px; }

/* D2panel visual v5: consistent, accessible native file selector in both themes. */
input[type="file"].archive-file-input {
  display: block;
  min-height: 48px;
  padding: 5px 10px 5px 5px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  line-height: 36px;
  cursor: pointer;
}
input[type="file"].archive-file-input::file-selector-button {
  border: 0;
  border-radius: 9px;
  min-height: 35px;
  padding: 8px 14px;
  margin-right: 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 750;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(105deg, #477cf8, #6449ed 75%, #7846df);
  box-shadow: 0 4px 12px rgba(79, 91, 235, .18);
  transition: filter .16s ease;
}
input[type="file"].archive-file-input:hover::file-selector-button { filter: brightness(1.11); }
input[type="file"].archive-file-input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* D2mesh integration: only changes the D2panel container, not Messenger UI. */
body.app-body:has(.d2mesh-frame) { height: 100dvh; overflow: hidden; }
body.app-body:has(.d2mesh-frame) .page-content {
  max-width: none; height: calc(100dvh - 77px); min-height: 440px;
  padding: 12px 14px 14px; display: flex; overflow: hidden;
}
.d2mesh-frame-wrap { flex: 1; min-width: 0; min-height: 0; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-md); background: var(--surface); }
.d2mesh-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
@media (max-width: 760px) {
  body.app-body:has(.d2mesh-frame) .page-content { height: calc(100dvh - 66px); padding: 6px; }
  .d2mesh-frame-wrap { border-radius: 10px; }
}

/* D2PANEL_RECENT_ACCOUNTS_STYLES_V1 — компактные счётчики рядом с Аккаунтов / Игр */
.page-heading-actions .badge-recent-accounts {
  gap: 5px;
  color: var(--text-soft);
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.page-heading-actions .badge-recent-accounts strong {
  color: var(--primary);
  font-size: inherit;
  font-weight: 800;
}
