:root {
  --navy: #1f3a5f;
  --navy-2: #2b4c77;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e3e7ee;
  --text: #1d2433;
  --muted: #6b7486;
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --todo: #64748b;
  --prog: #2563eb;
  --rev: #a16207;
  --done: #15803d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.hidden { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #dbe5f3; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 17px; padding: 4px 8px 16px; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: #fff; color: var(--navy); display: grid; place-items: center; font-size: 16px; }
.side .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8ea5c4; padding: 14px 10px 4px; }
.nav { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; color: #dbe5f3; text-decoration: none; cursor: pointer; }
.nav:hover { background: rgba(255, 255, 255, .08); }
.nav.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.nav .count { background: rgba(255, 255, 255, .2); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.nav .count.alert { background: #f59e0b; color: #1d2433; }
.side .me { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding: 12px 8px 0; font-size: 13px; }
.side .me b { color: #fff; display: block; }
.side .me a { color: #9fc0ea; cursor: pointer; margin-right: 10px; font-size: 12px; }

.main { padding: 20px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 21px; margin: 0; margin-right: auto; }
.bell { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.bell .dot { position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 5px; }
.notif-panel { position: absolute; right: 28px; top: 62px; width: 340px; max-height: 420px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .15); z-index: 30; }
.notif-panel .n { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-panel .n:hover { background: var(--bg); }
.notif-panel .n.unread { background: #eff6ff; }
.notif-panel .n small { color: var(--muted); display: block; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #c5ccd8; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.warn { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.btn.wa { background: #e7f8ee; border-color: #86efac; color: #166534; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=tel], input[type=url], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
label.f { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; font-weight: 500; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }

/* board */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; align-items: start; }
.col { background: #eaeef4; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col h3 { margin: 2px 4px 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .04em; color: #3d4757; }
.col h3 .pill { margin-left: auto; }
.sdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.card { background: var(--card); border-radius: 8px; padding: 10px 12px; margin-bottom: 9px; box-shadow: var(--shadow); cursor: pointer; border-left: 4px solid var(--line); }
.card:hover { box-shadow: 0 4px 12px rgba(16, 24, 40, .12); }
.card .t { font-weight: 600; margin-bottom: 6px; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.card .people { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 18px 6px; font-size: 13px; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: #eef1f5; color: #475066; }
.pill.todo { background: #f1f5f9; color: var(--todo); }
.pill.in_progress { background: #dbeafe; color: var(--prog); }
.pill.in_review { background: #fef3c7; color: var(--rev); }
.pill.completed { background: #dcfce7; color: var(--done); }
.pill.p-urgent { background: #fee2e2; color: var(--red); }
.pill.p-high { background: #ffedd5; color: #c2410c; }
.pill.p-medium { background: #e0e7ff; color: #3730a3; }
.pill.p-low { background: #f1f5f9; color: #64748b; }
.pill.overdue { background: #fee2e2; color: var(--red); }
.pill.rework { background: #fce7f3; color: #9d174d; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--navy-2); color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; vertical-align: middle; }

/* panels & tables */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi.alert .v { color: var(--red); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #eef1f5; border-radius: 5px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 5px; }
.stackbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #eef1f5; }
.stackbar > i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* workload heatmap */
.heat td.cell { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; border: 2px solid #fff; border-radius: 6px; min-width: 78px; }
.heat .lo { background: #ecfdf5; color: #166534; }
.heat .ok { background: #bbf7d0; color: #14532d; }
.heat .hi { background: #fde68a; color: #78350f; }
.heat .over { background: #fca5a5; color: #7f1d1d; }
.heat .zero { background: #f8fafc; color: #94a3b8; }
.heat td.cell small { display: block; font-weight: 400; font-size: 11px; }

/* timeline */
.tl { overflow-x: auto; }
.tl-grid { position: relative; }
.tl-head { display: flex; position: sticky; top: 0; }
.tl-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); height: 34px; }
.tl-label { width: 260px; flex: none; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; cursor: pointer; }
.tl-track { position: relative; flex: none; height: 100%; }
.tl-day { position: absolute; top: 0; bottom: 0; border-left: 1px solid #f1f3f7; }
.tl-day.wk { border-left-color: #dfe4ec; }
.tl-day.today { border-left: 2px solid var(--red); z-index: 2; }
.tl-bar { position: absolute; top: 8px; height: 18px; border-radius: 5px; font-size: 11px; color: #fff; padding: 0 6px; line-height: 18px; white-space: nowrap; overflow: hidden; cursor: pointer; }
.tl-group { background: #f1f4f8; font-weight: 700; font-size: 12.5px; }

/* drawer */
#drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 40; }
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: #fff; z-index: 41; overflow-y: auto; box-shadow: -10px 0 30px rgba(0, 0, 0, .15); }
.dr-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.dr-head h2 { margin: 6px 0 0; font-size: 19px; }
.dr-body { padding: 16px 22px 40px; }
.dr-close { float: right; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.flow { display: flex; align-items: center; gap: 4px; margin: 12px 0 4px; font-size: 12px; }
.flow .st { padding: 4px 10px; border-radius: 14px; background: #eef1f5; color: var(--muted); }
.flow .st.cur { background: var(--navy); color: #fff; font-weight: 600; }
.flow .st.past { background: #dcfce7; color: var(--done); }
.flow .arr { color: #b6bdc9; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px solid var(--line); }
.actions .hint { width: 100%; font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.dr-sec { margin-top: 22px; }
.dr-sec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.desc { white-space: pre-wrap; background: #f8fafc; border-radius: 8px; padding: 10px 12px; }
.comment { padding: 9px 0; border-bottom: 1px solid var(--line); }
.comment .who { font-weight: 600; font-size: 13px; }
.comment .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.comment .txt { white-space: pre-wrap; margin-top: 2px; }
.hist { font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.check.done span { text-decoration: line-through; color: var(--muted); }

/* modal */
#modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: grid; place-items: center; padding: 20px; }
#modal { background: #fff; border-radius: 12px; width: min(620px, 100%); max-height: 92vh; overflow: auto; padding: 20px 22px; }
#modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0%, #2c5282 100%); padding: 20px; }
.auth-card { background: #fff; border-radius: 14px; padding: 28px 30px; width: min(400px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p { color: var(--muted); margin: 0 0 12px; }
.auth-card .btn { width: 100%; margin-top: 16px; padding: 10px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
#toast.bad { background: var(--red); }
.muted { color: var(--muted); }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav { display: flex; gap: 6px; overflow-x: auto; background: var(--navy); padding: 8px 10px; position: sticky; top: 0; z-index: 20; }
  .mobile-nav .nav { flex: none; padding: 6px 10px; font-size: 13px; }
  .main { padding: 14px 12px 40px; }
  .board { grid-template-columns: repeat(4, 80vw); overflow-x: auto; }
  .grid2 { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
  .notif-panel { right: 10px; left: 10px; width: auto; }
  .tl-label { width: 160px; }
}
