/* ============================================================
   Helm — Design System
   ============================================================ */
:root {
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --gap: 16px;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
  --transition: 160ms cubic-bezier(.4,0,.2,1);
}

/* ---- Dark theme (default) ---- */
[data-theme="dark"] {
  --bg: #0c0e14;
  --bg-elev: #14171f;
  --bg-elev-2: #1b1f29;
  --bg-hover: #232836;
  --border: #262b38;
  --border-soft: #1d2230;
  --text: #e8ebf2;
  --text-dim: #9aa3b5;
  --text-faint: #626b7e;
  --accent: #6d8bff;
  --accent-soft: #6d8bff22;
  --accent-2: #34d8a8;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}
/* ---- Light theme ---- */
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-elev-2: #f7f9fd;
  --bg-hover: #eef1f8;
  --border: #e2e7f0;
  --border-soft: #edf0f6;
  --text: #1a2030;
  --text-dim: #5a6478;
  --text-faint: #9aa3b5;
  --accent: #3b5bff;
  --accent-soft: #3b5bff15;
  --accent-2: #109e76;
  --shadow: 0 8px 30px rgba(40,50,90,.12);
}

/* Semantic / status colors */
:root {
  --crit: #ff5c72;
  --high: #ff9f43;
  --med:  #ffd166;
  --low:  #4fc1ff;
  --ok:   #34d8a8;
  --done: #6b7488;
  --income: #34d8a8;
  --expense: #ff5c72;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* login overlay */
.login-overlay { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 500; padding: 24px; }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px; padding: 30px; width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 11px 13px; border-radius: 8px; font-size: 14px; font-family: inherit; margin-bottom: 10px; }
.login-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-err { color: var(--crit); font-size: 12.5px; min-height: 18px; margin-bottom: 8px; }
.sync-badge { font-size: 11px; text-align: center; padding: 3px 0 6px; min-height: 14px; font-weight: 600; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================ Layout */
#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 4px 14px var(--accent-soft);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: none; background: transparent;
  color: var(--text-dim); font-size: 13.5px; font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  font-family: var(--font); transition: var(--transition);
}
.nav-item .ic { font-size: 15px; width: 18px; text-align: center; opacity: .85; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar-footer { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.ghost-btn {
  flex: 1; min-width: 64px; padding: 8px 6px; font-size: 11.5px; cursor: pointer;
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font); transition: var(--transition);
}
.ghost-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-faint); }

.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 16px; border-bottom: 1px solid var(--border-soft);
}
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.topbar .muted { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.topbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.content { padding: 24px 28px 60px; overflow-y: auto; flex: 1; }

/* ============================================================ Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: var(--font); transition: var(--transition); white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); border-color: transparent; background: transparent; }
.btn.danger:hover { background: #ff5c7218; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.icon { padding: 8px 10px; }

/* ============================================================ Cards / grid */
.grid { display: grid; gap: var(--gap); }
.cards-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cards-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card.pad-lg { padding: 22px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 14px; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 750; letter-spacing: -.5px; }
.stat .label { font-size: 12px; color: var(--text-faint); }
.stat .delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--crit); }

/* progress bars */
.bar { height: 7px; border-radius: 99px; background: var(--bg-hover); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s ease; }

/* badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge.crit { background: #ff5c7220; color: var(--crit); }
.badge.high { background: #ff9f4320; color: var(--high); }
.badge.med  { background: #ffd16622; color: var(--med); }
.badge.low  { background: #4fc1ff20; color: var(--low); }
.badge.ok   { background: #34d8a820; color: var(--ok); }
.badge.muted{ background: var(--bg-hover); color: var(--text-dim); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* ============================================================ Project cards */
.proj-card { cursor: pointer; transition: var(--transition); position: relative; overflow: hidden; }
.proj-card:hover { border-color: var(--text-faint); transform: translateY(-2px); box-shadow: var(--shadow); }
.proj-card .accent-line { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.proj-card h3 { font-size: 16px; margin-bottom: 5px; }
.proj-card .desc { font-size: 12.5px; color: var(--text-dim); min-height: 34px; }
.proj-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 12px; color: var(--text-faint); }

