/* KIN Work — blue · white · purple · soft navy */
:root {
  --navy: #1f2a56;
  --navy-2: #2b3a73;
  --navy-soft: #e8ecf8;
  --blue: #3b6cf6;
  --blue-2: #5b8cff;
  --blue-soft: #eaf0ff;
  --purple: #7246d8;
  --purple-2: #9a6cf0;
  --purple-soft: #f1ebff;
  --white: #ffffff;
  --bg: #f4f6fd;
  --line: #e2e7f5;
  --text: #1b2347;
  --muted: #6b7395;
  --green: #12a979;
  --green-soft: #e3f7ef;
  --amber: #e69a14;
  --amber-soft: #fff4dd;
  --red: #e2475b;
  --red-soft: #fde8eb;
  --teal: #0ea5c6;
  --grad: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
  --grad-side: linear-gradient(180deg, #1f2a56 0%, #2a2f6e 55%, #3b2f7e 100%);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 86, .05), 0 6px 20px rgba(31, 42, 86, .06);
  --shadow-lg: 0 20px 60px rgba(31, 42, 86, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
a { color: var(--blue); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--white); color: var(--text); padding: 9px 16px; border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: #c9d2ee; background: #fafbff; }
.btn-primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(91, 76, 230, .28); }
.btn-primary:hover { filter: brightness(1.06); background: var(--grad); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: #f6c4cb; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: var(--white); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--purple); border-color: #d6ccf7; }
.icon-btn.ghost-light { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #cdd3f4; }
.icon-btn.ghost-light:hover { background: rgba(255,255,255,.16); color: #fff; }

label { display: block; font-weight: 600; font-size: 13px; color: var(--navy); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-weight: 500;
  color: var(--text); background: var(--white); border: 1px solid var(--line); border-radius: 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 4px rgba(59,108,246,.12); }
input[type=color] { padding: 4px; height: 42px; }
input[type=range] { padding: 0; accent-color: var(--purple); }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0; }

/* ---------- login ---------- */
.login-wrap { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-art { position: relative; overflow: hidden; background: var(--grad-side); color: #fff; display: grid; place-items: center; padding: 48px; }
.login-art-inner { position: relative; z-index: 2; max-width: 420px; }
.login-logo { width: 120px; height: 120px; object-fit: contain; background: #fff; border-radius: 50%; padding: 8px; box-shadow: 0 16px 40px rgba(0,0,0,.25); }
.login-art h1 { font-size: 40px; margin: 28px 0 8px; font-weight: 800; }
.login-art .owner-line { margin: 0 0 6px; color: #fff; font-size: 17px; }
.login-art p { color: #cfd5f7; font-size: 16px; margin: 0 0 24px; }
.login-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.login-points li { padding-left: 30px; position: relative; color: #e6e9fb; }
.login-points li::before { content: ''; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 6px; background: linear-gradient(135deg, var(--blue-2), var(--purple-2)); }
.blob { position: absolute; border-radius: 50%; filter: blur(10px); opacity: .55; }
.b1 { width: 380px; height: 380px; background: radial-gradient(circle, #5b8cff 0%, transparent 70%); top: -80px; right: -100px; }
.b2 { width: 320px; height: 320px; background: radial-gradient(circle, #9a6cf0 0%, transparent 70%); bottom: -60px; left: -60px; }
.b3 { width: 180px; height: 180px; background: radial-gradient(circle, #8fd3ff 0%, transparent 70%); bottom: 30%; right: 12%; opacity: .35; }
.login-form-side { display: grid; place-items: center; padding: 32px; background: var(--white); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.login-card h2 { font-size: 26px; font-weight: 800; }
.login-card .muted { margin: -8px 0 8px; }
.login-logo-sm { display: none; width: 72px; height: 72px; object-fit: contain; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex: none; background: var(--grad-side); color: #cdd3f4; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.brand img { width: 46px; height: 46px; border-radius: 50%; background: #fff; padding: 3px; object-fit: contain; }
.brand strong { display: block; color: #fff; font-size: 16px; font-weight: 800; }
.brand span { font-size: 11.5px; color: #aab3e6; }
#nav { display: grid; gap: 4px; flex: 1; align-content: start; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #c3cbf1;
  text-decoration: none; font-weight: 600; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--blue-2); }
.nav-item .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; border-radius: 20px; padding: 1px 8px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8690c7; padding: 14px 12px 4px; font-weight: 700; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 6px 0; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip strong { display: block; color: #fff; font-size: 13px; }
.user-chip span { font-size: 12px; color: #9aa3d9; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--blue-2), var(--purple-2)); color: #fff; display: grid; place-items: center; font-weight: 800; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 18px 28px; background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 21px; font-weight: 800; color: var(--navy); }
.topbar p { margin: 0; font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; display: grid; gap: 20px; align-content: start; }

/* ---------- cards ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; font-weight: 700; color: var(--navy); }
.grid { display: grid; gap: 20px; }
.g-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-2 { grid-template-columns: 2fr 1fr; }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-half { grid-template-columns: 1fr 1fr; }

.hero {
  background: var(--grad); color: #fff; border-radius: 18px; padding: 24px 28px; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; box-shadow: 0 14px 34px rgba(91, 76, 230, .25);
}
.hero h2 { font-size: 22px; font-weight: 800; }
.hero p { margin: 4px 0 0; color: #e3e6ff; }
.hero::after { content: ''; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.1); }
.hero::before { content: ''; position: absolute; right: 120px; bottom: -110px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero .btn { position: relative; z-index: 1; background: #fff; color: var(--purple); border: 0; }

.kpi { display: flex; gap: 14px; align-items: center; padding: 18px; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-icon svg { width: 22px; height: 22px; }
.kpi .val { font-size: 26px; font-weight: 800; line-height: 1.1; color: var(--navy); }
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-purple { background: var(--purple-soft); color: var(--purple); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-red { background: var(--red-soft); color: var(--red); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-navy { background: var(--navy-soft); color: var(--navy-2); }
.tone-teal { background: #e0f6fb; color: var(--teal); }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 220px; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-todo { background: var(--navy-soft); color: var(--navy-2); }
.s-in_progress { background: var(--blue-soft); color: var(--blue); }
.s-review { background: var(--purple-soft); color: var(--purple); }
.s-on_hold { background: var(--amber-soft); color: #b9770a; }
.s-done { background: var(--green-soft); color: var(--green); }
.p-low { background: #eef2f7; color: #64748b; }
.p-medium { background: var(--blue-soft); color: var(--blue); }
.p-high { background: var(--amber-soft); color: #b9770a; }
.p-urgent { background: var(--red-soft); color: var(--red); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------- lists ---------- */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover .li-title { color: var(--purple); }
.li-title { font-weight: 600; color: var(--text); }
.li-sub { font-size: 12.5px; color: var(--muted); }
.date-chip { width: 46px; flex: none; text-align: center; border-radius: 10px; padding: 5px 0; background: var(--blue-soft); color: var(--blue); line-height: 1.1; }
.date-chip b { display: block; font-size: 17px; }
.date-chip span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; }
.date-chip.late { background: var(--red-soft); color: var(--red); }
.act { display: flex; gap: 12px; padding: 9px 0; }
.act-dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.act-dot svg { width: 15px; height: 15px; }

.progress { height: 8px; background: #edf0f9; border-radius: 10px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 10px; background: var(--grad); }
.proj-row { display: grid; gap: 6px; padding: 9px 0; }
.proj-row .top { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; }

/* ---------- table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar input, .toolbar select { margin: 0; width: auto; min-width: 150px; padding: 9px 12px; }
.toolbar .search { flex: 1; min-width: 220px; position: relative; }
.toolbar .search input { width: 100%; padding-left: 38px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.seg { display: inline-flex; background: var(--navy-soft); padding: 3px; border-radius: 10px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: #fff; color: var(--purple); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 20px; background: #f8f9fe; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: #f8f7ff; }
tbody tr:last-child td { border-bottom: 0; }
td .li-title { display: block; }
.mini-progress { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.mini-progress .progress { flex: 1; height: 6px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: #c3c9e6; margin-bottom: 8px; }
.late-text { color: var(--red); font-weight: 700; }

/* ---------- kanban ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.col { background: #eef1fb; border-radius: var(--radius); padding: 12px; min-height: 300px; display: flex; flex-direction: column; gap: 10px; transition: background .15s; }
.col.drag-over { background: var(--purple-soft); outline: 2px dashed var(--purple-2); }
.col-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 13px; padding: 2px 4px; }
.col-head .count { background: #fff; border-radius: 20px; padding: 0 9px; font-size: 12px; color: var(--muted); }
.kcard { background: #fff; border-radius: 12px; padding: 12px; border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(31,42,86,.05); cursor: grab; display: grid; gap: 8px; border-left: 4px solid var(--blue); }
.kcard:hover { box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; }
.kcard .k-title { font-weight: 700; font-size: 13.5px; }
.kcard .k-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- projects ---------- */
.proj-card { display: grid; gap: 12px; position: relative; overflow: hidden; }
.proj-card::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: var(--c, var(--blue)); }
.proj-card h3 { font-size: 16px; }
.proj-stats { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); }
.proj-stats b { color: var(--navy); font-size: 15px; display: block; }

/* ---------- modal & drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(23, 28, 64, .45); backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { background: #fff; width: 100%; max-width: 620px; border-radius: 18px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .18s ease-out; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; color: var(--navy); }
.modal-body { padding: 20px 22px; overflow-y: auto; display: grid; gap: 14px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal-foot .left { margin-right: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.overlay.right { place-items: stretch end; padding: 0; }
.drawer { background: #fff; width: min(560px, 100vw); height: 100vh; display: flex; flex-direction: column; animation: slide .2s ease-out; box-shadow: var(--shadow-lg); }
.drawer .modal-body { flex: 1; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }
.desc { white-space: pre-wrap; background: #f8f9fe; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13.5px; }
.section-title { font-size: 13px; font-weight: 800; color: var(--navy); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }
.log-form { display: grid; grid-template-columns: 130px 80px 1fr auto; gap: 8px; align-items: end; }
.log-form input { margin: 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: grid; gap: 10px; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; display: flex; gap: 10px; align-items: center; animation: pop .2s; border-left: 4px solid var(--blue-2); }
.toast.err { border-left-color: var(--red); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .g-kpi { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) { .g-2, .g-3, .g-half { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-logo-sm { display: block; }
  .sidebar { position: fixed; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-grid; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 14px 16px; }
  .g-kpi { grid-template-columns: repeat(2, 1fr); }
  .row2, .row3, .log-form { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
  .topbar-actions .btn span { display: none; }
}


/* ---------- notes ---------- */
.notes-grid { columns: 4 240px; column-gap: 16px; }
.notes-grid.compact { columns: 4 200px; }
.note-card {
  break-inside: avoid; margin-bottom: 16px; border: 1px solid var(--line); border-top: 4px solid var(--line);
  border-radius: 14px; padding: 14px 16px; cursor: pointer; position: relative; box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s; display: grid; gap: 8px;
}
.note-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(31,42,86,.12); }
.note-title { font-weight: 800; color: var(--navy); padding-right: 22px; }
.note-card > * { min-width: 0; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; color: #2c3560; max-height: 260px; overflow: hidden; }
.compact .note-body { max-height: 110px; }
.note-meta > span:last-child { white-space: nowrap; }
.note-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
.note-meta .tag { font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-meta .tag svg { width: 13px; height: 13px; }
.note-pin { position: absolute; top: 12px; right: 12px; color: var(--purple); }
.note-pin svg { width: 16px; height: 16px; }
.note-title-input { font-size: 18px; font-weight: 800; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 6px 2px; margin: 0; box-shadow: none !important; }
.note-content-input { min-height: 260px; border: 0; padding: 4px 2px; margin: 0; box-shadow: none !important; line-height: 1.6; font-family: inherit; }
.note-opts { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }
.color-dots { display: flex; gap: 8px; }
.cdot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid; cursor: pointer; padding: 0; }
.cdot.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--navy); }
.card-head h3 svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--purple); }
.section-title svg { width: 14px; height: 14px; vertical-align: -2px; }
.li-title.link { cursor: pointer; }
.li-title.link:hover { color: var(--purple); }

/* ---------- mobile nav ---------- */
.bottom-nav, .side-backdrop { display: none; }

@media (max-width: 860px) {
  input, select, textarea { font-size: 16px; } /* prevents iOS auto-zoom */
  .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(23,28,64,.45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar.open ~ .side-backdrop, .sidebar.open + .main + .side-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: calc(12px + env(safe-area-inset-top)); flex-wrap: wrap; }
  .topbar h1 { font-size: 18px; }
  .topbar-actions { margin-left: auto; justify-content: flex-end; flex-wrap: wrap; }
  #new-task-btn, #new-note { display: none; }
  .topbar > div:nth-child(2) { flex: 1 1 55%; min-width: 0; }
  .g-kpi.g-kpi4 { grid-template-columns: repeat(2, 1fr) !important; }
  .topbar-actions:empty { display: none; }
  .topbar-actions input[type=month] { flex: 1; }
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); gap: 14px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px -16px; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(31,42,86,.08);
  }
  .bottom-nav a, .bottom-nav button:not(.bn-add) {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted);
    text-decoration: none; font: inherit; font-size: 11px; font-weight: 700; background: none; border: 0; position: relative; cursor: pointer;
  }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .active { color: var(--purple); }
  .bn-dot { position: absolute; top: 4px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }
  .bn-add {
    justify-self: center; width: 54px; height: 54px; margin-top: -24px; border-radius: 18px; border: 4px solid #fff;
    background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(91,76,230,.4); cursor: pointer;
  }
  .bn-add svg { width: 24px; height: 24px; }
  .menu-btn { display: none !important; }

  /* modals become bottom sheets / full screen */
  .overlay { padding: 0; place-items: end stretch; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; animation: sheet .22s ease-out; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; justify-content: center; }
  .modal-foot .left { flex: 0 0 auto; }
  .drawer { width: 100vw; padding-top: env(safe-area-inset-top); }
  .kv { grid-template-columns: 105px 1fr; }

  /* responsive tables -> cards */
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { padding: 12px 16px; border-bottom: 1px solid var(--line); position: relative; }
  table.rtable tr:last-child { border-bottom: 0; }
  table.rtable td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
  table.rtable td[data-label]::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: 12px; flex: none; }
  table.rtable td.td-main { display: block; padding-bottom: 6px; padding-right: 40px; font-size: 14px; }
  table.rtable td.td-act { position: absolute; top: 8px; right: 12px; width: auto; padding: 0; }
  table.rtable td.hide-sm { display: none; }
  table.rtable .mini-progress { min-width: 0; width: 55%; }
  .notes-grid, .notes-grid.compact { columns: 2 150px; column-gap: 12px; }
  .note-card { margin-bottom: 12px; padding: 12px 14px; }
  .toolbar select { flex: 1; min-width: 0; }
  .toolbar .search { min-width: 100%; }
  .toolbar label { flex: 1; }
  .toolbar label input { flex: 1; min-width: 0; }
  .toolbar .seg { width: 100%; }
  .toolbar .seg button { flex: 1; justify-content: center; }
  .board { grid-template-columns: repeat(5, 82vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  #toast-root { bottom: calc(90px + env(safe-area-inset-bottom)); left: 16px; right: 16px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 420px) {
  .g-kpi { gap: 10px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-icon { width: 38px; height: 38px; }
  .kpi .val { font-size: 21px; }
  .hero { padding: 18px; }
  .hero h2 { font-size: 18px; }
}
@media print { .bottom-nav, .side-backdrop { display: none !important; } }

/* ---------- print (reports) ---------- */
@media print {
  .sidebar, .topbar-actions, .no-print, .menu-btn { display: none !important; }
  body, .content { background: #fff; padding: 0; }
  .topbar { position: static; border: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
