/* ── Tiflisi ADMIN — dark theme ─────────────────────────────────── */
:root {
  color-scheme: dark;            /* browser UI (selects, checkboxes, scrollbars, date/number pickers) render dark */
  --bg:        #0d1017;
  --bg-2:      #141926;
  --bg-3:      #1b2233;
  --panel:     #161c2b;
  --line:      #232c40;
  --line-2:    #2c3750;
  --text:      #e6ebf5;
  --muted:     #8b96ad;
  --muted-2:   #5e6982;
  --accent:    #e0b061;   /* western gold */
  --accent-2:  #c9963f;
  --blue:      #5aa9e6;
  --green:     #4ec98a;
  --red:       #e5646e;
  --amber:     #e8b64c;
  --radius:    10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Login ── */
.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2233 0%, var(--bg) 60%);
}
.login-card {
  width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-card h1 { font-size: 20px; letter-spacing: .5px; }
.login-card .brand-sub { color: var(--muted); font-size: 12px; margin: 4px 0 24px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent-2); }
.login-card button {
  width: 100%; margin-top: 22px; padding: 12px; border: none; border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #201a0c;
  font-weight: 700; font-size: 14px;
}
.login-card button:hover { filter: brightness(1.06); }
.login-err { color: var(--red); font-size: 12px; margin-top: 14px; min-height: 16px; }
.login-hint { margin-top: 20px; font-size: 11px; color: var(--muted-2); line-height: 1.7; border-top: 1px solid var(--line); padding-top: 14px; }
.login-hint code { color: var(--accent); font-family: var(--mono); }

/* ── App shell ── */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.brand .logo { font-size: 16px; font-weight: 800; letter-spacing: 1px; }
.brand .logo b { color: var(--accent); }
.brand .tag { font-size: 10px; color: var(--muted-2); letter-spacing: 2px; text-transform: uppercase; margin-top: 3px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); font-size: 13px; cursor: pointer; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item:hover .ico { color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.active .ico { color: var(--accent); }
.nav-item .ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; color: var(--muted-2); flex-shrink: 0; }
.nav-item .ico svg { width: 18px; height: 18px; }
.nav-sep { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted-2); padding: 14px 12px 6px; }
.side-foot { padding: 14px; border-top: 1px solid var(--line); font-size: 12px; }
.side-foot .who { color: var(--text); font-weight: 600; }
.side-foot .role { color: var(--accent); text-transform: capitalize; font-size: 11px; }
.side-foot button { margin-top: 10px; width: 100%; padding: 8px; background: var(--bg-3); border: 1px solid var(--line); color: var(--muted); border-radius: 7px; font-size: 12px; }
.side-foot button:hover { color: var(--red); border-color: var(--red); }

