/* YG ERP — colors follow the YourGrace website palette */
:root {
    --indigo: #5976BA;
    --indigo-dark: #465f99;
    --indigo-soft: #eef1f8;
    --green: #6FBE44;
    --lime: #B9D532;
    --blue: #27AAE1;
    --purple: #662D91;
    --grey: #6D6E71;
    --ink: #2B2B2D;
    --paper: #ffffff;
    --bg: #f5f6f8;
    --border: #e4e5e1;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --success-soft: #eaf6e3;
    --info-soft: #e6f4fb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Segoe UI", -apple-system, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--ink);
    color: #d6d7da;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: .02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--lime), var(--green));
    color: var(--ink);
    font-size: 14px;
}
.nav { display: flex; flex-direction: column; padding: 4px 12px; gap: 2px; flex: 1; overflow-y: auto; }
.nav a, .nav-soon {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    color: #d6d7da;
}
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--indigo); color: #fff; }
.nav-soon { color: #7d7e83; cursor: default; }
.nav-soon em { font-style: normal; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.nav-group {
    margin: 16px 12px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #8b8c91;
}
.sidebar-foot { padding: 16px 24px; border-top: 1px solid rgba(255, 255, 255, .08); }
.user-name { color: #fff; font-weight: 600; }
.link-button {
    background: none;
    border: 0;
    padding: 0;
    color: #b3b4b8;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.link-button:hover { color: #fff; text-decoration: underline; }
.sidebar-foot-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.lang-switch { display: inline-flex; gap: 2px; margin: 0; }
.lang-switch button {
    background: none; border: 1px solid transparent; border-radius: 4px; padding: 1px 6px;
    font: inherit; font-size: 12px; color: #b3b4b8; cursor: pointer;
}
.lang-switch button:hover { color: #fff; }
.lang-switch button.active { border-color: rgba(255, 255, 255, .35); color: #fff; }
.guest-lang { display: flex; justify-content: center; margin-top: 20px; }
.guest-lang .lang-switch button { color: #6b6c72; }
.guest-lang .lang-switch button:hover { color: var(--indigo-dark); }
.guest-lang .lang-switch button.active { border-color: #c9cbd3; color: var(--indigo-dark); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 32px;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 21px; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar-actions form { margin: 0; }
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 18px;
    padding: 4px 10px;
    cursor: pointer;
}
.content { padding: 24px 32px 48px; max-width: 1200px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--indigo-soft); text-decoration: none; }
.btn-primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--grey); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Cards & layout ---------- */
.card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-soon { background: transparent; border-style: dashed; box-shadow: none; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.count { color: var(--grey); font-weight: 400; }
.breadcrumb { margin: 0 0 16px; font-size: 14px; }

/* ---------- Dashboard greeting ---------- */
.greeting { margin-bottom: 18px; }
.greeting-date { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--indigo); }
.greeting-title { font-size: 28px; font-weight: 700; color: var(--ink); margin-top: 2px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat {
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    color: var(--ink);
    border-top: 3px solid var(--indigo);
}
a.stat:hover { text-decoration: none; border-color: var(--indigo); }
.stat:nth-child(2) { border-top-color: var(--green); }
.stat:nth-child(3) { border-top-color: var(--blue); }
.stat:nth-child(4) { border-top-color: var(--purple); }
.stat-soon { opacity: .6; }
.stat-label { font-size: 13px; color: var(--grey); }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.2; }
.stat-sub { font-size: 13px; color: var(--grey); }

/* ---------- Tables & lists ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--grey); font-weight: 600; background: #fafafa; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.num { text-align: right !important; }
.list { list-style: none; margin: 0; padding: 0; }
.list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input[type="search"] { flex: 1; min-width: 200px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }

.empty { text-align: center; padding: 48px 20px; }
.empty p { margin: 0 0 16px; color: var(--grey); }
.empty-code { font-size: 48px; font-weight: 700; color: var(--indigo); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #eee;
    color: var(--grey);
    white-space: nowrap;
    vertical-align: middle;
}
.badge-client { background: var(--success-soft); color: #3c7a1e; }
.badge-prospect { background: var(--info-soft); color: #11719a; }
.badge-partner { background: #f1e9f7; color: var(--purple); }
.badge-primary { background: var(--indigo-soft); color: var(--indigo-dark); }

/* ---------- Details ---------- */
.details { display: grid; grid-template-columns: minmax(90px, 130px) minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.details dt { color: var(--grey); font-size: 14px; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: normal; overflow-wrap: anywhere; }

/* ---------- Forms ---------- */
.form { max-width: 820px; }
.form-section {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--grey);
    margin: 24px 0 12px;
}
.form-section:first-of-type { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field.checkbox { margin-top: 16px; }
.field.checkbox label { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.req { color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="url"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cfd1d6;
    border-radius: 8px;
    font: inherit;
    font-size: 15px;
    background: #fff;
    color: var(--ink);
}
.filters input, .filters select { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(89, 118, 186, .2);
}
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; }
.field-help { color: var(--grey); font-size: 13px; }
.form-actions { display: flex; gap: 8px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--success-soft); color: #2f6317; }
.alert-error { background: var(--danger-soft); color: #922b21; }
.alert-info { background: var(--info-soft); color: #0e5c7d; }

/* ---------- Utilities ---------- */
.muted { color: var(--grey); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.right { text-align: right; }

[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }
.overdue { color: var(--danger); font-weight: 600; }
.text-ok { color: #3c7a1e; }
.lead { font-size: 16px; margin: 0 0 16px; }
.form-gap { margin-top: 16px; }
.readonly-value { padding: 9px 0; font-weight: 600; }
.stat-money { font-size: 20px; padding: 6px 0 4px; overflow-wrap: anywhere; }
.icon-button {
    background: none; border: 0; cursor: pointer; font-size: 20px; line-height: 1;
    color: var(--grey); padding: 2px 6px; border-radius: 6px;
}
.icon-button:hover { color: var(--danger); background: var(--danger-soft); }

/* Board / list toggle */
.toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.toggle a { padding: 7px 14px; font-weight: 600; font-size: 14px; color: var(--grey); }
.toggle a:hover { text-decoration: none; background: var(--indigo-soft); }
.toggle a.active { background: var(--indigo-soft); color: var(--indigo-dark); }

/* Stage pill + colored dots */
.stage-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.stage-pill::before, .dot {
    content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--stage, var(--c, #999));
}
.dot { background: var(--c); vertical-align: middle; }
.maturity {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
    color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); white-space: nowrap;
}

/* ---------- Opportunities board ---------- */
.content:has(.board) { max-width: none; }
.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(250px, 1fr);
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    align-items: start;
}
.board-col {
    background: #eceef2;
    border-radius: var(--radius);
    border-top: 3px solid var(--stage);
    display: flex;
    flex-direction: column;
    min-height: 200px;
    transition: box-shadow .15s;
}
.board-col.drop-target { box-shadow: 0 0 0 2px var(--stage) inset; }
.board-col-head { padding: 12px 12px 8px; }
.board-col-title { display: flex; align-items: center; gap: 8px; }
.board-col-title .count {
    background: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--grey);
}
.board-col-title .muted { margin-left: auto; }
.board-col-total { font-size: 13px; color: var(--grey); margin-top: 2px; }
.board-cards { display: flex; flex-direction: column; gap: 8px; padding: 0 8px 8px; min-height: 60px; flex: 1; }
.deal-card {
    display: flex; flex-direction: column; gap: 2px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    cursor: grab;
    box-shadow: var(--shadow);
}
.deal-card:hover { text-decoration: none; border-color: var(--stage); }
.deal-card.dragging { opacity: .4; }
.deal-title { font-weight: 600; line-height: 1.3; }
.deal-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-top: 4px; }
.deal-value { font-weight: 600; }
.deal-tag {
    align-self: flex-start; margin-top: 6px; font-size: 11px; padding: 1px 8px; border-radius: 999px;
    background: var(--indigo-soft); color: var(--indigo-dark);
}
.board-add { padding: 8px 12px 12px; font-size: 14px; color: var(--grey); }
.board-help { margin-top: 12px; }

.summary-bar {
    display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; font-size: 14px; color: var(--grey);
}
.summary-bar strong { color: var(--ink); }

/* ---------- Deal page ---------- */
.stage-card { margin-bottom: 16px; }
.stage-steps { display: flex; list-style: none; margin: 0 0 16px; padding: 0; gap: 4px; flex-wrap: wrap; }
.stage-steps li {
    flex: 1; min-width: 90px; text-align: center; padding: 8px 6px; font-size: 13px; font-weight: 600;
    background: #eceef2; color: var(--grey); border-radius: 6px;
}
.stage-steps li.done { background: color-mix(in srgb, var(--stage) 22%, white); color: var(--ink); }
.stage-steps li.current { background: var(--stage); color: #fff; }
.stage-move { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-move select { width: auto; }
.stage-move input[type="text"] { width: auto; flex: 1; min-width: 200px; }

.table-compact th, .table-compact td { padding: 8px 10px; }
.totals {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 24px;
    margin: 12px 0 0; padding: 12px 10px 0; border-top: 1px solid var(--border);
}
.totals dt { color: var(--grey); text-align: right; }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; color: var(--ink); font-size: 16px; }

.add-line { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.add-line summary { cursor: pointer; font-weight: 600; color: var(--indigo); }
.add-line-form { margin-top: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; flex-direction: column; padding: 8px 0 8px 16px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before {
    content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--indigo);
}

/* ---------- Products ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.product-card { display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
.product-card:hover { text-decoration: none; border-color: var(--indigo); }
.product-card .maturity { align-self: flex-start; }
.product-name { font-size: 17px; font-weight: 700; }
.product-stats { display: flex; gap: 16px; margin-top: auto; padding-top: 8px; color: var(--grey); }

/* ---------- Tasks ---------- */
.tasks { list-style: none; margin: 0; padding: 0; }
.task {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.task:last-child { border-bottom: 0; }
.task form { margin: 0; }
.task-check {
    width: 22px; height: 22px; margin-top: 1px; flex-shrink: 0;
    border: 2px solid #b8bcc6; border-radius: 50%; background: #fff;
    color: #fff; font-size: 13px; line-height: 1; cursor: pointer; padding: 0;
    display: grid; place-items: center;
}
.task-check:hover { border-color: var(--green); background: var(--success-soft); }
.task.is-done .task-check { background: var(--green); border-color: var(--green); }
.task-body { flex: 1; min-width: 0; }
.task-title { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.task.is-done .task-title, .task-card.is-done .deal-title { text-decoration: line-through; color: var(--grey); font-weight: 400; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 2px; }
.task-due { white-space: nowrap; padding-top: 2px; }
.task-group { margin-bottom: 16px; padding-top: 14px; padding-bottom: 6px; }
.task-group-title { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--grey); margin-bottom: 4px; }
.task-group-title.overdue { color: var(--danger); }
.prio { font-weight: 600; font-size: 12px; }
.prio::before { content: "\25CF"; margin-right: 4px; }
.prio-urgent { color: var(--danger); }
.prio-high { color: #d97706; }
.prio-low { color: #9ca3af; }

.quick-add { display: flex; gap: 8px; padding: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.quick-add input[type="text"] { flex: 1; min-width: 200px; }
.quick-add input[type="date"], .quick-add select { width: auto; }

/* ---------- Projects ---------- */
.status-pill {
    display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); white-space: nowrap; vertical-align: middle;
}
.progress { display: inline-block; width: 100%; height: 8px; background: #eceef2; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.progress-lg { height: 12px; }
.progress-line { display: flex; align-items: center; gap: 10px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { display: flex; flex-direction: column; gap: 8px; color: var(--ink); border-top: 3px solid var(--c); }
.project-card:hover { text-decoration: none; border-color: var(--c); }
.project-card .status-pill { align-self: flex-start; }
.project-card-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); color: var(--grey); }
.project-row { align-items: center !important; }
.project-row-main { min-width: 0; }
.project-row-main .status-pill { margin-left: 6px; }
.project-row-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.project-row-side .progress { width: 80px; }
.project-head { display: flex; justify-content: space-between; align-items: center; gap: 16px 32px; flex-wrap: wrap; margin-bottom: 16px; border-top: 3px solid var(--c); }
.project-head-main { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 240px; max-width: 520px; }
.project-head-main .status-pill { align-self: flex-start; }
.inline-add { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); align-items: flex-start; flex-wrap: wrap; }
.inline-add .field:first-of-type { flex: 1; min-width: 180px; }
.inline-add input[type="date"] { width: auto; }
.card-callout { border-color: var(--green); background: var(--success-soft); }

/* ---------- Time ---------- */
.timer-pill {
    display: inline-flex; align-items: center; gap: 8px; margin: 0;
    padding: 4px 6px 4px 12px; border-radius: 999px;
    background: var(--success-soft); border: 1px solid #cfe9bf; max-width: 320px;
}
.timer-label { display: inline-flex; gap: 8px; align-items: baseline; color: #2f6317; min-width: 0; }
.timer-label:hover { text-decoration: none; }
.timer-label [data-timer-elapsed] { font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-what { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.timer-stop {
    border: 0; background: #2f6317; color: #fff; width: 26px; height: 26px; border-radius: 50%;
    cursor: pointer; font-size: 11px; line-height: 1; flex-shrink: 0;
}
.timer-stop:hover { background: var(--danger); }
.timer-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green);
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }
.timer-running { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }

.week-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.week-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.week-totals { display: flex; gap: 20px; color: var(--grey); font-size: 14px; }
.week-totals strong { color: var(--ink); font-size: 18px; }
.day-card .card-head { margin-bottom: 4px; }
.time-list li { align-items: center; }
.time-list.compact li { padding: 6px 0; }
.time-what { min-width: 0; overflow-wrap: anywhere; }
.time-dur { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; gap: 6px; align-items: center; }
.btn-row form { margin: 0; }
.budget-bar { display: block; margin-top: 6px; }
.budget-bar.over > span { background: var(--danger); }
.task-time { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; background: var(--bg); border-radius: 8px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.presets { display: flex; gap: 16px; margin: -8px 0 16px; }
.table-title { padding: 16px 16px 4px; }

/* ---------- Settings ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a {
    padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--grey);
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--indigo-dark); border-bottom-color: var(--indigo); }
.form-intro { margin: -6px 0 12px; }
.form-narrow { max-width: 520px; }
.settings-table th, .settings-table td { vertical-align: middle; padding: 8px 10px; }
.settings-table input[type="text"] { min-width: 110px; }
.settings-table input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid #cfd1d6; border-radius: 6px; background: #fff; cursor: pointer; }
.settings-table tr.is-hidden td { opacity: .55; }
.settings-table .add-row td { background: #fafbfd; }
.input-narrow { width: 80px !important; }
.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; display: inline-flex; }
.icon-button:disabled { opacity: .25; cursor: default; background: none; color: var(--grey); }
.logo-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.logo-preview { max-width: 240px; max-height: 90px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; }
.logo-empty { width: 200px; height: 70px; display: grid; place-items: center; color: var(--grey); font-size: 13px; border-style: dashed; }
.link-danger { background: none; border: 0; padding: 0; color: var(--danger); font: inherit; cursor: pointer; }
.link-danger:hover { text-decoration: underline; }

/* ---------- Quotes & invoices ---------- */
.form-wide { max-width: 1100px; }
.doc-form-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.lines-table th, .lines-table td { padding: 6px; vertical-align: top; }
.lines-table textarea { min-width: 220px; resize: vertical; }
.lines-table input.num { text-align: right; }
.lines-table .col-desc { width: 40%; }
.lines-table .col-qty { width: 8%; }
.lines-table .col-unit { width: 10%; }
.lines-table .col-price { width: 13%; }
.lines-table .col-pct { width: 8%; }
.lines-table .col-total { width: 11%; }
.lines-table [data-line-total] { padding-top: 14px; font-weight: 600; }
.lines-table td.has-error input, .lines-table td.has-error textarea { border-color: var(--danger); }
.lines-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.doc-totals { min-width: 260px; border-top: 0; margin-top: 0; }
.doc-status { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 16px; border-top: 3px solid var(--c); }
.doc-status .status-pill { vertical-align: middle; }
.doc-status-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.doc-total { font-size: 22px; }
.doc-status-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-status-actions form { margin: 0; }
.doc-hint { flex-basis: 100%; margin: 0; }
.doc-intro { margin-bottom: 12px; }
.doc-notes { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.client-block { display: flex; flex-direction: column; gap: 2px; }
.payment-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.filter-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row .filters { margin: 0; }
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pills a { padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--grey); }
.pills a:hover { background: var(--indigo-soft); text-decoration: none; }
.pills a.active { background: var(--indigo); color: #fff; }
@media (max-width: 1000px) {
    .doc-form-top { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Proposals & AI ---------- */
.ai-box { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.ai-box summary, .ai-log summary, .format-help summary { cursor: pointer; font-weight: 600; color: var(--indigo); }
.ai-form { margin-top: 12px; }
.ai-log { margin-top: 12px; }
.sent-text {
    white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 6px; padding: 8px; max-height: 260px; overflow: auto;
}
.ai-status.ok { border-top: 3px solid var(--green); }
.ai-status { margin-bottom: 16px; }
.setup-steps { padding-left: 20px; }
.setup-steps li { margin-bottom: 6px; }
.section-edit { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; background: #fcfcfd; }
.section-edit-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.section-edit-head input { font-weight: 600; }
.section-no { font-weight: 700; color: var(--indigo); min-width: 24px; }
.section-edit textarea { font-family: Consolas, "Courier New", monospace; font-size: 13.5px; }
.section-ai { display: flex; gap: 8px; margin-top: 8px; }
.section-ai input { flex: 1; font-size: 14px; }
.format-help { margin-bottom: 12px; }
.format-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin-top: 8px; }
.format-grid code { background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin-top: 0; z-index: 5; align-items: center; flex-wrap: wrap; }

/* Pipeline bars (dashboard) */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { display: grid; grid-template-columns: 110px 1fr 32px; align-items: center; gap: 10px; font-size: 14px; }
.bar-track { height: 10px; background: #eceef2; border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; min-width: 2px; }
.bar-value { text-align: right; font-weight: 600; }

/* ---------- Guest pages (login, setup) ---------- */
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--indigo-soft); }
.guest-box {
    width: 100%;
    max-width: 400px;
    background: var(--paper);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 10px 30px rgba(43, 43, 45, .08);
}
.brand-center { justify-content: center; color: var(--ink); padding: 0 0 20px; }
.guest-title { font-size: 20px; margin-bottom: 8px; text-align: center; }
.guest-box .muted { text-align: center; margin: 0 0 16px; font-size: 14px; }
.guest-box .stack { gap: 14px; margin-top: 16px; }
.code-input { font-size: 24px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.guest-links { flex-direction: row; justify-content: space-between; align-items: center; margin-top: 18px; font-size: 13px; }
.guest-links .link-button { color: var(--indigo-dark); font-size: 13px; }
.guest-links .link-button:hover { color: var(--indigo-dark); }

/* ---------- Small screens ---------- */
@media (max-width: 1200px) {
    /* Detail pages: the side column gets too narrow next to the sidebar, so stack it. */
    .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
    .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1000px) {
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
    .sidebar {
        position: fixed;
        z-index: 20;
        left: 0;
        transform: translateX(-100%);
        transition: transform .2s;
    }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .menu-toggle { display: block; }
    .topbar { padding: 12px 16px; flex-wrap: wrap; }
    .topbar h1 { font-size: 18px; }
    .content { padding: 16px 16px 40px; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .hide-sm { display: none; }
    .stats-3 { grid-template-columns: 1fr; }
    .timer-what { display: none; }
    .details { grid-template-columns: 1fr; gap: 2px; }
    .details dd { margin-bottom: 10px; }
    .filters input[type="search"] { min-width: 0; width: 100%; }
}

/* ---------- Audit trail ---------- */
.audit-history { margin-top: 18px; }
.audit-line { margin: 0 0 4px; }
form .audit-line { margin: 18px 0 0; }
.audit-history details { margin-top: 8px; }
.audit-history summary { cursor: pointer; }
.audit-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.audit-list li { padding-left: 12px; border-left: 3px solid var(--border); }
.audit-changes { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.audit-changes li { padding: 0; border: 0; margin: 2px 0; }
.audit-old { color: #9a5b5b; text-decoration: line-through; text-decoration-color: rgba(154, 91, 91, .45); }
.audit-new { color: #2f6317; }
.audit-table td { vertical-align: top; }

/* ---------- Sortable columns ---------- */
.table th a.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.table th a.sort-link:hover { text-decoration: underline; }
.sort-arrow { display: inline-block; width: 10px; font-size: 10px; opacity: .35; }
.sort-link.active .sort-arrow { opacity: 1; }
.filters select[name="sort"], .filters select[name="year"] { max-width: 220px; }

.status-admin { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.status-admin select { width: auto; }
/* ---------- Long text: counter and restore banner ---------- */
.field-counter { margin-top: 4px; font-size: 12px; color: #8b8c91; text-align: right; font-variant-numeric: tabular-nums; }
.field-counter.near { color: #b7791f; }
.field-counter.over { color: #c53030; font-weight: 600; }
.draft-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }

/* ---------- Proposal steps ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 6px 4px; list-style: none; margin: 0 0 18px; padding: 0; counter-reset: none; }
.steps li { display: flex; }
.steps .step-link { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 999px; background: #fff;
    border: 1px solid var(--border); color: #6b6c72; text-decoration: none; font-size: 13px; }
.steps a.step-link:hover { border-color: var(--indigo); color: var(--indigo-dark); }
.steps .step-no { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
    background: #eceef3; color: #6b6c72; font-size: 12px; font-weight: 600; }
.steps li.done .step-no { background: #6FBE44; color: #fff; }
.steps li.current .step-link { background: var(--indigo); border-color: var(--indigo); color: #fff; font-weight: 600; }
.steps li.current .step-no { background: #fff; color: var(--indigo-dark); }
.tips { margin: 0 0 12px; padding-left: 20px; }
.tips li { margin: 4px 0; }

/* ---------- Help panel (slides in from the right) ---------- */
.help-button { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: #fff; color: var(--indigo-dark);
    font-family: inherit; font-size: 16px; font-weight: 600; line-height: 1; cursor: pointer; }
.help-button:hover, .help-button:focus-visible { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.help-overlay { position: fixed; inset: 0; background: rgba(30, 32, 40, .35); opacity: 0; transition: opacity .25s ease; z-index: 90; }
.help-overlay.is-open { opacity: 1; }
.help-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: #fff; z-index: 91; display: flex; flex-direction: column;
    box-shadow: -8px 0 28px rgba(0, 0, 0, .15); transform: translateX(100%); transition: transform .25s ease; outline: none; }
.help-panel[hidden], .help-overlay[hidden] { display: none; }
.help-panel.is-open { transform: translateX(0); }
.help-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.help-head h2 { font-size: 18px; margin: 0; }
.help-close { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--grey); padding: 0 4px; }
.help-close:hover { color: var(--ink); }
.help-content { flex: 1; overflow-y: auto; padding: 14px 20px 28px; }
.help-search input { width: 100%; margin-bottom: 12px; }
.help-topic { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.help-topic[hidden] { display: none; }
.help-topic.is-current { border-color: var(--indigo); }
.help-topic summary { cursor: pointer; padding: 11px 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; list-style: none; }
.help-topic summary::-webkit-details-marker { display: none; }
.help-topic summary::after { content: '+'; color: var(--grey); font-weight: 400; margin-left: auto; padding-left: 8px; }
.help-topic[open] summary::after { content: '\2212'; }
.help-badge { background: var(--indigo-soft); color: var(--indigo-dark); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.help-body { padding: 0 14px 12px; font-size: 14px; line-height: 1.55; }
.help-body h4 { margin: 14px 0 4px; font-size: 14px; }
.help-body p { margin: 8px 0; }
.help-body ul, .help-body ol { margin: 6px 0 8px; padding-left: 20px; }
.help-body li { margin: 4px 0; }
.help-body code { background: var(--indigo-soft); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.help-tip { background: var(--indigo-soft); border-left: 3px solid var(--indigo); padding: 8px 10px; border-radius: 4px; }
body.help-open { overflow: hidden; }
@media print { .help-button, .help-panel, .help-overlay { display: none !important; } }

/* ---------- Check boxes in a group (e.g. service types) ---------- */
.check-group { border: 0; padding: 0; margin: 4px 0 0; min-width: 0; }
.check-group legend { font-size: 13px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 400; }
.check:hover { border-color: var(--indigo); }
.check input { width: auto; margin: 0; flex: none; }
.check:has(input:checked) { border-color: var(--indigo); background: var(--indigo-soft); }

/* ---------- Quick add (+ Add company / + Add contact) ---------- */
.quick-add { align-self: flex-start; background: none; border: 0; padding: 4px 0 0; margin: 0; color: var(--indigo); font: inherit; font-size: 13px; cursor: pointer; }
.quick-add:hover, .quick-add:focus-visible { color: var(--indigo-dark); text-decoration: underline; }
.swal2-container .quick-html { text-align: left; margin: 8px 0 0; padding: 0 4px; overflow: visible; }
.quick-html .field { margin-bottom: 12px; }
.quick-html label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.quick-html input, .quick-html select { width: 100%; box-sizing: border-box; }
.quick-html .form-grid { gap: 0 12px; }
.quick-html .field-error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.quick-html [aria-invalid="true"] { border-color: var(--danger); }

/* ---------- Tax ---------- */
.tax-year { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tax-year label { font-weight: 600; margin: 0; }
.tax-year select { width: auto; min-width: 120px; }
.tax-period { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tax-period .field { margin: 0; min-width: 240px; }
.table tr.is-selected { background: var(--indigo-soft); }
.table tfoot th { border-top: 2px solid var(--border); }

/* ---------- Email ---------- */
.email-signature { width: 100%; height: 260px; border: 1px solid var(--border); border-radius: 8px; background: #fff; resize: vertical; }
.check-single { grid-template-columns: 1fr; }
.due-card { border-top: 3px solid var(--danger); margin-bottom: 18px; }
.due-card h2 { display: flex; align-items: center; gap: 8px; }
.email-history { list-style: none; margin: 0; padding: 0; }
.email-history li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.email-history li:last-child { border-bottom: 0; }
.email-history .is-failed { color: var(--danger); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
textarea.code { font-family: Consolas, Menlo, monospace; font-size: 13px; }
.code-block { background: #f1f2f6; border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 13px; }
.sig-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.tpl-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.tpl-box summary { cursor: pointer; }
.tpl-box .form-grid { margin-top: 12px; }

/* ---------- Deal types (investment / charity) ---------- */
.deal-kind { font-weight: 600; white-space: nowrap; }
.deal-kind-investment { background: #e8f0fb; color: #27508f; }
.deal-kind-charity { background: #fbeaf3; color: #9b2f68; }
.deal-card-nonsale { border-style: dashed; }
.kind-card { margin-bottom: 18px; }
.kind-figures { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 6px; }
.kind-figure { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.kind-figure strong { font-size: 18px; }
.deal-card .deal-kind { align-self: flex-start; }
.alert-warning { background: #fff6dd; color: #7a5200; }
.code-block.trace { max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12px; }
