/* Photo CRM Studio — design system
   Warm neutrals, plum primary, gold accent. Always light. */

:root {
  --bg: #f7f4f0;
  --bg-elev: #ffffff;
  --bg-sunken: #f1ece6;
  --bg-hover: #f3eef4;
  --ink: #241d2c;
  --ink-2: #4a4353;
  --muted: #736c7b;
  --faint: #a39cab;
  --line: #e7e0d9;
  --line-strong: #d6ccd6;
  --primary: #4a2f5c;
  --primary-hover: #3a2449;
  --primary-soft: #f0e8f3;
  --primary-ink: #5e3f73;
  --accent: #b9803f;
  --accent-soft: #f8eedf;
  --green: #2f7a63;
  --green-soft: #e3f2ec;
  --yellow: #9a6a12;
  --yellow-soft: #fbf1d6;
  --red: #a23b4d;
  --red-soft: #f9e6e9;
  --blue: #2f6390;
  --blue-soft: #e5eef7;
  --shadow-sm: 0 1px 2px rgba(40, 24, 40, .06);
  --shadow: 0 1px 2px rgba(40, 24, 40, .05), 0 8px 24px rgba(40, 24, 40, .06);
  --shadow-lg: 0 24px 60px rgba(30, 16, 36, .22);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 252px;
  --focus: 0 0 0 3px rgba(94, 63, 115, .25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-ink); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2.15rem); letter-spacing: -.035em; line-height: 1.12; margin-bottom: 6px; }
