:root {
  color-scheme: dark;
  --bg: #07101c;
  --surface: #101b2d;
  --surface-2: #15243b;
  --surface-3: #0b1526;
  --line: #2b4262;
  --line-strong: #42638c;
  --text: #eef4ff;
  --muted: #a7b6ca;
  --accent: #7cff4b;
  --accent-2: #5dc2ff;
  --warning: #ffbf47;
  --danger: #ff7485;
  --shadow: 0 18px 55px rgb(0 0 0 / 32%);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 88% -10%, rgb(69 183 255 / 20%), transparent 36%), radial-gradient(circle at 8% 20%, rgb(124 255 75 / 10%), transparent 28%), var(--bg);
  color: var(--text);
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.65;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .22em; }
:focus-visible { outline: 3px solid var(--warning); outline-offset: 3px; }
.skip-link { position: fixed; inset-block-start: 8px; inset-inline-start: 8px; z-index: 100; padding: 9px 13px; border-radius: 9px; background: #fff; color: #07101c; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.wrap { width: min(100%, 1480px); margin-inline: auto; padding: 20px; }
.head, .nav, .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.head { padding: 16px 18px; border: 1px solid rgb(130 183 255 / 18%); border-radius: 18px; background: rgb(9 17 31 / 82%); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.head h1 { margin: 0 0 5px; font-size: clamp(1.35rem, 3vw, 2rem); }
.nav { justify-content: flex-start; margin: 14px 0; padding-block: 4px; overflow-x: auto; overscroll-behavior-inline: contain; }
.nav a, .tabs a { min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: #dce9fa; white-space: nowrap; }

.commandbar { position: sticky; inset-block-start: 8px; z-index: 20; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; margin: 14px 0 18px; padding: 10px 12px; border: 1px solid rgb(130 183 255 / 22%); border-radius: 16px; background: rgb(7 16 28 / 94%); box-shadow: 0 14px 38px #0007; backdrop-filter: blur(18px); }
.commandbar-brand, .commandbar-links { display: flex; align-items: center; gap: 8px; }
.commandbar-links { overflow-x: auto; scrollbar-width: thin; scroll-snap-type: x proximity; }
.commandbar-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 11px; border-radius: 9px; color: #c2d1e5; white-space: nowrap; scroll-snap-align: start; }
.commandbar-links a:hover, .commandbar-links a.active { background: #1b3657; color: #fff; text-decoration: none; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 15px var(--accent); }
.version, .role-chip, .metric-badge { display: inline-flex; align-items: center; font-size: .76rem; border: 1px solid #3b5577; border-radius: 999px; padding: 4px 8px; color: #c4d4e9; white-space: nowrap; }

button, input, select, textarea, .button-link { min-height: 44px; font: inherit; border: 1px solid var(--line-strong); border-radius: 10px; }
button, .button-link { display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; background: #1f4d79; color: #fff; cursor: pointer; transition: transform .15s ease, filter .15s ease, border-color .15s ease; }
button:hover, .button-link:hover { filter: brightness(1.14); text-decoration: none; transform: translateY(-1px); }
button.secondary, .button-link.secondary { background: #172b46; }
button.danger { background: #762d40; border-color: #a94b61; }
button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
input, select, textarea { width: 100%; padding: 9px 11px; background: var(--surface-3); color: var(--text); }
input::placeholder { color: #8499b3; opacity: 1; }
label { display: block; margin: 10px 0 5px; }
form.inline { display: inline-flex; align-items: center; gap: 6px; margin: 3px; }
form.inline input, form.inline select { width: auto; max-width: 210px; }
.account-actions { display: flex; gap: 6px; flex-wrap: wrap; min-width: 260px; }
.account-actions form { margin: 0; }

.card, .panel-section { margin: 14px 0; padding: 18px; border: 1px solid #2a405f; border-radius: 18px; background: rgb(14 26 44 / 96%); box-shadow: 0 12px 34px #0003; }
.card { overflow: hidden; }
.panel-section > h2, .card > h2:first-child { margin-block-start: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 13px; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 14px; }
.status { font-size: 1.2rem; color: var(--accent); }
.ok, .allow { color: var(--accent); }
.warn { color: var(--warning); }
.bad, .deny { color: var(--danger); }
.muted { color: var(--muted); font-size: .9rem; }
.mono, .tag { font-family: Consolas, monospace; direction: ltr; text-align: left; unicode-bidi: isolate; }
.tag { display: inline-block; padding: 4px 7px; border-radius: 6px; background: #07101e; }
.dim { opacity: .7; }

.hero-panel { position: relative; overflow: hidden; padding: clamp(20px, 4vw, 30px); border: 1px solid rgb(124 255 75 / 18%); border-radius: 22px; background: linear-gradient(125deg, rgb(21 36 59 / 98%), rgb(9 20 35 / 98%)); box-shadow: var(--shadow); }
.hero-panel::after { content: "IRANCS"; position: absolute; inset-inline-end: 24px; inset-block-end: -32px; font: 900 86px/1 Arial; color: rgb(255 255 255 / 3%); letter-spacing: 8px; pointer-events: none; }
.hero-panel h2 { position: relative; margin: 0 0 7px; font-size: clamp(1.5rem, 3vw, 2.35rem); }
.hero-actions { position: relative; display: flex; gap: 9px; flex-wrap: wrap; margin-top: 17px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 12px; margin: 14px 0; }
.kpi { min-height: 122px; padding: 16px; border: 1px solid #2a4264; border-radius: 16px; background: linear-gradient(145deg, #132139, #0d1829); }
.kpi-label { color: #aabbd1; font-size: .82rem; }
.kpi-value { margin-top: 5px; font-size: clamp(1.45rem, 4vw, 2.15rem); font-weight: 900; }
.kpi-note { color: #9fb1c8; font-size: .78rem; }
.server-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.server-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.meter { height: 9px; margin-top: 8px; overflow: hidden; border-radius: 99px; background: #07111f; }
.meter > span { display: block; height: 100%; max-width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

.notice { margin: 9px 0; padding: 11px 13px; border-inline-start: 4px solid var(--accent-2); border-radius: 10px; background: #10233a; }
.notice.warning { border-color: var(--warning); background: #302515; }
.notice.danger { border-color: var(--danger); background: #321923; }
.danger-zone { border-color: rgb(255 116 133 / 38%); }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }
.flash-stack { position: relative; z-index: 30; }
.flash { margin: 10px 0; padding: 11px 14px; border: 1px solid #315e87; border-radius: 10px; background: #17395a; }

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 10px 0; }
.search-control { display: grid; gap: 4px; width: min(100%, 430px); }
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid #2a405f; border-radius: 13px; }
table { width: 100%; border-collapse: collapse; }
.card > table { display: block; max-width: 100%; overflow: auto; }
.table-wrap table { display: table; min-width: 700px; }
th, td { padding: 10px; border-bottom: 1px solid #2a3c56; text-align: start; vertical-align: top; white-space: nowrap; }
th { position: sticky; inset-block-start: 0; z-index: 1; background: #14243a; }
tbody tr:hover { background: rgb(69 183 255 / 6%); }
pre { direction: ltr; max-height: 460px; overflow: auto; margin: 0; padding: 13px; border-radius: 10px; background: #07101e; color: #d5e7ff; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }

.login { max-width: 430px; margin: 10vh auto; }
.tabs { position: sticky; inset-block-start: 0; z-index: 5; display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 0; background: rgb(9 17 31 / 91%); }
.perm-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.perm { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-3); }
.perm-head { display: flex; justify-content: space-between; gap: 8px; }
.choices { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.choices label { margin: 0; }
.choices input, label input[type="checkbox"] { width: auto; min-height: auto; }
.risk { display: inline-flex; align-items: center; height: fit-content; padding: 3px 7px; border-radius: 12px; background: #4a2937; font-size: .78rem; }
.section-title { scroll-margin-top: 90px; border-inline-start: 4px solid var(--accent-2); padding-inline-start: 10px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 9px; }
.quick-grid form, .quick-grid button { width: 100%; }
.quick-link { display: block; min-height: 76px; padding: 13px; border: 1px solid #345176; border-radius: 12px; background: #11223a; }
.quick-link:hover { border-color: var(--accent-2); text-decoration: none; transform: translateY(-1px); }
.timeline { display: grid; gap: 8px; }
.timeline-item { display: grid; grid-template-columns: 105px 130px minmax(0, 1fr); gap: 10px; padding: 10px; border-bottom: 1px solid #25364e; }
details > summary { cursor: pointer; }
.admin-row-actions { display: flex; gap: 7px; flex-wrap: wrap; max-width: 330px; }
.admin-row-actions form { margin: 0; }
#admin-editor details, #ranks details { margin-top: 18px; }
#admin-editor summary, #ranks summary { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
#admin-editor .perm-list, #ranks .perm-list { margin-top: 12px; }
#admin-roster td { white-space: normal; }
@media (max-width:700px) {
  #admin-roster, #admin-roster tbody { display:block; width:100%; min-width:0; }
  #admin-roster thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  #admin-roster tr { display:block; padding:10px; border-bottom:1px solid var(--line); }
  #admin-roster td { display:block; border:0; padding:9px 5px; overflow-wrap:anywhere; }
  #admin-roster td::before { display:block; color:#a9b9cf; font-size:12px; margin-bottom:4px; }
  #admin-roster td:nth-child(1)::before { content:'ادمین / حساب'; }
  #admin-roster td:nth-child(2)::before { content:'رنک / سیاست'; }
  #admin-roster td:nth-child(3)::before { content:'آنلاین ثبت‌شده در ماه'; }
  #admin-roster td:nth-child(4)::before { content:'حضور ثبت‌شده در تیم'; }
  #admin-roster td:nth-child(5)::before { content:'روز فعال / فرمان'; }
  #admin-roster td:nth-child(6)::before { content:'عملیات'; }
  #admin-roster .admin-row-actions { max-width:none; }
  #admin-roster tr[hidden] { display:none; }
}
[hidden] { display: none !important; }

.player-hero { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.player-hero p { margin-block-end: 0; color: var(--muted); }
.live-state { display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 8px 12px; border: 1px solid #315579; border-radius: 999px; background: #0b1a2c; white-space: nowrap; }
.player-live-panel { scroll-margin-block-start: 90px; }
.player-live-panel[aria-busy="true"] .live-state { opacity: .7; }
.player-kpis { grid-template-columns: repeat(5, minmax(130px, 1fr)); }
.player-kpis .kpi { min-height: 104px; }
.player-kpis .kpi-value { font-size: clamp(1.25rem, 3vw, 1.8rem); overflow-wrap: anywhere; }
.player-refresh { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.player-table-wrap { background: #0a1525; }
.player-table { min-width: 1480px !important; font-size: .92rem; }
.player-table th:first-child, .player-table td:first-child { position: sticky; inset-inline-start: 0; z-index: 2; min-width: 145px; background: #101e32; }
.player-table th:first-child { z-index: 3; background: #14243a; }
.player-table tbody tr:hover td:first-child { background: #142945; }
.player-state, .team-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 68px; padding: 4px 9px; border: 1px solid transparent; border-radius: 999px; font-weight: 700; }
.state-alive { color: #b8ff9e; border-color: #477f3c; background: #173522; }
.state-dead { color: #ffb7c0; border-color: #874354; background: #3a1a25; }
.state-spectator { color: #ffe2a5; border-color: #856933; background: #352a16; }
.state-unknown { color: #c3cfdf; border-color: #53647b; background: #202b3b; }
.team-t { color: #ffcb76; border-color: #815f2d; background: #342514; }
.team-ct { color: #8fd7ff; border-color: #376d8d; background: #142d42; }
.team-spectator, .team-unassigned, .team-unknown { color: #c3cfdf; border-color: #53647b; background: #202b3b; }
.player-action-form { min-width: 430px; }
.player-action-form input[name="reason"] { min-width: 150px; }
.player-footnote { margin-block-end: 0; }

@media (max-width: 900px) {
  .wrap { padding: 10px; }
  .head { border-radius: 13px; }
  .commandbar { position: static; grid-template-columns: 1fr; gap: 7px; }
  .commandbar-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; overflow: visible; }
  .commandbar-links a { justify-content: center; white-space: normal; text-align: center; }
  .role-chip { justify-self: start; }
  .split { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 1fr; }
  .perm-list { grid-template-columns: 1fr; }
  .player-hero { align-items: flex-start; flex-direction: column; }
  .player-kpis { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .player-kpis .kpi { min-width: 150px; scroll-snap-align: start; }
}
@media (max-width: 640px) {
  .wrap { padding: 7px; }
  .head, .card, .panel-section, .hero-panel { padding: 14px; border-radius: 13px; }
  .server-card { grid-template-columns: 1fr; }
  .server-card > .button-link { width: 100%; }
  form.inline { display: flex; width: 100%; flex-wrap: wrap; }
  form.inline input, form.inline select, form.inline button { width: 100%; max-width: none; }
  .account-actions { min-width: 210px; }
  .account-actions form, .account-actions button { width: 100%; }
  .hero-actions, .hero-actions .button-link { width: 100%; }
  .commandbar-brand { flex-wrap: wrap; }
  .commandbar-links { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-inline: 0; padding-inline: 0; }
  .table-wrap table { min-width: 620px; }
  .live-state { max-width: 100%; white-space: normal; }
  .player-refresh, .player-refresh button { width: 100%; }
  .player-refresh { justify-content: flex-start; }
  .player-action-form { min-width: 260px; }
  .player-table-wrap { border: 0; overflow: visible; background: transparent; }
  .player-table { display: block; width: 100%; min-width: 0 !important; }
  .player-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .player-table tbody { display: grid; gap: 14px; }
  .player-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #0a1525; }
  .player-table td, .player-table td:first-child { display: flex; flex-direction: column; gap: 6px; position: static; z-index: auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; padding: 9px 5px; background: transparent; }
  .player-table td::before { font-size: .75rem; color: var(--muted); }
  .player-table td[data-col="name"] { grid-column: 1 / -1; font-weight: 700; font-size: 1.05rem; }
  .player-table td[data-col="name"]::before { content: "بازیکن"; }
  .player-table td[data-col="state"]::before { content: "وضعیت"; }
  .player-table td[data-col="team"]::before { content: "تیم"; }
  .player-table td[data-col="frags"]::before { content: "Kills / امتیاز"; }
  .player-table td[data-col="deaths"]::before { content: "Deaths / دث"; }
  .player-table td[data-col="kd"]::before { content: "K/D"; }
  .player-table td[data-col="vitals"]::before { content: "HP / Armor / Money"; }
  .player-table td[data-col="network"]::before { content: "Ping / Loss"; }
  .player-table td[data-col="connected"]::before { content: "زمان اتصال"; }
  .player-table td[data-col="authid"]::before { content: "SteamID"; }
  .player-table td[data-col="ip"]::before { content: "IP"; }
  .player-table td[data-col="actions"] { grid-column: 1 / -1; }
  .player-table td[data-col="actions"]::before { content: "عملیات امن"; }
  .player-table .tag { font-size: .72rem; overflow-wrap: anywhere; }
  .player-action-form { min-width: 0; margin: 0; }
  .player-table [data-empty-row] td { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
