/* ==========================================================================
   Gantt — design system (tokens, base, components). Light + dark.
   ========================================================================== */

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f9;
  --text: #121626;
  --muted: #667089;
  --border: #e2e5f0;
  --border-strong: #cfd4e4;
  --primary: #4b57d8;
  --primary-600: #3a45bf;
  --primary-soft: #eceefe;
  --on-primary: #ffffff;
  --danger: #dc3b46;
  --danger-soft: #fdecee;
  --ok: #1f9d62;
  --ok-soft: #e4f6ec;
  --warn: #d98a00;
  --warn-soft: #fff4d9;
  --shadow: 0 1px 2px rgba(18, 22, 38, .05), 0 6px 20px rgba(18, 22, 38, .06);
  --shadow-lg: 0 18px 60px rgba(18, 22, 38, .22);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --header-h: 58px;
  color-scheme: light;
}

.dark {
  --bg: #0d1019;
  --surface: #151925;
  --surface-2: #1b2030;
  --text: #e8ebf5;
  --muted: #98a1ba;
  --border: #272d42;
  --border-strong: #353d57;
  --primary: #7b86f5;
  --primary-600: #98a1ff;
  --primary-soft: #1d2250;
  --on-primary: #0d1019;
  --danger: #ff6b75;
  --danger-soft: #3b1a1f;
  --ok: #46d192;
  --ok-soft: #123226;
  --warn: #f2b53a;
  --warn-soft: #3a2f10;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/1.45 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
[hidden], .is-hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 900px) { .wrap { padding-inline: 24px; } }
i.ki-filled, i.ki-outline, i.ki-duotone, i.ki-solid { line-height: 1; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header .wrap { height: 100%; display: flex; align-items: center; gap: 14px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; white-space: nowrap; }
.logo svg { width: 30px; height: 30px; flex: none; }
.logo b { color: var(--primary); font-weight: 800; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--primary-600); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.soft:hover { background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary) 12%); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger.ghost:hover { background: var(--danger-soft); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; height: 44px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn i { font-size: 18px; }
.theme-sun { display: none; }
.dark .theme-sun { display: inline; }
.dark .theme-moon { display: none; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); outline: none;
}
.textarea { resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: 17px; pointer-events: none; }
.input-icon > .input { padding-left: 38px; }
.field-error { color: var(--danger); font-size: 12.5px; min-height: 0; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13.5px; background: var(--danger-soft); color: var(--danger); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.page { padding-block: 28px 56px; flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--primary); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 30px 0 12px; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 12px; padding: 18px; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.tile:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.tile h3 { font-size: 16px; font-weight: 700; line-height: 1.3; }
.tile-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 20px; }
.tile-foot { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.tile-foot span { display: inline-flex; align-items: center; gap: 5px; }
.tile .tile-menu { position: absolute; top: 10px; right: 10px; }   /* .menu below sets position: relative, so this needs the extra class */
.tile-new {
  border-style: dashed; border-color: var(--border-strong); background: transparent; align-items: center; justify-content: center;
  min-height: 130px; color: var(--muted); font-weight: 600; cursor: pointer; text-align: center; font-size: 14px;
}
.tile-new:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.tile-new i { font-size: 24px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.edit { background: var(--ok-soft); color: var(--ok); }
.badge.view { background: var(--warn-soft); color: var(--warn); }
.badge.owner { background: var(--primary-soft); color: var(--primary); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty i { font-size: 38px; color: var(--border-strong); display: block; margin-bottom: 10px; }

/* ---------- Avatars ---------- */
.ava {
  --s: 30px; width: var(--s); height: var(--s); flex: none; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--c, var(--primary)); color: #fff; font-weight: 700; font-size: calc(var(--s) * .42); text-transform: uppercase;
  border: 2px solid var(--surface); user-select: none;
}

/* ---------- Dropdown menu ---------- */
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; padding: 6px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  display: none;
}
.menu.open > .menu-pop { display: block; }
.menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
  text-align: left; cursor: pointer; font-size: 14px;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop .danger { color: var(--danger); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu-pop i { color: var(--muted); font-size: 17px; }
.menu-pop .danger i { color: var(--danger); }
.user-btn { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.user-btn:hover { border-color: var(--border-strong); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 24, .5); backdrop-filter: blur(3px); animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow: auto; padding: 22px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out;
}
.modal.wide { max-width: 560px; }
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; translate: -50% 0; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow-lg); animation: pop .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Auth ---------- */
.auth { flex: 1; display: grid; place-items: center; padding: 28px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; }
.auth-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- Landing ---------- */
.hero { padding: 64px 0 36px; text-align: center; }
.hero h1 { font-size: clamp(32px, 6vw, 54px); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; max-width: 14em; margin-inline: auto; }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p { margin: 18px auto 28px; max-width: 34em; color: var(--muted); font-size: 17px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn { height: 46px; padding-inline: 24px; font-size: 15px; }
.demo { margin: 36px auto 0; max-width: 920px; padding: 14px; overflow: hidden; }
.demo svg { width: 100%; height: auto; display: block; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 40px; }
.feature { padding: 20px; }
.feature i { font-size: 22px; color: var(--primary); }
.feature h3 { margin: 12px 0 6px; font-size: 16px; }
.feature p { color: var(--muted); font-size: 14px; }
.site-foot { padding: 22px 0; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }

@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .page-head { align-items: stretch; flex-direction: column; gap: 10px; }
  .page-head > .row, .page-head > .btn { margin-left: 0 !important; width: 100%; }
  .page-head .btn { flex: 1; height: 44px; }
  .page-head .grow { width: 100%; }
  .page-head h1 { white-space: normal; }
  .grid-cards { grid-template-columns: 1fr; }
  .hero { padding: 36px 0 24px; }
  .hero-actions .btn { width: 100%; }
  .app-header .wrap { gap: 8px; }
  .tile-menu .icon-btn, .menu > .icon-btn { width: 40px; height: 40px; }
  .menu-pop button, .menu-pop a { padding: 12px 12px; }
  .input, .select, .textarea { font-size: 16px; min-height: 44px; }
  .btn { height: 44px; }
  .btn.sm { height: 38px; }
  .page { padding-block: 18px 40px; }
  .page-head h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
