:root {
  --bg: #0f1218;
  --bg-2: #151a22;
  --bg-3: #1c222c;
  --line: #262d3a;
  --line-2: #333c4d;
  --text: #e6eaf2;
  --text-2: #9aa5b8;
  --text-3: #6b768a;
  --accent: #6c8cff;
  --accent-2: #4fb0c6;
  --ok: #37b24d;
  --warn: #ff9f43;
  --danger: #e5484d;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
html[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-2: #ffffff;
  --bg-3: #eef1f7;
  --line: #dde3ee;
  --line-2: #c6cfe0;
  --text: #1a2030;
  --text-2: #5a6579;
  --text-3: #8b94a7;
  --shadow: 0 8px 30px rgba(20,30,60,.10);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 30% -10%, rgba(108,140,255,.18), transparent 60%), var(--bg); }
.login-card { width: 340px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-logo { font-size: 34px; }
.login-card h1 { font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); }
.login-error { background: rgba(229,72,77,.12); color: #ff8a8f; padding: 8px 10px; border-radius: 8px; font-size: 13px; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-size: 16px; }
.brand-mark { font-size: 20px; }
.brand-text b { color: var(--accent); font-weight: 700; }
#nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; overflow: auto; flex: 1; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; }
#nav a:hover { background: var(--bg-3); color: var(--text); }
#nav a.active { background: var(--accent); color: #fff; }
#nav .nav-ico { width: 18px; text-align: center; }
#nav .nav-sep { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 12px 4px; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; align-items: center; gap: 8px; }
.me { flex: 1; min-width: 0; font-size: 12px; line-height: 1.2; }
.me b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: var(--bg-2); position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 17px; flex: 1; }
.view { padding: 20px 24px 60px; }

/* ---------- controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 8px; padding: 8px 10px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
select { cursor: pointer; }
.btn { background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 14px;
  cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: rgba(229,72,77,.4); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.wide { width: 100%; justify-content: center; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px;
  cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- cards / tables ---------- */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { font-size: 14px; margin-bottom: 12px; }
.cards { display: grid; gap: 14px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .k { font-size: 12px; color: var(--text-2); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
  padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--bg-3); }
.table-wrap { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 70vh; }
.clickable { cursor: pointer; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: var(--bg-3); border: 1px solid var(--line-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff; flex: none; }

.bar { height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }

.empty { text-align: center; color: var(--text-3); padding: 36px 12px; }

/* ---------- dashboard ---------- */
.now-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.studio-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; border-left: 4px solid var(--accent); }
.studio-card.busy { background: linear-gradient(180deg, rgba(108,140,255,.08), transparent); }
.studio-card .st-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.studio-card .st-free { color: var(--text-3); font-size: 13px; padding: 10px 0 2px; }
.people-line { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- calendar ---------- */
.cal { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.cal table { min-width: 900px; }
.cal th.day { text-align: center; }
.cal th.day.today { color: var(--accent); }
.cal td.slot { vertical-align: top; padding: 6px; min-width: 130px; height: 74px; border-left: 1px solid var(--line); }
.cal td.studio-col { width: 150px; font-weight: 600; font-size: 13px; }
.cal td.slot:hover { background: var(--bg-3); cursor: copy; }
.chip { display: block; border-radius: 6px; padding: 5px 7px; margin-bottom: 4px; font-size: 11.5px;
  line-height: 1.3; cursor: pointer; border-left: 3px solid #fff3; background: var(--bg-3); }
.chip b { display: block; font-weight: 600; }
.chip .t { display: block; color: var(--text-2); font-size: 10.5px; }
.chip.cancelled { opacity: .45; text-decoration: line-through; }

/* ---------- project detail ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 9px 14px; cursor: pointer; color: var(--text-2);
  border-bottom: 2px solid transparent; font-weight: 500; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.stage-row { display: grid; grid-template-columns: 26px 1fr 150px 130px 120px 34px; gap: 10px; align-items: center;
  padding: 8px 4px; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .stage-row { grid-template-columns: 26px 1fr; } .stage-row > *:nth-child(n+3) { grid-column: 2; } }
.stage-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--bg-3); color: var(--text-2); }
.stage-num.done { background: var(--ok); color: #fff; }
.stage-num.prog { background: var(--accent); color: #fff; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,14,.6); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; width: min(720px, 100%);
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-head h3 { flex: 1; font-size: 15px; }
.modal-body { padding: 18px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- toast ---------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--bg-3); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); animation: in .2s ease; max-width: 340px; }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }

.chk { width: auto; }
.langs-box { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow: auto;
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px; }
.langs-box label { display: flex; align-items: center; gap: 5px; font-size: 12px; background: var(--bg-3);
  padding: 3px 8px; border-radius: 6px; cursor: pointer; }
.langs-box input { width: auto; }
.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-tabs button { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--text-2); }
.pill-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill-tabs.legend button { cursor: default; pointer-events: none; }
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav .nav-sep { display: none; }
  .view { padding: 14px; }
}
