:root {
  --bg: #F3F5F2; --card: #FFFFFF; --surface-2: #EEF2EE; --border: #DFE5E0;
  --text: #142320; --text-dim: #5D6E69; --accent: #0E7A65; --accent-hover: #0B6553; --accent-soft: #D8EFE8;
  --green: #16865B; --green-bg: #DDF2E6; --yellow: #B7791F; --yellow-bg: #FBEFD6; --red: #C2413A; --red-bg: #F9E0DD;
  --blue: #4C5BD4; --blue-bg: #E3E6FB;
  --f-display: "Unbounded", "Manrope", system-ui, sans-serif;
  --f-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1412; --card: #141D1A; --surface-2: #1A2522; --border: #25332F;
    --text: #E6EEEB; --text-dim: #8C9E98; --accent: #3CC4A4; --accent-hover: #5AD3B7; --accent-soft: #163A31;
    --green: #4CC98D; --green-bg: #163327; --yellow: #E3AA4E; --yellow-bg: #3A2D16; --red: #EE7A70; --red-bg: #3D1F1C;
    --blue: #8C97F2; --blue-bg: #22264A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1412; --card: #141D1A; --surface-2: #1A2522; --border: #25332F;
  --text: #E6EEEB; --text-dim: #8C9E98; --accent: #3CC4A4; --accent-hover: #5AD3B7; --accent-soft: #163A31;
  --green: #4CC98D; --green-bg: #163327; --yellow: #E3AA4E; --yellow-bg: #3A2D16; --red: #EE7A70; --red-bg: #3D1F1C;
  --blue: #8C97F2; --blue-bg: #22264A;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--f-body); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
a { color: var(--accent); }
.hidden { display: none !important; }
h1 { font-family: var(--f-display); font-weight: 600; font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

.btn { border: 1px solid var(--border); background: var(--card); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border: 2px solid var(--text-dim); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 auto !important; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: block; font-size: 12px; color: var(--text-dim); font-weight: 600; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); font-weight: 400; font-size: 14px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 600; font-size: 16px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: inline-block; position: relative; }
.logo::after { content: ""; position: absolute; inset: 7px; border: 2px solid #fff; border-radius: 50%; border-right-color: transparent; }
.err { color: var(--red); min-height: 18px; font-size: 13px; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.side { background: var(--card); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
#nav { display: grid; gap: 2px; }
#nav a { padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; font-weight: 600; display: flex; justify-content: space-between; }
#nav a:hover { background: var(--surface-2); }
#nav a.on { background: var(--accent-soft); color: var(--accent); }
.cnt { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.cnt:empty { display: none; }
.me { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); padding: 0 6px; }
main { padding: 22px 24px 60px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* board */
.today { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.today .chip { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.today .chip b { font-size: 16px; margin-right: 4px; }
.today .chip.warn { border-color: var(--yellow); background: var(--yellow-bg); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--surface-2); border-radius: 12px; padding: 10px; min-height: 200px; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 4px; }
.col-hint { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; min-height: 32px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card .t { font-weight: 700; margin: 2px 0 6px; }
.card .meta { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 7px; background: var(--surface-2); color: var(--text-dim); }
.badge.ai { background: var(--blue-bg); color: var(--blue); }
.badge.human { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--yellow-bg); color: var(--yellow); }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.ok { background: var(--green-bg); color: var(--green); }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(760px, 100%); background: var(--bg); overflow-y: auto; padding: 20px 22px 60px; box-shadow: -8px 0 30px rgba(0,0,0,.15); }
.stagebar { display: flex; gap: 4px; margin: 10px 0 12px; flex-wrap: wrap; }
.stagebar span { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-dim); font-weight: 600; }
.stagebar span.done { background: var(--accent-soft); color: var(--accent); }
.stagebar span.cur { background: var(--accent); color: #fff; }
.todo { background: var(--yellow-bg); border: 1px solid var(--yellow); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.todo b { display: block; color: var(--yellow); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.todo.done { background: var(--green-bg); border-color: var(--green); }
.todo.done b { color: var(--green); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.md { white-space: pre-wrap; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 14px; }
.script { min-height: 320px; font-size: 14px; line-height: 1.5; }
.files { display: grid; gap: 6px; }
.file { display: flex; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.file .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
video { width: 100%; max-height: 520px; background: #000; border-radius: 10px; }
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 18px; text-align: center; color: var(--text-dim); cursor: pointer; background: var(--card); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 8px 12px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--accent); color: #fff; }
.hist { font-size: 12px; color: var(--text-dim); display: grid; gap: 2px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--text-dim); background: var(--surface-2); font-weight: 700; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--border); background: var(--card); border-radius: 20px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.stars { display: inline-flex; gap: 1px; }
.stars button { border: 0; background: none; cursor: pointer; font-size: 17px; padding: 0 1px; color: var(--border); }
.stars button.on { color: var(--yellow); }
.refurl { word-break: break-all; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.kpi .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--text-dim); }
.idea { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.idea .t { font-weight: 800; font-size: 15px; margin: 4px 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.err { background: var(--red); color: #fff; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 10px; }
  #nav { display: flex; overflow-x: auto; gap: 4px; width: 100%; }
  #nav a { white-space: nowrap; }
  .me { margin: 0 0 0 auto; }
  main { padding: 16px 16px 60px; }
  .grid2 { grid-template-columns: 1fr; }
  .drawer-panel { padding: 16px; }
}
.row > select, .row > input:not([type=checkbox]) { width: auto; }
.head .row select { min-width: 140px; }
