:root {
  --brand:       #00e5a0;
  --brand-2:     #38bdf8;
  --brand-soft:  rgba(0,229,160,.12);
  --brand-line:  rgba(0,229,160,.28);
  --danger:      #ff4d8d;
  --warning:     #f59e0b;
  --success:     #10b981;
  --bg:          #0a0e14;
  --surface:     #141b26;
  --surface-2:   #1a2230;
  --surface-3:   #212b3b;
  --line:        #26303f;
  --text:        #eaf0f6;
  --muted:       #9aa8b9;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 8px 32px rgba(0,0,0,.4);
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --mono:        'JetBrains Mono', ui-monospace, monospace;
  --sidebar-w:   248px;
}
[data-theme="light"] {
  --bg: #f6f7f9; --surface: #fff; --surface-2: #f0f2f5; --surface-3: #e9ecf1;
  --line: #e2e6ec; --text: #0a0e14; --muted: #64748b;
  --shadow: 0 8px 24px rgba(15,23,42,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); }

/* ========== LOGIN ========== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, rgba(0,229,160,.08), transparent 40%),
              radial-gradient(circle at 80% 100%, rgba(56,189,248,.06), transparent 40%), var(--bg); }
.login-wrap { width: 100%; max-width: 420px; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 36px 32px; box-shadow: var(--shadow); }
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 28px; }
.login-brand-name { font-size: 18px; font-weight: 700; }
.login-brand-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 8px; }
.login-card input { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text); font: inherit; outline: none; transition: .15s; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-card .btn { margin-top: 20px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; margin-top: 10px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }

/* ========== LAYOUT ========== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px;
  border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.sidebar-brand img { width: 32px; height: 32px; }
.sidebar-brand-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.sidebar-brand-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.nav-group { margin-bottom: 4px; }
.nav-group-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  padding: 14px 10px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; font-weight: 500; font-size: 13.5px; transition: .12s; user-select: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.9; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; min-width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; }
.user-chip:hover { background: var(--surface-3); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,var(--brand),var(--brand-2));
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #04170f; font-size: 13px; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 24px;
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; }
.search-box { position: relative; }
.search-box input { padding: 9px 14px 9px 36px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font: inherit; width: 280px; outline: none; }
.search-box input:focus { border-color: var(--brand); }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .5; pointer-events: none; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 400px;
  overflow-y: auto; display: none; z-index: 100; }
.search-results.open { display: block; }
.search-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-item:last-child { border: 0; }
.search-item:hover { background: var(--surface-2); }
.search-item-title { font-weight: 600; font-size: 13px; }
.search-item-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.content { padding: 24px; flex: 1; }
.content-loading { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--muted); }

/* ========== BUTTONS ========== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font: inherit;
  font-weight: 600; font-size: 13px; cursor: pointer; transition: .15s; }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #04170f; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.full { width: 100%; justify-content: center; padding: 13px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ========== PANELS ========== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--line); gap: 14px; }
.panel-head h3 { font-size: 15px; }
.panel-head .muted { font-size: 12px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-body.p-0 { padding: 0; }

/* ========== CARDS / STATS ========== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; position: relative; overflow: hidden; }
.stat small { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  font-weight: 600; margin-bottom: 8px; }
.stat strong { font-size: 28px; font-weight: 700; letter-spacing: -.02em; display: block; }
.stat.warn strong { color: var(--warning); }
.stat.danger strong { color: var(--danger); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px,1fr)); }

/* ========== TABLE ========== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  background: var(--surface-2); }
.table tbody tr { cursor: pointer; transition: .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.table .empty { text-align: center; color: var(--muted); padding: 40px 20px; font-style: italic; }

/* ========== PILLS ========== */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.green { background: var(--brand-soft); color: var(--brand); }
.pill.red   { background: rgba(255,77,141,.14); color: var(--danger); }
.pill.amber { background: rgba(245,158,11,.14); color: var(--warning); }
.pill.blue  { background: rgba(56,189,248,.14); color: var(--brand-2); }
.pill.gray  { background: var(--surface-3); color: var(--muted); }

/* ========== MODAL ========== */
.modal-overlay { position: fixed; inset: 0; background: rgba(3,7,12,.72); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; z-index: 1000; padding: 40px 20px; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; width: 100%;
  max-width: 640px; box-shadow: var(--shadow); overflow: hidden; }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px;
  border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1;
  padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line);
  background: var(--surface-2); }

/* ========== FORM ========== */
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.formgrid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 10px 13px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font: inherit; outline: none; transition: .15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.field select { cursor: pointer; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ========== TOAST ========== */
.toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px;
  z-index: 2000; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); padding: 12px 18px; min-width: 260px; max-width: 380px; box-shadow: var(--shadow);
  animation: toastIn .22s ease-out; pointer-events: auto; }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ========== KANBAN ========== */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kanban-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; min-height: 400px; display: flex; flex-direction: column; }
.kanban-col.drag-over { border-color: var(--brand); background: var(--brand-soft); }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.kanban-col-title { font-weight: 700; font-size: 13px; }
.kanban-count { color: var(--muted); font-size: 12px; background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kanban-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; cursor: grab; transition: .15s; }
.kanban-card:hover { border-color: var(--brand-line); }
.kanban-card.dragging { opacity: .4; }
.kanban-card-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.kanban-card-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }

/* ========== DETAIL PAGE ========== */
.detail-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 24px; padding-bottom: 24px;
  border-bottom: 1px solid var(--line); }
.detail-avatar { width: 64px; height: 64px; border-radius: 14px;
  background: linear-gradient(135deg,var(--brand),var(--brand-2)); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 24px; color: #04170f; flex-shrink: 0; }
.detail-info h2 { font-size: 22px; margin-bottom: 6px; }
.detail-info .sub { color: var(--muted); font-size: 13.5px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.detail-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.detail-tab { padding: 12px 16px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; transition: .12s; }
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 20px; }
.kv dt { color: var(--muted); font-size: 12.5px; padding: 6px 0; }
.kv dd { margin: 0; padding: 6px 0; font-size: 13.5px; }

/* ========== TIMER ========== */
.timer-bar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface);
  border: 1px solid var(--brand-line); border-radius: 999px; padding: 10px 12px 10px 20px; display: flex;
  align-items: center; gap: 14px; box-shadow: var(--shadow); z-index: 900; }
.timer-bar.running { border-color: var(--brand); background: var(--brand-soft); }
.timer-label { font-size: 13px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-time { font-family: var(--mono); font-weight: 700; font-size: 16px; min-width: 76px; text-align: right; }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%); z-index: 100;
    transition: .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .formgrid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .search-box input { width: 100%; }
}