.main { overflow-y: auto; }
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(13,16,23,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; }
.topbar h2 { font-size: 17px; font-weight: 700; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.content { padding: 24px 28px 60px; }

/* ── Cards / stats ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .v.gold { color: var(--accent); }
.stat .v.red { color: var(--red); }
.stat .v.green { color: var(--green); }

/* ── Filter bar ── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: flex-end; }
.filters .fld { display: flex; flex-direction: column; gap: 4px; }
.filters label { font-size: 11px; color: var(--muted); }
.filters input, .filters select {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 7px; font-size: 13px; outline: none; min-width: 120px;
}
.filters input:focus, .filters select:focus { border-color: var(--accent-2); }
.btn { padding: 8px 16px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text); border-radius: 7px; font-size: 13px; }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #201a0c; border: none; font-weight: 700; }
.btn:hover { filter: brightness(1.08); }
.chip { display: inline-flex; gap: 6px; }
.chip button { padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); font-size: 12px; }
.chip button.on { background: var(--bg-3); color: var(--accent); border-color: var(--accent-2); }

/* ── Table ── */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { position: sticky; top: 0; background: var(--bg-3); text-align: left; padding: 11px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; }
/* column separators — drop the trailing edge so the grid stops at the last column */
thead th:last-child, tbody td:last-child { border-right: none; }
/* zebra striping for easier row tracking; hover still wins */
tbody tr:nth-child(even) td { background: rgba(255,255,255,.018); }
tbody tr:hover td { background: var(--bg-2); }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th.sortable.active { color: var(--accent); }
.sort-ind { opacity: .7; font-size: 10px; }
td.empty { text-align: center; color: var(--muted-2); padding: 40px; }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-family: var(--mono); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.mono { font-family: var(--mono); color: var(--muted); font-size: 12px; }
/* Storage rows read as a sentence ("X took 3× iron from the Sheriff armoury"),
   so the column needs room to breathe and must not be clipped to one line. */
.story { display: inline-block; min-width: 22ch; max-width: 52ch; line-height: 1.45; white-space: normal; }
.story b { color: var(--text); font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.gray { background: #2a3346; color: var(--muted); }
.pill.gold { background: rgba(224,176,97,.15); color: var(--accent); }
.pill.red { background: rgba(229,100,110,.15); color: var(--red); }
.pill.green { background: rgba(78,201,138,.15); color: var(--green); }
.pill.blue { background: rgba(90,169,230,.15); color: var(--blue); }
.pill.amber { background: rgba(232,182,76,.15); color: var(--amber); }
.link { color: var(--blue); cursor: pointer; }
.link:hover { text-decoration: underline; }

.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--bg-2); font-size: 12px; color: var(--muted); }
.pager button { padding: 6px 12px; margin-left: 6px; background: var(--bg-3); border: 1px solid var(--line); color: var(--text); border-radius: 6px; font-size: 12px; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

.empty { padding: 44px; text-align: center; color: var(--muted-2); }
.loading { padding: 44px; text-align: center; color: var(--muted); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 24px 0 12px; }

/* ── Player profile ── */
.profile { display: grid; grid-template-columns: 320px 1fr; gap: 20px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.pcard h3 { font-size: 18px; }
.pcard .pid { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-top: 3px; }
.pcard .rowl { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pcard .rowl:last-child { border: none; }
.pcard .rowl .l { color: var(--muted); }
.pcard .rowl .r { font-weight: 600; }
.back { color: var(--muted); font-size: 13px; cursor: pointer; margin-bottom: 14px; display: inline-block; }
.back:hover { color: var(--text); }
.notice { background: rgba(229,100,110,.08); border: 1px solid rgba(229,100,110,.3); color: #f0a5ab; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 13px; }
.hidden { display: none !important; }

/* ── Flag badge, range chips, date inputs, a11y, responsive ── */
.nav-item { position: relative; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.range-chip button { padding: 7px 10px; font-size: 12px; }

/* Segmented control — sub-category switch inside a page (e.g. Medical). */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel-2, #1a2130); border: 1px solid var(--line, #2a3346); border-radius: 10px; }
.seg button { padding: 7px 16px; font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.on { color: var(--text); background: var(--accent-dim, rgba(224,176,97,.15)); box-shadow: inset 0 0 0 1px rgba(224,176,97,.3); }
input[type=date] { color-scheme: dark; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.nav-item:focus-visible, .link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; height: auto; }
  body { overflow-y: auto; }
  .main { overflow: visible; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .nav { display: flex; flex-wrap: wrap; padding: 8px; }
  .nav-item { flex: 0 0 auto; }
  .nav-sep { width: 100%; }
  .profile { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .filters { gap: 8px; }
  .topbar { padding: 14px 16px; }
}

/* ── Staff management controls ── */
select.mini { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 5px 8px; border-radius: 6px; font-size: 12px; text-transform: capitalize; }
.mini-btn { background: var(--bg-3); border: 1px solid var(--line); color: var(--muted); padding: 5px 10px; border-radius: 6px; font-size: 12px; margin-left: 4px; }
.mini-btn:hover { color: var(--text); border-color: var(--line-2); }
.mini-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* ── Language toggle + greeting ── */
.lang-toggle { background: var(--bg-3); border: 1px solid var(--line); color: var(--muted); padding: 7px 12px; border-radius: 7px; font-size: 12px; font-weight: 600; letter-spacing: .5px; }
.lang-toggle:hover { color: var(--accent); border-color: var(--accent-2); }
.foot-row { display: flex; gap: 8px; margin-top: 10px; }
.foot-row button#logoutBtn { margin-top: 0; flex: 1; }
/* Transaction-trace overlay — every leg of one tx_id */
.tx-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.tx-panel { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); width: min(1000px, 100%); box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.tx-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.tx-body { padding: 14px 16px 18px; }

/* "deleted character" marker in log/player cells — name is gone, account remains */
.del-tag { display: inline-block; font-size: 9px; font-weight: 600; color: var(--red); background: rgba(229,100,110,.12); border: 1px solid rgba(229,100,110,.3); border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: middle; cursor: help; }

/* Editable rank name (Staff → Permissions) */
.rank-name { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); font: inherit; font-weight: 600; padding: 5px 8px; border-radius: 6px; width: 130px; }
.rank-name:hover { border-color: var(--line-2); }
.rank-name:focus { border-color: var(--accent-2); outline: none; }

/* ── Player-profile horse cards ── */
.hcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.hcard-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; user-select: none; }
.hcard-head:hover { background: var(--bg-3); }
.hcard-head .chev { color: var(--muted-2); transition: transform .15s ease; font-size: 11px; flex-shrink: 0; }
.hcard.open .chev { transform: rotate(90deg); color: var(--accent); }
.hcard-head .hname { font-weight: 600; }
.hcard-head .hsub { color: var(--muted); font-size: 12px; }
.hcard-head .hflags { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.hbody { padding: 14px; border-top: 1px solid var(--line); background: var(--bg-2); }
.hgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.hh { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted-2); margin-bottom: 8px; }
.stat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 12px; }
.stat-row .sk { width: 92px; color: var(--muted); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row .sbar { flex: 1; height: 6px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.stat-row .sbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.stat-row .sv { width: 32px; text-align: right; color: var(--text); font-family: var(--mono); }
.hinv-tbl { width: 100%; font-size: 12px; }
.hinv-tbl td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.hinv-tbl tr:last-child td { border-bottom: none; }
@media (max-width: 860px) { .hgrid { grid-template-columns: 1fr; gap: 14px; } }

.login-lang { position: absolute; top: 22px; right: 26px; }
.greeting { font-size: 15px; color: var(--muted); margin-bottom: 18px; }
.greeting::first-letter { text-transform: capitalize; }

/* ── Native control theming — make browser chrome honor the dark theme ── */
/* Placeholders: consistent muted tone instead of the browser default grey. */
::placeholder { color: var(--muted-2); opacity: 1; }
input, select, textarea, button { font-family: inherit; }

/* Checkboxes / radios / range (permissions matrix, export toggles, etc.). */
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; }
input[type=range] { accent-color: var(--accent); }

/* Native <select> and its dropdown list — options otherwise render OS-light. */
select { color-scheme: dark; }
select option, select optgroup { background: var(--bg-2); color: var(--text); }

/* Kill Chrome/Edge autofill's white/blue box on login + filter inputs. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
          box-shadow: 0 0 0 1000px var(--bg-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;   /* defeat the autofill flash */
}

/* Firefox scrollbars (WebKit ones are already styled above). */
* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }

/* Text selection in the app's accent, not the OS blue. */
::selection { background: rgba(224,176,97,.28); color: var(--text); }

/* Date/time popups (already dark via color-scheme, but pin the indicator too). */
input[type=date], input[type=datetime-local], input[type=time] { color-scheme: dark; }
::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }
