:root {
  --bg: #0E140D; --bg2: #1A2518; --bg3: rgba(255, 255, 255, .09);
  --ink: #F5F2EB; --ink2: #CFCBBB; --ink3: #8E9277;
  --navy: #1A2518; --navy2: #2D4028;
  --accent: #C85A2E; --al: rgba(200, 90, 46, .14); --ad: #E0794A;
  --green: #4ADE9C; --amber: #F0B23D; --sand: #C4AB78;
  --card: linear-gradient(155deg, rgba(45, 64, 40, .55), rgba(26, 37, 24, .55));
  --card-line: rgba(255, 255, 255, .09);
  --r: 14px; --rs: 9px; --t: .15s ease;
  --shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 6px 20px rgba(0, 0, 0, .35);
  --glow: 0 0 0 1px rgba(200, 90, 46, .18), 0 8px 28px -4px rgba(200, 90, 46, .4), 0 2px 10px rgba(200, 90, 46, .25);
  --serif: 'Cormorant Garamond', Georgia, serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 14px/1.5 'Hanken Grotesk', system-ui, sans-serif;
  background: radial-gradient(1000px 500px at 20% -10%, rgba(200, 90, 46, .09), transparent 60%), radial-gradient(900px 500px at 100% 0%, rgba(45, 64, 40, .12), transparent 55%), var(--bg);
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 22px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); margin: 18px 0 6px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* buttons */
button { cursor: pointer; border: 1.5px solid var(--bg3); background: transparent; color: var(--ink2); border-radius: var(--rs); padding: 8px 15px; font-size: 13px; font-weight: 500; transition: var(--t); }
button:hover { border-color: var(--ink3); background: var(--bg2); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--ad); border-color: var(--ad); transform: translateY(-2px); box-shadow: var(--glow); }
button.danger { color: var(--ad); border-color: rgba(224, 121, 74, .45); }
button.danger:hover { background: var(--al); }
button.link { border: 0; background: none; padding: 0; color: var(--sand); text-align: left; font-weight: 600; }
button.link:hover { background: none; color: var(--ink); text-decoration: underline; }
button:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* form fields */
input, select, textarea { width: 100%; padding: 8px 10px; border-radius: var(--rs); border: 1.5px solid var(--bg3); background: var(--bg); outline: none; transition: var(--t); font-size: 13px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--ink3); }
textarea { min-height: 90px; resize: vertical; }
select { -webkit-appearance: none; appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%238E9277' stroke-width='1.5' fill='none'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; }
label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--ink3); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 160px; }
.muted { color: var(--ink3); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 38px 34px; border-radius: var(--r); border: 1px solid var(--card-line); box-shadow: 0 30px 80px rgba(0, 0, 0, .5); background: linear-gradient(155deg, rgba(45, 64, 40, .9), rgba(14, 20, 13, .96)); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 11px; font-family: var(--serif); font-size: 34px; color: #fff; margin-bottom: 26px; }
.brand-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: var(--glow); flex-shrink: 0; }
.login-card h2 { font-size: 26px; margin-bottom: 4px; }
.login-card .muted { margin: 0 0 22px; font-size: 13px; }
.login-card button.primary { width: 100%; padding: 10px; margin-top: 6px; }
.err { color: var(--ad); min-height: 20px; margin: 12px 0 0; font-size: 13px; }

/* app shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: linear-gradient(165deg, var(--navy2) 0%, var(--navy) 55%, #0E140D 100%); border-right: 1px solid rgba(200, 90, 46, .16); box-shadow: 4px 0 24px rgba(0, 0, 0, .35); }
.sidebar .brand { font-size: 24px; padding: 20px 18px 16px; margin: 0; }
.sidebar nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.navtab { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border: 0; border-radius: 9px; color: rgba(255, 255, 255, .55); background: transparent; font-size: 13.5px; text-align: left; }
.navtab:hover { color: #fff; background: rgba(255, 255, 255, .06); transform: translateX(2px); border: 0; }
.navtab.on { color: #fff; background: linear-gradient(120deg, rgba(200, 90, 46, .22), rgba(200, 90, 46, .08)); box-shadow: inset 3px 0 0 var(--accent), var(--glow); }
.ico { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.sidefoot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: 8px; }
.who { font-size: 13px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; min-width: 0; }
.topbar { height: 54px; padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; border-bottom: 1px solid rgba(255, 255, 255, .08); backdrop-filter: blur(12px); }
.content { padding: 1.5rem; max-width: 1200px; }

/* stats, cards, tables */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--card-line); border-left: 3px solid var(--accent); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); transition: var(--t); }
.stat:hover { transform: translateY(-3px); }
.stat-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); margin-bottom: 8px; }
.stat-val { font-size: 28px; font-weight: 300; line-height: 1; }
.stat-val.ac { color: var(--accent); } .stat-val.gr { color: var(--green); } .stat-val.am { color: var(--amber); }
.panel { background: var(--card); border: 1px solid var(--card-line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.tablewrap { overflow-x: auto; padding: 4px 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--card-line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }
th { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); font-weight: 700; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 10.5px; font-weight: 600; background: var(--al); color: var(--ad); white-space: nowrap; }
.chip.won { background: rgba(74, 222, 156, .14); color: var(--green); }
.chip.hold { background: rgba(240, 178, 61, .14); color: var(--amber); }
.chip.plain { background: rgba(255, 255, 255, .08); color: var(--ink2); }
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.count { margin: 0 0 10px; font-size: 13px; }
.empty { padding: 34px; text-align: center; color: var(--ink3); }
.timeline { display: grid; gap: 8px; margin: 8px 0 14px; }
.timeline .item { border-left: 3px solid var(--accent); padding: 2px 0 2px 11px; }
pre.diff { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.45 ui-monospace, Menlo, monospace; color: var(--ink3); max-width: 520px; }

/* dialog */
dialog { border: 1px solid var(--card-line); border-radius: var(--r); color: var(--ink); width: min(540px, calc(100vw - 24px)); max-height: 90vh; padding: 20px; background: linear-gradient(155deg, rgba(45, 64, 40, .97), rgba(26, 37, 24, .98)); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
dialog .row.between { margin-bottom: 14px; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 15px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; font-weight: 500; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .brand { padding: 12px 14px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 4px 10px; }
  .sidefoot { border-top: 0; display: flex; align-items: center; margin-left: auto; }
  .who { display: none; }
  .content { padding: 1rem; }
  th:nth-child(n+4), td:nth-child(n+4) { display: none; }
}
