:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #64707d;
  --line: #e2e6ea;
  --line-strong: #cfd5db;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f4f2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn-soft: #fff7e0;
  --nav: #16212c;
  --nav-ink: #c9d2db;
  --nav-active: #243241;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 10px; min-width: 200px; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.search { flex: 1; max-width: 520px; }
.search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); }
.topbar .spacer { flex: 1; }
.usermenu { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.usermenu strong { color: var(--ink); font-weight: 600; }

.sidenav { background: var(--nav); color: var(--nav-ink); padding: 14px 10px 40px; overflow-y: auto; position: sticky; top: 56px; height: calc(100vh - 56px); }
.sidenav h4 { margin: 18px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7f8c99; font-weight: 600; }
.sidenav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; color: var(--nav-ink); text-decoration: none; }
.sidenav a:hover { background: var(--nav-active); color: #fff; }
.sidenav a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.sidenav .dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); flex: none; }
.sidenav .count { margin-left: auto; background: #34495e; color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; line-height: 18px; }
.sidenav .count.hot { background: #d97706; }

main { padding: 20px 24px 60px; min-width: 0; }
.pagehead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pagehead h1 { font-size: 20px; margin: 0; }
.pagehead .sub { color: var(--muted); }
.pagehead .spacer { flex: 1; }

/* ---------- controls ---------- */
.btn { border: 1px solid var(--line-strong); background: var(--panel); padding: 7px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #aeb7c0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); border-color: #f1b8b3; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--accent); padding: 4px 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input:not([type]), select, textarea {
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%;
}
input:disabled, select:disabled, textarea:disabled { background: #f3f4f6; color: #4b5563; }
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
textarea.script { min-height: 140px; font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.req > span::after { content: " *"; color: var(--danger); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; background: #fff; }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: #0b4f49; font-weight: 600; }
.chip input { accent-color: var(--accent); }

/* ---------- status ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; border: 1px solid rgba(0,0,0,.15); font-size: 12px; font-weight: 600; white-space: nowrap; color: #1f2933; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.badge.spec { background: #ede9fe; color: #5b21b6; }
.badge.draft { background: #fef3c7; color: #92400e; }
.tick { color: var(--accent); font-weight: 700; }
.tick.no { color: #c3cad1; font-weight: 400; }

/* ---------- list ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar select, .pagehead select { width: auto; }
.spot-row1 { display: grid; gap: 12px; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 110px 140px; }
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; position: sticky; top: 0; }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr { cursor: pointer; }
table.list tbody tr { border-left: 5px solid transparent; }
table.list tbody tr:hover td { background: #f7fafc; }
table.list .client { font-weight: 600; }
table.list .title { color: var(--muted); font-size: 13px; }
table.list .nowrap { white-space: nowrap; }
table.list .overdue { color: var(--danger); font-weight: 600; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }

/* ---------- order ---------- */
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card > .hd h2, .card > .hd h3 { margin: 0; font-size: 15px; }
.card > .bd { padding: 16px; }
.card + .card { margin-top: 16px; }
.spot-card { border-left: 6px solid var(--line-strong); }
.spot-card .lineno { font-weight: 700; color: var(--muted); }
.section-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 18px 0 8px; display: flex; align-items: center; gap: 10px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.workflow { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.checkrow { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.timer { font-size: 12px; color: var(--muted); display: flex; gap: 10px; margin-top: 4px; }
.timer .over { color: var(--danger); font-weight: 600; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.files li:last-child { border-bottom: none; }
.files .kind { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; min-width: 92px; }
.files audio { height: 32px; max-width: 260px; }
.upload { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.upload select { width: auto; }
.blog-entry, .hist-entry { padding: 10px 0; border-bottom: 1px solid var(--line); }
.blog-entry:last-child, .hist-entry:last-child { border-bottom: none; }
.blog-entry .meta, .hist-entry .meta { font-size: 12px; color: var(--muted); }
.blog-entry .body { white-space: pre-wrap; margin-top: 3px; line-height: 1.45; }
.hist-entry { font-size: 13px; padding: 7px 0; }
.sticky { position: sticky; top: 76px; }
.scrollbox { max-height: 380px; overflow-y: auto; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; line-height: 1.45; }
.notice.warn { background: var(--warn-soft); border: 1px solid #f5d98b; }
.notice.error { background: var(--danger-soft); border: 1px solid #f1b8b3; color: #7a1a12; }
.notice.info { background: var(--accent-soft); border: 1px solid #b4dcd6; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 10px; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .hd { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal .bd { padding: 18px 20px; }
.modal .ft { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2933; color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); }
.login .brand { margin-bottom: 18px; font-size: 17px; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-color: var(--accent); font-weight: 600; }
table.admin td input, table.admin td select { padding: 5px 7px; }
table.admin tr { cursor: default; }
.inactive td { opacity: .55; }

@media (max-width: 1100px) { .order-layout { grid-template-columns: 1fr; } .sticky { position: static; } }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .topbar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; position: static; }
  .brand { min-width: 0; }
  .brand small, .usermenu .who, .usermenu [data-action=change-password] { display: none; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .sidenav { position: static; height: auto; display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px; padding: 8px; }
  .sidenav h4, .sidenav .nav-status { display: none; }
  .sidenav a { white-space: nowrap; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4, .spot-row1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main { padding: 16px 12px 60px; }
  .files audio { max-width: 100%; }
}
