/* Structo Mobile — dark theme, mobile-first */
:root, [data-theme="structo"] {
  --bg: #0D0D12;
  --surface: #111119;
  --card: #17171F;
  --card-2: #1F1F2A;
  --input: #20202B;
  --border: #2A2A38;
  --text: #F2F2F7;
  --text-dim: #9A9AA8;
  --accent: #F5C518;
  --accent-ink: #0D0D12;
  --green: #4CAF50;
  --red: #F44336;
  --amber: #FF9800;
  --topbar-h: 56px;
}

/* Neutral dark */
[data-theme="dark"] {
  --bg: #121214;
  --surface: #1A1A1E;
  --card: #1C1C20;
  --card-2: #27272C;
  --input: #1C1C20;
  --border: #34343A;
  --text: #F2F2F7;
  --text-dim: #9A9AA8;
}

/* Light */
[data-theme="light"] {
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --card: #FFFFFF;
  --card-2: #ECECF1;
  --input: #FFFFFF;
  --border: #D6D6DE;
  --text: #16161A;
  --text-dim: #6B6B76;
  --accent: #C99700;
  --accent-ink: #1A1500;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  overscroll-behavior-y: contain;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px; width: 100%;
}
.hidden { display: none !important; }

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding-left: 12px; padding-right: 12px; z-index: 40;
}
.topbar .icon-btn { background: transparent; border: 0; color: var(--text); font-size: 22px; padding: 8px; border-radius: 8px; }
.topbar .title { font-weight: 700; font-size: 17px; }
.topbar .logo { color: var(--accent); font-weight: 800; font-size: 20px; }
.topbar .spacer { flex: 1; }
.project-pick { max-width: 46%; background: var(--input); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px; font-size: 13px; }

