:root {
  --bg: #F4F6F9; --panel: #FFFFFF; --panel-2: #F8FAFC; --line: #E3E8EF; --text: #1B2533; --muted: #66758A;
  --navy: #1F3A5F; --accent: #2A7F8F; --accent-soft: #E3F1F3; --ok: #2E8B57; --warn: #D98E04; --bad: #C0392B;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px; --font: "Inter", "Segoe UI", system-ui, -apple-system, "Carlito", sans-serif;
}
[data-theme="dark"] {
  --bg: #0F1620; --panel: #16202C; --panel-2: #1B2734; --line: #273546; --text: #E4EAF2; --muted: #93A3B8;
  --navy: #8DB4E2; --accent: #4DB3C4; --accent-soft: #173842; --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
[data-theme="dark"] .side { background: #0B121B; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 6px 18px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #4DB3C4, #2A7F8F); display: grid; place-items: center; font-weight: 800; }
.brand b { display: block; font-size: 16px; letter-spacing: .2px; }
.brand small { opacity: .7; font-size: 11.5px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: rgba(255,255,255,.82); cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; font-size: 11.5px; opacity: .65; padding: 0 8px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 26px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 17px; margin: 0; font-weight: 700; }
.top .sub { color: var(--muted); font-size: 12.5px; }
.spacer { flex: 1; }
.content { padding: 22px 26px 60px; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.icon { padding: 5px 7px; }
.btn svg { width: 15px; height: 15px; }
select, input[type=text], input[type=number], input[type=date], input[type=password], textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
input[type=range] { accent-color: var(--accent); width: 100%; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .side-foot, .brand small { display: none; } .g2 { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 800; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.kpi .d { font-size: 12.5px; margin-top: 8px; font-weight: 600; }
.up { color: var(--ok); } .down { color: var(--bad); } .flat { color: var(--warn); }
.muted { color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.avatar { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: none; }
.avatar.lg { width: 42px; height: 42px; font-size: 15px; }
.bar { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar.thin { height: 5px; }
.status { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.s-todo { background: #EEF1F5; color: #4B5B70; } .s-doing { background: #E3F1F3; color: #1E6E7C; }
.s-blocked { background: #FCE8E6; color: #B03427; } .s-done { background: #E4F4EA; color: #237447; }
[data-theme="dark"] .s-todo { background: #26313F; color: #B9C6D6; } [data-theme="dark"] .s-doing { background: #173842; color: #7FD3E0; }
[data-theme="dark"] .s-blocked { background: #3A1E1C; color: #F3A39A; } [data-theme="dark"] .s-done { background: #173326; color: #8FDBAE; }

/* member card */
.member { display: flex; flex-direction: column; gap: 12px; }
.member-head { display: flex; gap: 12px; align-items: center; }
.member-head b { display: block; font-size: 15px; }
.member .now { background: var(--panel-2); border: 1px dashed var(--line); border-radius: 8px; padding: 9px 10px; font-size: 13px; }
.ring { width: 64px; height: 64px; flex: none; margin-left: auto; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.stats b { display: block; font-size: 16px; }
.stats span { font-size: 11px; color: var(--muted); }

/* lists */
.alerts { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow: auto; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border-left: 3px solid var(--warn); font-size: 13px; cursor: pointer; }
.alert.bad { border-left-color: var(--bad); } .alert.info { border-left-color: var(--accent); }
.feed { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; font-size: 13px; }
.feed li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.feed time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.theme-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; }

/* board */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; }
.col { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--accent); }
.col-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin: 2px 4px 10px; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; margin-bottom: 9px; cursor: pointer; box-shadow: var(--shadow); border-left: 4px solid var(--accent); }
.tcard:hover { border-color: var(--accent); }
.tcard .t { font-weight: 600; margin: 3px 0 7px; }
.tcard .meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-top: 7px; }
.tid { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.wait { font-size: 11.5px; color: var(--bad); font-weight: 600; margin-top: 6px; }

/* table */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--panel-2); padding: 9px 10px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.grp td { background: var(--panel-2); font-weight: 700; font-size: 12.5px; }
.tbl tbody tr:hover td { background: var(--accent-soft); }
.pct { display: grid; grid-template-columns: 1fr 40px; gap: 8px; align-items: center; min-width: 150px; }

/* gantt */
.gantt { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.gantt table { border-collapse: collapse; min-width: 100%; }
.gantt th, .gantt td { border-bottom: 1px solid var(--line); padding: 0; }
.gantt th.day { font-size: 11px; color: var(--muted); font-weight: 600; text-align: center; padding: 6px 0; min-width: 64px; border-left: 1px solid var(--line); }
.gantt th.day.today { color: var(--bad); }
.gantt td.name { position: sticky; left: 0; background: var(--panel); min-width: 270px; max-width: 270px; padding: 6px 10px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 2; border-right: 1px solid var(--line); cursor: pointer; }
.gantt td.lane { position: relative; height: 32px; }
.gantt tr.grp td { background: var(--panel-2); font-weight: 700; font-size: 12.5px; padding: 6px 10px; }
.gbar { position: absolute; top: 7px; height: 18px; border-radius: 5px; overflow: hidden; cursor: pointer; opacity: .95; }
.gbar .plan { position: absolute; inset: 0; opacity: .3; }
.gbar .done { position: absolute; top: 0; bottom: 0; left: 0; }
.gbar span { position: relative; font-size: 10.5px; color: #fff; font-weight: 700; padding: 0 6px; line-height: 18px; text-shadow: 0 0 2px rgba(0,0,0,.5); }
.gbar.late { outline: 2px solid var(--bad); outline-offset: 1px; }
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 1; }
.gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }

/* timesheet */
.ts td.h { text-align: center; font-variant-numeric: tabular-nums; }
.ts td.h.z { color: var(--muted); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(10, 18, 30, .45); display: flex; justify-content: flex-end; z-index: 20; }
.drawer { width: min(640px, 100%); height: 100%; background: var(--panel); overflow: auto; padding: 22px 24px; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
.drawer h2 { margin: 6px 0 4px; font-size: 20px; }
.drawer section { margin-top: 18px; }
.drawer section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.comment { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.comment b { font-size: 12.5px; }

/* timer pill */
.timer { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 12px; border-radius: 99px; background: #FCE8E6; color: #9E2B20; font-weight: 700; font-variant-numeric: tabular-nums; }
[data-theme="dark"] .timer { background: #3A1E1C; color: #F3A39A; }
.timer .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: p 1.2s infinite; }
@keyframes p { 50% { opacity: .25; } }

.login { max-width: 360px; margin: 14vh auto; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 30; box-shadow: var(--shadow); }
[data-theme="dark"] .toast { background: #2A7F8F; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
