/* Thamarr — Sonarr-style dark theme */
:root {
  --bg: #1f2127; --bar: #17181d; --side: #23252c; --tool: #262830; --card: #262830; --card2: #2a2c33;
  --line: #2f323a; --line2: #353841; --field: #1f2127; --fieldline: #3a3e47; --chip: #33363f;
  --text: #e4e6ea; --muted: #b9bdc5; --dim: #9ba0aa; --white: #ffffff;
  --accent: #3fc7f0; --accent2: #8fdcf6; --teal: #4a9cb0;
  --ok: #5fb36b; --bad: #e5675b; --warn: #f0a13a; --off: #5c616b; --anime: #6b3fa6;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { color: var(--accent2); }
code, .mono { font-family: ui-monospace, Consolas, monospace; }
h1, h2, h3 { color: var(--white); font-weight: 500; }
button, input, select, textarea { font: inherit; }
.sr { position: absolute; left: -9999px; }

/* shell */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 8px 16px; min-height: 60px; background: var(--bar); border-bottom: 1px solid #2c2f36; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--white); font-weight: 700; font-size: 18px; }
.logo:hover { color: var(--white); }
.search { flex: 1 1 260px; display: flex; justify-content: center; }
.search label { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 300px; background: #22252b; border: 1px solid var(--fieldline); border-radius: 6px; padding: 0 12px; min-height: 36px; }
.search input { flex: 1; background: none; border: 0; color: var(--text); outline: none; min-width: 0; }
.topicons { display: flex; gap: 4px; }
.ib { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; background: none; border: 0; color: #c9ccd2; border-radius: 6px; cursor: pointer; }
.ib:hover { background: #2a2d35; color: var(--white); }
.shell { display: flex; flex-wrap: wrap; align-items: stretch; min-height: calc(100vh - 61px); }
.side { flex: 1 1 200px; max-width: 100%; background: var(--side); padding: 8px 10px 24px; display: flex; flex-direction: column; gap: 2px; }
.sec { font-size: 11px; letter-spacing: .08em; color: var(--dim); text-transform: uppercase; padding: 18px 12px 6px; }
.nv { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 6px; color: var(--text); font-size: 15px; }
.nv:hover { background: #2a2d35; color: var(--white); }
.nv.on { background: #2c2f38; font-weight: 600; }
.sub { display: flex; padding: 8px 12px 8px 40px; border-radius: 6px; color: var(--text); }
.sub:hover { background: #2a2d35; color: var(--white); }
.sub.on { background: #2c2f38; box-shadow: inset 3px 0 0 var(--accent); }
.badge { margin-left: auto; background: var(--warn); color: #1a1c21; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }
.divider { height: 1px; background: var(--line2); margin: 14px 8px; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 20px; background: var(--tool); border-bottom: 1px solid var(--line); min-height: 57px; }
.tb { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); padding: 8px 12px; border-radius: 6px; cursor: pointer; min-height: 40px; }
.tb:hover { background: #2a2d35; color: var(--white); }
.tb:disabled { color: #7c818b; cursor: default; background: none; }
.spacer { flex: 1 1 auto; }
.crumb { padding: 20px 28px 8px; color: var(--dim); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; }
.crumb b { color: var(--white); font-weight: 600; }
.content { padding: 8px 28px 40px; display: flex; flex-direction: column; gap: 18px; }
.hint { color: var(--dim); font-size: 13px; margin: 0; }

/* cards, forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card > .hint { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; align-items: start; }
.in { background: var(--field); border: 1px solid var(--fieldline); border-radius: 4px; color: var(--text); padding: 0 10px; min-height: 36px; width: 100%; }
textarea.in { padding: 8px 10px; min-height: 90px; }
.in:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 8px 20px; align-items: start; padding: 8px 0; }
.row > .lab { font-weight: 600; padding-top: 8px; text-align: right; }
.help { color: var(--dim); font-size: 12px; margin-top: 6px; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.grp { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin: 22px 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #2c2f38; color: var(--text); border: 0; border-radius: 4px; padding: 0 14px; min-height: 36px; cursor: pointer; }
.btn:hover { background: #363a44; color: var(--white); }
.btn.primary { background: var(--accent); color: #14161a; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: #5a2a26; color: #ffd6d1; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.pill { display: inline-flex; align-items: center; background: var(--chip); color: #c9ccd2; border-radius: 4px; padding: 2px 8px; font-size: 12px; }
.pill.anime { background: var(--anime); color: var(--white); }
.tag { display: inline-flex; border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 700; color: #14161a; }
.s-present { color: var(--ok); } .s-missing { color: var(--bad); } .s-review { color: var(--warn); } .s-locked { color: var(--accent); }
.s-disabled { color: var(--off); } .s-failed { color: var(--bad); } .s-deferred { color: var(--warn); } .s-searching, .s-queued { color: var(--teal); }
.bg-present { background: var(--ok); } .bg-missing, .bg-failed { background: var(--bad); } .bg-review, .bg-deferred { background: var(--warn); }
.bg-locked { background: var(--accent); } .bg-disabled { background: var(--off); color: var(--white); } .bg-searching, .bg-queued { background: var(--teal); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbtn { background: #2c2f38; color: var(--text); border: 0; border-radius: 16px; padding: 6px 14px; min-height: 32px; cursor: pointer; }
.chipbtn.on { background: var(--accent); color: #14161a; font-weight: 600; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-radius: 6px; padding: 12px 16px; }
.banner.warn { background: #3a2e1a; border: 1px solid #7a5a22; color: #f6dcae; }
.banner.ok { background: #1e3a2a; border: 1px solid #2f6b45; color: #b9ecc6; }
.banner.err { background: #3a1e1e; border: 1px solid #7a3530; color: #ffd6d1; }
.banner > div { flex: 1 1 300px; }

/* tables */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:hover td { background: #2a2d35; }
td.r, th.r { text-align: right; }
.pager { display: flex; justify-content: center; gap: 12px; align-items: center; padding: 12px; color: var(--dim); }

/* library grid */
.legend { display: flex; flex-wrap: wrap; gap: 18px; padding: 4px 28px 12px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.posters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 22px; padding: 0 28px 32px; }
.poster { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
.poster:hover { color: var(--white); }
.poster .img { aspect-ratio: 2 / 3; border-radius: 6px; background: #2d3039; border: 1px solid var(--fieldline); overflow: hidden; position: relative; display: flex; align-items: flex-end; }
.poster .img img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.poster .img span { padding: 12px; font-weight: 700; font-size: 15px; line-height: 1.25; color: var(--white); }
.bar { height: 4px; border-radius: 2px; background: var(--fieldline); overflow: hidden; }
.bar > div { height: 4px; background: var(--teal); }
.icons { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.icons .pct { margin-left: auto; color: var(--dim); font-size: 12px; font-weight: 400; }
.meta { color: var(--dim); font-size: 12px; }

/* detail */
.hero { display: flex; flex-wrap: wrap; gap: 28px; padding: 28px; background: var(--tool); border-bottom: 1px solid var(--line); }
.hero .img { flex: 0 0 180px; }
.hero h1 { margin: 0; font-size: 30px; font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 8px; }
.stats b { display: block; font-size: 22px; font-weight: 600; color: var(--white); }
.stats span { color: var(--dim); font-size: 12px; }
.asset h3 { margin: 0; font-size: 16px; font-weight: 600; }
.asset { display: flex; flex-direction: column; gap: 12px; }
.asset audio, .asset video { width: 100%; border-radius: 6px; background: #000; }
.asset.off { border-style: dashed; }

/* review */
.cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cand { background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; }
.cand .thumb { aspect-ratio: 16 / 9; background: #2d3039; position: relative; display: block; }
.cand .thumb img { width: 100%; height: 100%; object-fit: cover; }
.cand .dur { position: absolute; right: 8px; bottom: 8px; background: #000; color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 3px; }
.cand .score { position: absolute; left: 8px; top: 8px; }
.cand .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cand .why { color: var(--dim); font-size: 12px; }
.cand .acts { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }

/* stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.kpi { background: var(--card2); border-radius: 4px; padding: 16px 12px; text-align: center; }
.kpi b { display: block; font-size: 26px; font-weight: 400; color: var(--white); }
.kpi span { display: block; color: #c9ccd2; margin-top: 4px; }
.kpi small { display: block; color: var(--dim); font-size: 12px; margin-top: 4px; }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.sw { width: 22px; height: 10px; display: inline-block; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; border-bottom: 1px solid #4a4e58; padding: 0 4px; }
.bars > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bars span { font-size: 11px; color: var(--dim); }
.bars i { display: block; width: 100%; max-width: 34px; background: #5ad1ee; border-radius: 2px 2px 0 0; }

/* modal & login */
.modalbg { min-height: 100vh; background: #101114; display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px; }
.modal { width: 100%; max-width: 860px; background: var(--card); border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; border-bottom: 1px solid var(--line2); }
.modal header h1 { margin: 0; font-size: 20px; }
.modal .mbody { padding: 8px 32px 24px; }
.modal footer { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 24px; border-top: 1px solid var(--line2); background: var(--side); }
.login { min-height: 100vh; background: var(--bar); display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.login .box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 20px; }
.login form { background: var(--card); border: 1px solid var(--line2); border-radius: 8px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.login .in { min-height: 44px; }
.login h1 { margin: 0; font-size: 20px; font-weight: 600; }

#toast { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#toast div { background: #2c2f38; border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 4px; max-width: 360px; box-shadow: 0 4px 16px #0008; }
#toast div.err { border-color: var(--bad); }
.kv { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr); gap: 10px 16px; }
.kv .k { color: var(--dim); text-align: right; }
.loglines { font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.lv-ERROR { color: var(--bad); } .lv-WARN { color: var(--warn); } .lv-DEBUG { color: var(--dim); }

@media (max-width: 700px) {
  .row { grid-template-columns: 1fr; } .row > .lab { text-align: left; padding-top: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .content, .crumb { padding-left: 16px; padding-right: 16px; }
  .posters { padding: 0 16px 24px; }
}