/* ============================================================ Tables / lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: var(--transition);
}
.row:hover { border-color: var(--text-faint); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; font-size: 13.5px; }
.row .sub { font-size: 11.5px; color: var(--text-faint); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================ Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 13.5px;
  width: 100%; transition: var(--transition);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }
.hint { font-size: 11px; color: var(--text-faint); }

/* color swatches */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.swatch.sel { border-color: var(--text); transform: scale(1.1); }

/* ============================================================ Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; padding: 24px;
}
.modal {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow);
  animation: pop .18s ease;
}
.modal.wide { max-width: 720px; }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px 0; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border-soft); margin-top: 4px; }
.x-btn { background: transparent; border: none; color: var(--text-faint); font-size: 22px; cursor: pointer; line-height: 1; }
.x-btn:hover { color: var(--text); }

/* ============================================================ Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.kcol { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.kcol.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.kcol-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); margin-bottom: 10px; padding: 0 4px; }
.kcol-head .count { background: var(--bg-hover); border-radius: 99px; padding: 1px 8px; font-size: 11px; }
.kcard {
  background: var(--bg-elev-2); border: 1px solid var(--border); border-left-width: 3px;
  border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 9px; cursor: grab;
  transition: var(--transition);
}
.kcard:hover { border-color: var(--text-faint); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .45; }
.kcard .kt { font-size: 13px; font-weight: 550; margin-bottom: 7px; }
.kcard .kmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--text-faint); }

/* ============================================================ Gantt */
.gantt { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.gantt svg { display: block; }

/* ============================================================ Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border-soft); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--bg-elev); padding: 9px; text-align: center; font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.cal-cell { background: var(--bg-elev); min-height: 104px; padding: 7px; cursor: pointer; transition: var(--transition); position: relative; }
.cal-cell:hover { background: var(--bg-hover); }
.cal-cell.other { opacity: .4; }
.cal-cell.today .cal-num { background: var(--accent); color: #fff; }
.cal-num { font-size: 12px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-ev { font-size: 10.5px; padding: 2px 6px; border-radius: 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }

/* ============================================================ Misc */
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.empty { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty .big { font-size: 40px; opacity: .5; margin-bottom: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 26px 0 14px; }
.section-head h2 { font-size: 16px; font-weight: 650; }
.tabs { display: flex; gap: 4px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.tab { padding: 7px 14px; border: none; background: transparent; color: var(--text-dim); border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 550; font-family: var(--font); transition: var(--transition); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg-hover); color: var(--text); }
.split { display: flex; gap: 8px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chiplist { display: flex; gap: 7px; flex-wrap: wrap; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 200; font-size: 13px; font-weight: 550;
  animation: pop .2s ease;
}
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* budget bars */
.bbar { display: flex; flex-direction: column; gap: 12px; }
.bbar-row { display: grid; grid-template-columns: 80px 1fr 90px; align-items: center; gap: 12px; }
.bbar-label { font-size: 12px; color: var(--text-dim); }
.bbar-track { height: 10px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; }
.bbar-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }
.bbar-val { font-size: 12.5px; font-weight: 650; text-align: right; }

/* objectives checklist */
.obj { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.obj:last-child { border-bottom: none; }
.obj input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.obj.done span { text-decoration: line-through; color: var(--text-faint); }

/* matrix */
.matrix { display: grid; grid-template-columns: auto 1fr 1fr; grid-template-rows: auto 1fr 1fr; gap: 8px; }
.matrix-cell { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; min-height: 110px; background: var(--bg-elev); }
.matrix-axis { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; }
.matrix-tag { font-size: 11px; font-weight: 700; margin-bottom: 8px; }
.mini-task { font-size: 12px; padding: 5px 8px; background: var(--bg-elev-2); border-radius: 6px; margin-bottom: 5px; border-left: 3px solid var(--accent); }

/* calendar month enhancements */
.cal-cell-head { display: flex; align-items: center; justify-content: space-between; }
.cal-cell.weekend { background: var(--bg-elev-2); }
.cal-budget { font-size: 10px; font-weight: 700; }
/* Sundays in red */
.cal-dow.sunday { color: var(--crit); }
.cal-cell.sunday { background: #ff5c720d; }
.cal-cell.sunday .cal-num { color: var(--crit); }
.cal-cell.sunday.today .cal-num { color: #fff; background: var(--crit); }
table.agenda tr.sunday .ag-dow,
table.agenda tr.sunday .ag-day,
table.agenda tr.sunday .ag-mon { color: var(--crit); }

/* category picker (Notion-style) */
.catpick { position: relative; display: inline-block; }
.catpick-trigger { background: transparent; border: 1px dashed var(--border); color: var(--text-dim); padding: 5px 9px; border-radius: 7px; cursor: pointer; font-family: var(--font); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.catpick-trigger:hover { border-color: var(--text-faint); background: var(--bg-hover); }
.catpick-trigger.compact { padding: 4px 8px; border-style: solid; }
.cat-chip { padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.catpick-dd { position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; width: 230px; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; }
.catpick-search { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 7px 9px; font-size: 13px; font-family: var(--font); margin-bottom: 6px; }
.catpick-search:focus { outline: none; border-color: var(--accent); }
.catpick-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.catpick-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.catpick-item:hover { background: var(--bg-hover); }
.catpick-item.create { color: var(--accent); font-weight: 600; }
.catpick-del { margin-left: auto; background: transparent; border: none; color: var(--text-faint); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.catpick-del:hover { color: var(--crit); }

/* vertical agenda table */
.agenda-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 230px); }
table.agenda { width: 100%; border-collapse: collapse; font-size: 13px; }
table.agenda th { position: sticky; top: 0; z-index: 10; background: var(--bg-elev-2); text-align: left; padding: 12px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.agenda td { padding: 7px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.agenda tr.weekend td { background: var(--bg-elev-2); }
table.agenda tr.today td { background: var(--accent-soft); }
table.agenda tr.vac td { background: #34d8a814; }
table.agenda tr.month-start td { border-top: 2px solid var(--accent); }
table.agenda tr.month-start .ag-mon { color: var(--accent); font-weight: 700; }
table.agenda tr:hover td { background: var(--bg-hover); }
.col-date { width: 78px; text-align: center !important; }
.ag-dow { font-size: 10px; text-transform: uppercase; color: var(--text-faint); font-weight: 700; letter-spacing: .5px; }
.ag-day { font-size: 20px; font-weight: 750; line-height: 1.1; }
.ag-mon { font-size: 10px; color: var(--text-faint); }
tr.today .ag-day { color: var(--accent); }
.col-act { min-width: 150px; }
.col-budget { min-width: 180px; }
.col-saldo { width: 110px; text-align: right !important; font-size: 14px; white-space: nowrap; }
/* single-line cell: chips + adder inline, wrap only if needed */
.ag-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ag-act { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; background: var(--bg-elev-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 12.5px; }
.ag-act:hover { border-color: var(--text-faint); }
.ag-act .truncate { max-width: 200px; }
.ag-flow { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 12px; }
.ag-flow:hover { border-color: var(--text-faint); }
.ag-add { background: transparent; border: none; color: var(--text-faint); font-size: 12px; cursor: pointer; padding: 3px 4px; font-family: var(--font); white-space: nowrap; }
.ag-add:hover { color: var(--accent); }
.ag-input { width: auto; flex: 1 1 130px; min-width: 120px; background: var(--bg); border: 1px solid var(--accent); color: var(--text); border-radius: 6px; padding: 5px 8px; font-size: 12.5px; font-family: var(--font); }
.ag-input:focus { outline: none; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kanban { grid-template-columns: 1fr 1fr; }
}