h2 { font-size: 1.05rem; letter-spacing: -.015em; margin-bottom: 4px; }
h3 { font-size: .95rem; margin-bottom: 8px; }
code { font: 500 .86em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: var(--bg-elev); border-right: 1px solid var(--line); overflow-y: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: -.02em; }
.brand img { max-height: 34px; max-width: 150px; object-fit: contain; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #7b5494); color: #fff; font-size: 1rem; flex: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 38px; padding: 0 10px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-sunken); color: var(--muted); cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--ink-2); }
.search-trigger span { flex: 1; }
kbd { font: 600 .72rem ui-monospace, Menlo, monospace; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); background: var(--bg-elev); }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: .7rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--bg-hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); }
.nav a[aria-current="page"] .icon { stroke: var(--primary-ink); }
.nav .badge { margin-left: auto; }
.sidebar-footer { margin-top: auto; display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line); }
.sidebar-footer form { margin: 0; }
.nav-button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-2); font-weight: 550; cursor: pointer; text-align: left; }
.nav-button:hover { background: var(--bg-hover); color: var(--ink); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-size: .72rem; font-weight: 750; background: var(--green); color: #fff; }
.badge-muted { background: var(--bg-sunken); color: var(--muted); border: 1px solid var(--line); }
.badge-warn { background: var(--accent); }

.main { min-width: 0; grid-column: 2; }
.nav-scrim { display: none; }
.topbar { display: none; }
.page { width: min(1260px, 100%); margin: 0 auto; padding: 32px clamp(16px, 3.4vw, 44px) 80px; }
.page-narrow { width: min(760px, 100%); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .muted { max-width: 64ch; }
.eyebrow { display: block; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 550; }
.back-link:hover { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* ---------- Buttons ---------- */
.button {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 650; font-size: .93rem; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.button:active { transform: translateY(1px); }
.button:focus-visible, .text-input:focus, .select-input:focus, .nav a:focus-visible, .icon-button:focus-visible { outline: none; box-shadow: var(--focus); }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { background: var(--bg-elev); border-color: var(--line-strong); color: var(--ink); }
.button-secondary:hover { background: var(--bg-hover); }
.button-ghost { background: transparent; color: var(--ink-2); }
.button-ghost:hover { background: var(--bg-hover); color: var(--ink); }
.button-danger { background: var(--red); color: #fff; }
.button-danger-ghost { background: transparent; color: var(--red); border-color: transparent; }
.button-danger-ghost:hover { background: var(--red-soft); }
.button-sm { min-height: 32px; padding: 5px 10px; font-size: .85rem; }
.button-block { width: 100%; }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--bg-hover); color: var(--ink); }
.link-button { border: 0; background: none; padding: 0; color: var(--primary-ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-button.danger { color: var(--red); }

/* ---------- Cards / panels ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 18px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.card-head p { margin-bottom: 0; }
.card-head .muted { font-size: .9rem; }
.card-section { padding: 18px 22px; border-top: 1px solid var(--line); }
.card-section:first-child { border-top: 0; }
.stack { display: grid; gap: 18px; align-content: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { position: relative; display: block; padding: 17px 18px; border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; overflow: hidden; }
a.kpi:hover { border-color: var(--line-strong); }
.kpi-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .84rem; font-weight: 600; }
.kpi-value { display: block; font-size: 1.85rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-sub { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.kpi-accent { background: linear-gradient(140deg, var(--primary) 0%, #6d4a85 100%); border-color: transparent; color: #fff; }
.kpi-accent .kpi-label, .kpi-accent .kpi-sub { color: rgba(255,255,255,.8); }
.progress { height: 7px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #d9a466); border-radius: inherit; }
.kpi-next { display: block; margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.22); font-size: .82rem; color: rgba(255,255,255,.85); }
.kpi-next strong { color: #fff; }
.kpi-accent .progress { background: rgba(255,255,255,.18); border-color: transparent; }

/* ---------- Lists ---------- */
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; position: relative; }
.list-row:first-child { border-top: 0; }
a.list-row:hover, .list-row.is-link:hover { background: var(--bg-hover); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.list-row-main small, .list-meta { display: block; color: var(--muted); font-size: .83rem; }
.list-empty { padding: 26px 22px; color: var(--muted); text-align: center; }
.row-flag { position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; }
.row-flag--red { background: var(--red); } .row-flag--yellow { background: var(--accent); } .row-flag--green { background: var(--green); }
.attention { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font-size: .8rem; font-weight: 650; }
.attention--red { color: var(--red); } .attention--yellow { color: var(--yellow); } .attention--green { color: var(--green); }

.date-tile { width: 48px; flex: none; text-align: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary-ink); padding: 6px 2px; line-height: 1.1; }
.date-tile b { display: block; font-size: 1.15rem; font-weight: 750; }
.date-tile span { display: block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.date-tile--none { background: var(--bg-sunken); color: var(--faint); }

.avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: .82rem; color: var(--primary-ink); background: var(--primary-soft); letter-spacing: .02em; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.05rem; }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; line-height: 1.35; white-space: nowrap; background: var(--bg-sunken); color: var(--ink-2); border: 1px solid var(--line); font-style: normal; }
.chip-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.phase-inquiry { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.phase-booking { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }
.phase-planning { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }
.phase-delivery { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.phase-done { background: var(--green-soft); color: var(--green); border-color: transparent; }
.status-cancelled { background: var(--red-soft); color: var(--red); border-color: transparent; }
.status-new_inquiry { background: var(--green-soft); color: var(--green); }
.chip-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.chip-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chip-yellow { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }

/* ---------- Forms ---------- */
label, .label { display: block; font-weight: 650; font-size: .88rem; margin-bottom: 6px; color: var(--ink-2); }
.text-input, .select-input, .file-input {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.text-input::placeholder { color: var(--faint); }
.text-input:hover, .select-input:hover { border-color: var(--faint); }
.text-input:focus, .select-input:focus { border-color: var(--primary); }
textarea.text-input { min-height: 90px; resize: vertical; line-height: 1.55; }
.text-input:disabled, .select-input:disabled { opacity: .55; background: var(--bg-sunken); }
.select-input { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.file-input { padding: 7px; }
.file-input::file-selector-button { margin-right: 10px; border: 1px solid var(--line-strong); background: var(--bg-sunken); color: var(--ink); border-radius: 7px; padding: 5px 10px; font-weight: 600; cursor: pointer; }
.checkbox-input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; margin: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 550; color: var(--ink); cursor: pointer; margin: 0; }
.check .checkbox-input { margin-top: 2px; }
.check small { display: block; color: var(--muted); font-weight: 450; }
.field { margin-bottom: 0; }
.field-full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-stack { display: grid; gap: 16px; }
.help-text { margin: 6px 0 0; color: var(--muted); font-size: .82rem; font-weight: 450; }
.required { color: var(--red); margin-left: 3px; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--red); font-size: .84rem; font-weight: 600; }
.has-error .text-input, .has-error .select-input { border-color: var(--red); }
.form-errors { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--red-soft); color: var(--red); margin-bottom: 16px; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.choice-list, .choice-list ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.choice-list label, ul.choice-list label { display: flex; gap: 9px; align-items: center; font-weight: 500; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; margin: 0; cursor: pointer; background: var(--bg-elev); }
.choice-list label:hover { border-color: var(--line-strong); }
.choice-list input { accent-color: var(--primary); width: 16px; height: 16px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 650; font-size: .88rem; margin-bottom: 8px; color: var(--ink-2); padding: 0; }
.inline-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields > * { flex: 1 1 140px; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; }
.input-with-button { display: flex; gap: 8px; }
.input-with-button .text-input { flex: 1; min-width: 0; font-size: .88rem; }

/* ---------- Messages / toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 550; animation: toast-in .25s ease-out; }
.toast .icon { margin-top: 2px; }
.toast.success .icon { stroke: #7fd6b5; } .toast.error .icon { stroke: #ff9fb0; } .toast.warning .icon { stroke: #f1c26d; }
.toast button { margin-left: auto; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; padding: 0 2px; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-sunken); color: var(--ink-2); }
.notice p:last-child { margin-bottom: 0; }
.notice-warning { background: var(--yellow-soft); border-color: transparent; color: var(--ink); }
.notice-danger { background: var(--red-soft); border-color: transparent; color: var(--ink); }
.notice-success { background: var(--green-soft); border-color: transparent; color: var(--ink); }
.notice .icon { margin-top: 2px; flex: none; }

/* ---------- Tables / client list ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .search-field { flex: 1 1 260px; position: relative; }
.toolbar .search-field .icon { position: absolute; left: 11px; top: 11px; color: var(--faint); }
.toolbar .search-field .text-input { padding-left: 36px; }
.toolbar .select-input { width: auto; min-width: 150px; flex: 0 1 190px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-sunken); border: 1px solid var(--line); }
.segmented a, .segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .86rem; border: 0; background: none; cursor: pointer; }
.segmented [aria-current="true"] { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 11px 16px; background: var(--bg-sunken); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th a { color: inherit; text-decoration: none; }
.table th a:hover { color: var(--ink); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; position: relative; }
.table tbody tr:hover td { background: var(--bg-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.client-cell { display: flex; gap: 12px; align-items: center; min-width: 190px; }
.table .chip { white-space: normal; }
.client-cell a { color: var(--ink); text-decoration: none; font-weight: 650; }
.client-cell small { display: block; color: var(--muted); font-size: .8rem; }
.task-cell-flag { width: 4px; padding: 0 !important; }
.task-cell-flag span { display: block; width: 4px; height: 38px; border-radius: 3px; }
.list-summary { display: flex; justify-content: space-between; gap: 10px; padding: 11px 16px; font-size: .84rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--bg-sunken); }

/* ---------- Pipeline (kanban) ---------- */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.pipeline-col { background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); min-height: 180px; }
.pipeline-col-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.pipeline-col-head strong { font-size: .9rem; }
.pipeline-col-head small { color: var(--muted); font-size: .78rem; }
.pipeline-cards { display: grid; gap: 8px; padding: 6px 10px 12px; overflow-y: auto; min-height: 60px; align-content: start; flex: 1; }
.pipeline-col.is-over { border-color: var(--primary); background: var(--primary-soft); }
.deal { display: block; padding: 11px 12px; border-radius: 11px; background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--ink); text-decoration: none; cursor: grab; position: relative; }
.deal:hover { border-color: var(--line-strong); }
.deal.is-dragging { opacity: .45; }
.deal strong { display: block; font-size: .92rem; font-weight: 650; margin-bottom: 2px; padding-right: 18px; }
.deal small { display: block; color: var(--muted); font-size: .78rem; }
.deal .chip { margin-top: 8px; }
.deal-flag { position: absolute; top: 12px; right: 11px; width: 8px; height: 8px; border-radius: 50%; }
.deal-flag--red { background: var(--red); } .deal-flag--yellow { background: var(--accent); } .deal-flag--green { background: var(--green); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-head h2 { font-size: 1.3rem; margin: 0 8px 0 0; text-transform: capitalize; min-width: 170px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); box-shadow: var(--shadow); }
.cal-dow { padding: 9px 10px; font-size: .74rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--bg-sunken); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 118px; padding: 6px 7px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; position: relative; }
.cal-day.is-other { background: var(--bg-sunken); }
.cal-day.is-other .cal-num { color: var(--faint); }
.cal-num { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.cal-day.is-today .cal-num b { background: var(--primary); color: #fff; border-radius: 99px; padding: 1px 7px; }
.cal-add { opacity: 0; color: var(--muted); text-decoration: none; font-size: 1rem; line-height: 1; padding: 0 3px; border-radius: 5px; }
.cal-day:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--bg-hover); color: var(--ink); }
.cal-item { display: block; padding: 3px 7px; border-radius: 6px; font-size: .76rem; line-height: 1.3; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--primary-ink); background: var(--primary-soft); border-left: 3px solid var(--primary); }
.cal-item b { font-weight: 700; }
.cal-item--wedding { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); }
.cal-item--meeting { color: var(--blue); background: var(--blue-soft); border-left-color: var(--blue); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: .82rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Client detail ---------- */
.client-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.client-hero-main { flex: 1; min-width: 260px; }
.client-hero h1 { margin-bottom: 4px; }
.client-hero-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .9rem; }
.client-hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.client-hero-meta a { color: inherit; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 650; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-selected="true"] { color: var(--primary-ink); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }
.name-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.fact { background: var(--bg-elev); padding: 13px 15px; }
.fact span { display: block; color: var(--muted); font-size: .76rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.fact strong { display: block; font-size: 1rem; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; }
.save-bar { position: sticky; bottom: 14px; z-index: 20; display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 11px 12px 11px 18px; margin-top: 18px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s; }
.save-bar.is-visible { transform: none; opacity: 1; pointer-events: auto; }
.save-bar .button-ghost { color: var(--bg); }
.save-bar .button-ghost:hover { background: rgba(255,255,255,.1); }
.save-bar .button-primary { background: var(--accent); color: #1b1520; }
.weather { display: flex; gap: 14px; align-items: center; }
.weather-icon { font-size: 2.1rem; line-height: 1; }
.weather strong { display: block; font-size: 1.02rem; }
.sun-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.sun-grid div { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.sun-grid span { display: block; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.sun-grid strong { font-variant-numeric: tabular-nums; }
.answers { display: grid; gap: 0; margin: 0; }
.answers div { padding: 12px 0; border-top: 1px solid var(--line); }
.answers div:first-child { border-top: 0; padding-top: 0; }
.answers dt { font-weight: 650; font-size: .88rem; color: var(--ink-2); }
.answers dd { margin: 3px 0 0; white-space: pre-wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; background: var(--bg-sunken); }
.gallery figcaption { font-size: .82rem; font-weight: 600; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery form { margin: 0; }
.gallery .remove { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(20,14,24,.72); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: .15s; }
.gallery figure:hover .remove, .gallery .remove:focus { opacity: 1; }
@media (hover: none) { .gallery .remove { opacity: 1; } }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.file-list li:first-child { border-top: 0; }
.file-list a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-list form { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 20px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline strong { display: block; font-size: .9rem; }
.timeline p { margin: 1px 0 2px; color: var(--ink-2); font-size: .88rem; }
.timeline time { font-size: .78rem; color: var(--muted); }
details.disclosure { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-sunken); }
details.disclosure summary { cursor: pointer; padding: 10px 14px; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 8px; }
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::before { content: "+"; font-weight: 800; color: var(--muted); width: 14px; }
details.disclosure[open] summary::before { content: "–"; }
details.disclosure > div { padding: 4px 14px 14px; }

/* ---------- Tasks ---------- */
.task { display: flex; align-items: center; gap: 14px; padding: 13px 22px; border-top: 1px solid var(--line); position: relative; }
.task:first-child { border-top: 0; }
.task-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.task-dot--red { background: var(--red); } .task-dot--yellow { background: var(--accent); } .task-dot--green { background: var(--green); }
.task.is-unread { background: color-mix(in srgb, var(--green-soft) 55%, transparent); }
.task-link { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; display: flex; gap: 12px; align-items: center; }
.task-link div { flex: 1; min-width: 0; }
.task-link strong { display: block; }
.task-link span { display: block; color: var(--ink-2); font-size: .9rem; }
.task-link small { display: block; color: var(--muted); font-size: .8rem; }
.task form { margin: 0; }
.rule { display: flex; gap: 14px; align-items: flex-start; padding: 16px 22px; border-top: 1px solid var(--line); }
.rule:first-child { border-top: 0; }
.rule-color { width: 12px; height: 12px; border-radius: 4px; margin-top: 5px; flex: none; }
.rule-color--red { background: var(--red); } .rule-color--yellow { background: var(--accent); } .rule-color--green { background: var(--green); }
.rule-main { flex: 1; min-width: 0; }
.rule-main small { display: block; color: var(--muted); font-size: .82rem; }
.rule-main p { margin: 5px 0 0; font-size: .9rem; color: var(--ink-2); }
.rule.is-inactive { opacity: .6; }

/* ---------- Mails ---------- */
.mail-preview-frame { width: 100%; min-height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #f6f2ee; }
.variable-list { display: flex; flex-wrap: wrap; gap: 6px; }
.variable-list button { border: 1px dashed var(--line-strong); background: var(--bg-elev); border-radius: 7px; padding: 4px 8px; font: 600 .8rem ui-monospace, Menlo, monospace; color: var(--primary-ink); cursor: pointer; }
.variable-list button:hover { border-style: solid; background: var(--primary-soft); }
.delivery { display: flex; gap: 12px; align-items: center; padding: 11px 22px; border-top: 1px solid var(--line); }
.delivery:first-child { border-top: 0; }
.delivery div:first-child { flex: 1; min-width: 0; }
.delivery strong { display: block; font-size: .92rem; }
.delivery span, .delivery small { display: block; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.delivery .danger { color: var(--red); }
.delivery-meta { text-align: right; flex: none; }

/* ---------- Settings ---------- */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 26px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: grid; gap: 2px; }
.settings-nav a { padding: 7px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; }
.settings-nav a:hover { background: var(--bg-hover); color: var(--ink); }
.setting-section { scroll-margin-top: 20px; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; }
.status-line::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status-line.ok::before { background: var(--green); } .status-line.warn::before { background: var(--accent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .88rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Rich text editor ---------- */
.rte { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg-elev); overflow: hidden; }
.rte:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 5px 6px; border-bottom: 1px solid var(--line); background: var(--bg-sunken); }
.rte-toolbar button { min-width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); cursor: pointer; font-size: .9rem; }
.rte-toolbar button:hover, .rte-toolbar button.is-active { background: var(--bg-hover); color: var(--ink); }
.rte-toolbar select { height: 30px; border: 0; background: none; color: var(--ink-2); font-size: .85rem; border-radius: 6px; padding: 0 6px; cursor: pointer; }
.rte-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 4px; }
.rte-area { min-height: 150px; max-height: 70vh; overflow-y: auto; padding: 12px 14px; outline: none; line-height: 1.62; overflow-wrap: anywhere; }
.rte-area > div { min-height: 1.62em; margin: 0; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--faint); }
.rte-tall .rte-area { min-height: 60vh; }
.rich-text-output-line { min-height: 1.62em; margin: 0; }
.rich-text font[size="1"], .rte-area font[size="1"] { font-size: .7em; }
.rich-text font[size="2"], .rte-area font[size="2"] { font-size: .85em; }
.rich-text font[size="4"], .rte-area font[size="4"] { font-size: 1.2em; }
.rich-text font[size="5"], .rte-area font[size="5"] { font-size: 1.45em; font-weight: 700; }
.rich-text font[size="6"], .rte-area font[size="6"] { font-size: 1.8em; font-weight: 700; }
.rich-text { overflow-wrap: anywhere; }

/* ---------- Command palette ---------- */
.palette-backdrop { position: fixed; inset: 0; background: rgba(18, 12, 22, .45); backdrop-filter: blur(3px); z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette { width: min(620px, 100%); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; border: 0; background: none; outline: none; min-height: 54px; font-size: 1.05rem; color: var(--ink); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: .7rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.palette-item.is-active { background: var(--primary-soft); }
.palette-item .avatar { width: 32px; height: 32px; font-size: .74rem; }
.palette-item-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-sunken); color: var(--muted); flex: none; }
.palette-item div { min-width: 0; }
.palette-item strong { display: block; font-weight: 650; }
.palette-item small { display: block; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-empty { padding: 24px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--muted); background: var(--bg-sunken); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; stroke-width: 1.4; color: var(--faint); margin-bottom: 8px; }
.empty strong { display: block; color: var(--ink); font-size: 1.02rem; margin-bottom: 4px; }
.empty p { max-width: 42ch; margin: 0 auto 14px; }

/* ---------- Public pages ---------- */
.public-body { background: radial-gradient(1200px 500px at 50% -120px, var(--primary-soft), transparent), var(--bg); min-height: 100vh; }
.public-header { width: min(920px, 100% - 32px); margin: 0 auto; padding: 26px 0 0; display: flex; justify-content: center; }
.public-header .brand { padding: 0; font-size: 1.05rem; }
.public-main { width: min(860px, 100% - 32px); margin: 0 auto; padding: 36px 0 70px; }
.public-main.is-narrow { width: min(520px, 100% - 32px); }
.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.7rem); }
.hero p { color: var(--muted); max-width: 56ch; margin: 0 auto; font-size: 1.02rem; }
.public-footer { text-align: center; color: var(--muted); font-size: .85rem; padding-bottom: 30px; }
.public-footer a { color: inherit; }
.countdown-big { font-size: 2.6rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--primary-ink); }
.cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.cta p { margin-bottom: 0; }
.cta-highlight { background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); border-color: transparent; }
.reference-person { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--bg-sunken); }
.reference-person-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.reference-cropper { margin-top: 12px; }
.reference-canvas-wrap { position: relative; width: min(260px, 100%); aspect-ratio: 1; border-radius: 12px; overflow: hidden; touch-action: none; }
.reference-canvas-wrap canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.person-guide { position: absolute; inset: 0; pointer-events: none; }
.person-guide i { position: absolute; left: 50%; top: 18%; width: 34%; aspect-ratio: .8; transform: translateX(-50%); border: 2px dashed rgba(255,255,255,.8); border-radius: 50%; }
.person-guide b { position: absolute; left: 50%; bottom: -12%; width: 72%; height: 40%; transform: translateX(-50%); border: 2px dashed rgba(255,255,255,.8); border-radius: 50% 50% 0 0; }
.auth-card { max-width: 400px; margin: 6vh auto 0; }
.success-mark { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); font-size: 1.6rem; margin: 0 auto 14px; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.prose h2 { margin-top: 22px; }
.prose p { color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1250px) { .table .hide-lg { display: none; } }
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-main-side { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main { grid-column: 1; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(18,12,22,.4); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 8px; padding: 8px 12px; background: color-mix(in srgb, var(--bg-elev) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; flex: 1; justify-content: center; font-size: .98rem; }
  .topbar .brand-mark { width: 28px; height: 28px; border-radius: 8px; font-size: .85rem; }
  .page { padding-top: 20px; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .settings-nav a { white-space: nowrap; background: var(--bg-elev); border: 1px solid var(--line); }
  .table .hide-md { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 1.5rem; }
  .grid-2, .grid-3, .form-grid, .form-grid-3, .name-inputs { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px; border-radius: 12px; }
  .list-row, .task, .rule, .delivery { padding-left: 16px; padding-right: 16px; }
  .page-head { align-items: flex-start; }
  .page-head > .actions { width: 100%; }
  .toolbar .select-input { flex: 1 1 45%; min-width: 0; }
  .table .hide-sm { display: none; }
  .table td, .table th { padding: 10px 12px; }
  .cal-day { min-height: 74px; padding: 4px; }
  .cal-item { font-size: .66rem; padding: 2px 4px; }
  .cal-item .cal-time { display: none; }
  .cal-dow { font-size: .62rem; padding: 6px 4px; }
    .save-bar { bottom: 8px; padding-left: 14px; }
  .save-bar span { font-size: .85rem; }
  .toasts { right: 10px; left: 10px; bottom: 10px; width: auto; }
}
@media print {
  .sidebar, .topbar, .toasts, .save-bar, .no-print { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Contract signing ---------- */
.signature-pad { position: relative; height: 190px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #fff; touch-action: none; overflow: hidden; }
.signature-pad canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.signature-line { position: absolute; left: 22px; right: 22px; bottom: 42px; border-bottom: 1px solid var(--line-strong); pointer-events: none; }