/* ── Drawer (slide-in sidebar) ─────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 78%; max-width: 320px; z-index: 60;
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-105%); transition: transform .22s ease;
  padding-top: env(safe-area-inset-top); display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer .brand { padding: 20px 18px 14px; font-size: 22px; font-weight: 800; }
.drawer .brand span { color: var(--accent); }
.drawer nav { flex: 1; padding: 6px; }
.drawer nav a { display: flex; align-items: center; gap: 12px; padding: 14px 14px; color: var(--text); text-decoration: none; border-radius: 10px; font-weight: 600; }
.drawer nav a .ico { width: 22px; display: inline-flex; align-items: center; justify-content: center; opacity: .9; }
.drawer nav a .ico svg { width: 20px; height: 20px; }
.drawer nav a.active { background: var(--card-2); color: var(--accent); }
.drawer .foot { padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.drawer .foot .who { color: var(--text-dim); font-size: 12px; margin-bottom: 10px; word-break: break-all; }
.theme-row { display: flex; gap: 6px; margin-bottom: 12px; }
.theme-btn { flex: 1; padding: 8px 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--card-2); color: var(--text); font-size: 12px; }
.theme-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.lang-select { flex: 1.4; padding: 8px 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--card-2); color: var(--text); font-size: 12px; }

/* Timeline */
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tl-chip { font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-2); color: var(--text); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tl-chip.off { opacity: .4; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.tl-track { position: relative; height: 14px; background: var(--card-2); border-radius: 5px; margin-top: 10px; overflow: visible; }
.tl-bar { position: absolute; top: 0; bottom: 0; border-radius: 5px; min-width: 6px; overflow: hidden; }
.tl-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 5px 0 0 5px; }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.06); }
.tl-today { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #F44336; border-radius: 1px; z-index: 3; }
.tl-milestone { position: absolute; top: 50%; width: 11px; height: 11px; transform: translate(-50%,-50%) rotate(45deg); border-radius: 2px; z-index: 2; }

/* Summary + ruler */
.tl-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tl-sum { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--card-2); }
.tl-sum.ontrack { color: #4A9EFF; }
.tl-sum.overdue { color: #F44336; }
.tl-sum.done { color: #4CAF50; }
.tl-rulercard { padding-top: 6px; padding-bottom: 6px; margin-bottom: 10px; }
.tl-ruler { position: relative; height: 16px; }
.tl-tick { position: absolute; top: 0; transform: translateX(-50%); font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.tl-tick-today { color: #F44336; font-weight: 700; }

/* ── Main view ─────────────────────────────────────────────── */
main {
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 12px) 14px calc(90px + env(safe-area-inset-bottom));
}
.view-title { font-size: 22px; font-weight: 800; margin: 4px 0 14px; }
.muted { color: var(--text-dim); }
.center-msg { text-align: center; color: var(--text-dim); padding: 40px 16px; }

/* ── Cards / lists ─────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.row .ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amount { font-weight: 700; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.pill.green { background: rgba(76,175,80,.18); color: var(--green); }
.pill.amber { background: rgba(255,152,0,.18); color: var(--amber); }
.pill.red { background: rgba(244,67,54,.18); color: var(--red); }
.pill.dim { background: var(--card-2); color: var(--text-dim); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700; font-size: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.danger { background: rgba(244,67,54,.15); color: var(--red); }
.btn.block { width: 100%; }
.fab { position: fixed; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); border: 0; font-size: 28px; box-shadow: 0 6px 18px rgba(0,0,0,.4); z-index: 30; }

/* ── Search ────────────────────────────────────────────────── */
.search { margin-bottom: 12px; }

/* ── Login ─────────────────────────────────────────────────── */
.login { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: flex; flex-direction: column; justify-content: center; padding: 28px; }
.login .logo { font-size: 40px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.login .logo span { color: var(--accent); }
.login .sub { text-align: center; color: var(--text-dim); margin-bottom: 28px; }
.login .field { margin-bottom: 12px; }
.login .err { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 2px; }
.forgot-row { text-align: right; margin: 2px 2px 0; }
.forgot-row a { color: var(--text-dim); font-size: 13px; text-decoration: none; }
.forgot-row a:hover { color: var(--accent); }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 46px; }
.pwd-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: var(--text-dim); padding: 8px; line-height: 0; }
.pwd-toggle svg { display: block; }
.pwd-toggle.on { color: var(--accent); }
.login .or { text-align: center; color: var(--text-dim); font-size: 13px; margin: 18px 0 10px; }
.auth-toggle { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 14px; }
.auth-toggle a { color: var(--accent); text-decoration: none; font-weight: 600; }
.oauth-btn { margin-top: 10px; }

/* ── Sheet (modal form) ────────────────────────────────────── */
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 80; display: flex; align-items: flex-end; }
.sheet { background: var(--card); width: 100%; max-height: 92%; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); }
/* Sticky header so the ✕ stays reachable even when the card is scrolled. */
.sheet-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); margin: -18px -16px 12px; padding: 14px 16px 10px; }
.sheet .sheet-head h3 { margin: 0; font-size: 18px; }
.sheet-close { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--card-2); color: var(--text); font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.sheet-close:active { background: var(--border); }
.sheet h3 { margin: 4px 0 14px; font-size: 18px; }
.sheet .field { margin-bottom: 12px; }
.sheet label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet .actions .btn { flex: 1; }

/* ── Calendar ──────────────────────────────────────────────── */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; color: var(--text-dim); font-size: 11px; padding: 4px 0; }
.cal-cell { aspect-ratio: 1; border-radius: 10px; background: var(--card); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; position: relative; }
.cal-cell.out { opacity: .35; }
.cal-cell.today { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.cal-cell .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); position: absolute; bottom: 6px; }

/* ── Task board (stacked vertical sections, mobile) ────────── */
.kanban { display: flex; flex-direction: column; gap: 12px; }
.kcol { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.kcol h4 { margin: 2px 4px 10px; font-size: 13px; font-weight: 700; color: var(--text-dim); }
.kcard { background: var(--card-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.kcard .t { font-weight: 600; font-size: 14px; }
.kcard .meta { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.dot-prio { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ── Receipt thumb ─────────────────────────────────────────── */
.thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--card-2); }
.preview { width: 100%; border-radius: 12px; margin: 8px 0; max-height: 280px; object-fit: contain; background: #000; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Full-screen PDF viewer (with X to close) ──────────────── */
.pdf-overlay { position: fixed; inset: 0; z-index: 300; background: var(--bg); display: flex; flex-direction: column; }
.pdf-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); }
.pdf-bar .pdf-title { flex: 1; font-weight: 600; font-size: 15px; }
.pdf-bar .pdf-open { color: var(--accent); font-size: 13px; text-decoration: none; white-space: nowrap; }
.pdf-close { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 26px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.pdf-close:hover { border-color: var(--red); color: var(--red); }
.pdf-frame { flex: 1; width: 100%; border: 0; background: #2a2a2a; }
