/* ---------------------------------------------------------------------------
   Keel demo stylesheet.

   Plain CSS on purpose -- no build step, no preprocessor, no node_modules.
   Upload it over FTP and it works. Custom properties give you theming
   without a compiler.
   --------------------------------------------------------------------------- */

:root {
    --bg:          #f6f7f9;
    --surface:     #ffffff;
    --border:      #e3e5e8;
    --text:        #1a1d21;
    --muted:       #6b7280;
    --primary:     #2563eb;
    --primary-ink: #ffffff;
    --danger:      #dc2626;
    --success:     #059669;
    --warn:        #d97706;
    --radius:      8px;
    --shadow:      0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:      #16181c;
        --surface: #1f2228;
        --border:  #2d3138;
        --text:    #e7e9ea;
        --muted:   #9aa4b2;
        --shadow:  none;
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.shell { width: 100%; margin: 0 auto; padding: 0 20px; }
/* Forms and reading pages keep a comfortable measure; the dashboard uses the whole screen. */
.shell-narrow { max-width: 1100px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 1rem; letter-spacing: -0.005em; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num   { text-align: right; font-variant-numeric: tabular-nums; }
.required { color: var(--danger); }
.inline { display: inline; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Top bar ------------------------------------------------------------ */

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }

.topbar-inner {
    display: flex; align-items: center; gap: 2rem;
    height: 60px;
}

.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }

.nav { display: flex; gap: 1.25rem; flex: 1; }
.nav a { color: var(--muted); font-weight: 500; padding: .25rem 0; }
.nav a:hover, .nav a.active { color: var(--text); text-decoration: none; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--primary); }

.topbar-user { display: flex; align-items: center; gap: .75rem; }

.avatar {
    display: grid; place-items: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: var(--primary-ink);
    font-size: .75rem; font-weight: 700;
}

.link {
    background: none; border: 0; padding: 0;
    color: var(--muted); font: inherit; cursor: pointer;
}
.link:hover { color: var(--text); text-decoration: underline; }

/* --- Page --------------------------------------------------------------- */

main.shell { padding-top: 2rem; padding-bottom: 3rem; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }

@media (max-width: 820px) {
    .columns { grid-template-columns: 1fr; }
    .topbar-inner { gap: 1rem; }
    .nav { gap: .75rem; font-size: .9rem; }
}

/* --- Stats -------------------------------------------------------------- */

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}

/* The dashboard's six figures sit on ONE row on a desk; three then two per
   row as the screen narrows, never a horizontal scroll. */
.stat-grid-row { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; }
.stat-grid-row .stat { padding: .9rem 1rem; }
.stat-grid-row .stat-value { font-size: 1.35rem; }
.stat-grid-row .stat-label { font-size: .7rem; }

/* --- The dashboard — sizes copied from the practice's previous dashboard --- */
.dash { --navy: #0869AE; --dborder: #dfe3e8; --dbg: #f6f7f9; --dmuted: #6b7280; --serif: "DM Serif Display", Georgia, "Times New Roman", serif;
        font-size: 13px; padding: 20px 0; }
.dash-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.dash-title h1 { font-family: var(--serif); color: var(--navy); margin: 0; font-size: 1.6rem; font-weight: 700; }
.dash .stats { padding: 14px 24px; display: flex; gap: 14px; flex-wrap: wrap; }
.dash .stat-card { background: var(--surface); border-radius: 10px; padding: 12px 18px; border: 1px solid var(--dborder); min-width: 130px; box-shadow: none; }
.dash .stat-card .label { font-size: 10px; color: var(--dmuted); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.dash .stat-card .val { font-size: 22px; font-weight: 700; font-family: var(--serif); margin-top: 2px; }
.dash .stat-card .sub { font-size: 10px; color: var(--dmuted); margin-top: 2px; }
.dash .stat-card .sub.delta-up { color: #27ae60; }
.dash .stat-card .sub.delta-down { color: #e74c3c; }
.dash-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-grid2.mt8 { margin-top: 8px; }
.dash-grid2.mt14 { margin-top: 14px; }
.dash-grid2.mt16 { margin-top: 16px; }
@media (max-width: 900px) { .dash-grid2 { grid-template-columns: 1fr; } }
.dcard { background: var(--surface); border: 1px solid var(--dborder); border-radius: 10px; padding: 16px; min-width: 0; }
.dcard-title { font-weight: 700; color: var(--navy); margin-bottom: 10px; }
.dcard-title .count { color: var(--dmuted); font-weight: 400; font-size: 12px; }
.dcard-title a.small { font-weight: 400; font-size: 11px; margin-left: 6px; }
.dcard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.dcard-head .dcard-title { margin-bottom: 0; }

/* Stage cards: a 132px donut (outer 58, hole 30) beside a legend of up to 360px. */
.stage-body { display: flex; gap: 28px; align-items: center; justify-content: center; flex-wrap: wrap; }
.stage-body svg { flex: none; }
.stage-legend { flex: 0 1 360px; min-width: 240px; }
.stage-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; }
.stage-row .col-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; display: inline-block; }
.stage-row .lbl { flex: 1; }
.stage-row .n { font-weight: 700; min-width: 18px; text-align: right; }
.stage-row .pct { color: var(--dmuted); min-width: 36px; text-align: right; }
.stage-row .amt { color: var(--dmuted); min-width: 74px; text-align: right; }
.stage-total { display: flex; align-items: center; gap: 8px; padding: 7px 0 0; margin-top: 3px; border-top: 2px solid var(--dborder); font-size: 12px; font-weight: 700; }
.stage-total .col-dot { width: 11px; height: 11px; flex: none; display: inline-block; }
.stage-total .lbl { flex: 1; color: var(--navy); }
.stage-total .n { color: var(--navy); min-width: 18px; text-align: right; }
.stage-total .pct { color: var(--dmuted); min-width: 36px; text-align: right; }
.stage-total .amt { color: var(--navy); min-width: 74px; text-align: right; }
.donut-num { font-size: 21px; font-weight: 700; fill: var(--navy); }
.donut-cap { font-size: 9px; letter-spacing: .5px; fill: var(--dmuted); }

/* Pie cards: a 150px donut (outer 70, hole 34) beside a legend. */
.pie-body { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.pie-body svg { flex: none; }
.pie-legend { flex: 1; min-width: 130px; }
.pie-row { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0; }
.pie-row .sw { width: 11px; height: 11px; border-radius: 2px; flex: none; display: inline-block; }
.pie-row .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-row .n { font-weight: 600; color: var(--navy); }
.pie-row .pct { color: var(--dmuted); min-width: 32px; text-align: right; }

/* Tasks & Schedule */
.ts-head { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; margin-bottom: 8px; }
.ts-head .ts-title { font-weight: 700; color: var(--navy); font-size: 15px; }
.person-filter { display: flex; align-items: center; gap: 8px; }
.person-filter .lbl { font-size: 10px; color: var(--dmuted); text-transform: uppercase; letter-spacing: .6px; }
.person-filter select { padding: 5px 8px; border: 1.5px solid var(--dborder); border-radius: 6px; font-size: 12px; background: var(--surface); }
.dash .btn-sm { font-size: 11px; padding: 4px 10px; border-radius: 8px; }
.dash .btn-navy { background: var(--navy); color: #fff; border: none; font-weight: 600; cursor: pointer; }
.dash .btn-navy:hover { background: #064a7a; }
.task-list { max-height: 340px; overflow-y: auto; }
.task-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--dbg); font-size: 12px; }
.task-row .ttl { flex: 1; }
.task-row .ttl strong { font-weight: 600; }
.task-row .ctx { color: var(--dmuted); }
.task-assignee { font-size: 10px; color: var(--navy); background: rgba(8, 105, 174, .08); padding: 1px 6px; border-radius: 10px; white-space: nowrap; }
.task-row .due { font-size: 11px; color: var(--dmuted); min-width: 50px; text-align: right; }
.task-row .due.overdue { color: #e74c3c; }
.chk { width: 13px; height: 13px; border: 1.5px solid #8a94a6; border-radius: 3px; background: var(--surface); padding: 0; cursor: pointer; flex: none; }
.chk:hover { border-color: #27ae60; background: rgba(39, 174, 96, .12); }
.up-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-top: 1px solid var(--dbg); font-size: 12px; }
.up-row .when { min-width: 50px; font-size: 11px; color: var(--navy); font-weight: 600; }
.up-row .ttl { flex: 1; }
.up-row .ctx { color: var(--dmuted); }

/* The dashboard's month calendar: the day boxes, then the month's list in full. */
.dash-stack { display: grid; gap: 16px; }
.cal-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.cal-month { font-weight: 700; color: var(--navy); min-width: 120px; text-align: center; }
.cal-grid { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 6px; }
.cal-grid th { font-size: 11px; font-weight: 600; color: var(--dmuted); text-transform: uppercase; letter-spacing: .04em; padding: 4px 6px; text-align: left; }
.cal-day { height: 92px; vertical-align: top; border: 1px solid var(--dborder); padding: 4px 5px; position: relative; overflow: hidden; }
.cal-weekend { background: color-mix(in srgb, var(--navy) 3%, transparent); }
.cal-out { background: color-mix(in srgb, var(--dmuted) 8%, transparent); }
.cal-out .cal-date, .cal-past .cal-date { color: var(--dmuted); }
.cal-date { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.cal-today { box-shadow: inset 0 0 0 2px var(--navy); }
.cal-today .cal-date { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 10px; background: var(--navy); color: #fff; text-align: center; }
.cal-chip { display: block; font-size: 11px; line-height: 1.35; padding: 2px 5px; margin-top: 2px; border-radius: 4px; color: inherit; text-decoration: none; }
.cal-chip:hover { filter: brightness(.95); }
.cal-chip-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-weight: 600; }
.cal-chip-where { display: block; font-size: 10px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip-event { background: color-mix(in srgb, #2563eb 12%, transparent); color: #1d4ed8; }
.cal-chip-task { background: #fef3c7; color: #92400e; }
.cal-chip-overdue { background: color-mix(in srgb, #dc2626 14%, transparent); color: #b91c1c; }
.cal-more { font-size: 10px; color: var(--dmuted); margin-top: 2px; }
.cal-count { display: none; }
.cal-agenda { margin-top: 12px; }
.cal-agenda-title { font-size: 12px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.cal-agenda .up-row .when { min-width: 78px; }
.cal-past-row { opacity: .6; }
.cal-entry { border-top: 1px solid var(--dbg); padding-bottom: 6px; scroll-margin-top: 80px; }
.cal-entry .up-row { border-top: 0; }
.cal-entry:target { background: #fffbeb; }
.cal-details { display: grid; grid-template-columns: 70px 1fr; gap: 2px 10px; margin: 0 0 0 86px; font-size: 12px; }
.cal-details dt { color: var(--dmuted); }
.cal-details dd { margin: 0; overflow-wrap: anywhere; }
.cal-notes { white-space: pre-line; }
.cal-overdue-text { color: #e74c3c; }
@media (max-width: 640px) {
    .cal-day { height: 52px; padding: 3px; }
    .cal-chip, .cal-more { display: none; }
    .cal-count { display: inline-block; position: absolute; right: 4px; bottom: 4px; font-size: 10px; font-weight: 700; color: #fff; background: var(--navy); border-radius: 8px; min-width: 16px; text-align: center; padding: 0 4px; }
    .cal-month { min-width: 0; }
    .cal-details { margin-left: 0; grid-template-columns: 62px 1fr; }
}
.dash .empty { font-size: 12px; color: var(--dmuted); }
details.add-form { position: relative; }
details.add-form summary { list-style: none; cursor: pointer; display: inline-block; }
details.add-form summary::-webkit-details-marker { display: none; }
.add-form-body { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; background: #f8f9fb; border: 1px solid var(--dborder); border-radius: 8px; margin: 8px 0; position: absolute; right: 0; top: 2rem; z-index: 5; width: 24rem; max-width: 90vw; box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.add-form-body input, .add-form-body select { flex: 1; min-width: 130px; padding: 6px 9px; border: 1.5px solid var(--dborder); border-radius: 6px; font-size: 12px; }

/* Accounting section */
.dash-section { font-family: var(--serif); color: var(--navy); font-size: 17px; font-weight: 700; margin: 24px 0 2px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th { text-align: left; padding: 10px 14px; font-weight: 700; font-size: 10px; color: var(--dmuted); letter-spacing: .04em; text-transform: uppercase; background: #f8f9fb; border-bottom: 1px solid var(--dborder); }
.admin-table td { padding: 8px 14px; border-bottom: 1px solid var(--dbg); vertical-align: top; }
.admin-table td.num, .admin-table th.num { text-align: right; white-space: nowrap; }
.admin-table td.overdue { color: #e74c3c; font-weight: 600; }
.admin-table td .muted { display: block; font-size: 11px; }

.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem;
}

.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; }
.stat-warn .stat-value { color: var(--warn); }
.stat-note { color: var(--muted); font-size: .8rem; }

/* --- Form grids: two columns on a desk, one on a phone -------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem 1rem; margin-bottom: 1.5rem; }
.form-grid .field-wide { grid-column: 1 / -1; }
.stat-note.delta-up   { color: var(--success); }
.stat-note.delta-down { color: var(--danger); }

/* --- Tables ------------------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; font-size: .925rem; }

.table th {
    text-align: left; padding: .6rem .5rem;
    border-bottom: 2px solid var(--border);
    color: var(--muted); font-size: .8rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em;
}

.table th a { color: inherit; }
.table td { padding: .7rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }

/* --- Badges ------------------------------------------------------------- */

.badge {
    display: inline-block; padding: .15rem .55rem;
    border-radius: 999px; font-size: .75rem; font-weight: 600;
    background: color-mix(in srgb, var(--muted) 15%, transparent);
    color: var(--muted);
}

.badge-lead      { background: color-mix(in srgb, #64748b 18%, transparent); color: #64748b; }
.badge-qualified { background: color-mix(in srgb, #2563eb 18%, transparent); color: #2563eb; }
.badge-proposal  { background: color-mix(in srgb, #d97706 20%, transparent); color: #d97706; }
.badge-won       { background: color-mix(in srgb, #059669 18%, transparent); color: #059669; }
.badge-problem   { background: color-mix(in srgb, #b42318 15%, transparent); color: #b42318; }
.badge-lost      { background: color-mix(in srgb, #dc2626 16%, transparent); color: #dc2626; }
.badge-new-device  { background: #fde68a; color: #92400e; }
.badge-new-network { background: color-mix(in srgb, #2563eb 12%, transparent); color: #1d4ed8; font-weight: 500; }

/* The sign-in log: a sign-in from a device the person had never used stands out. */
.sign-in-log tr.sign-in-new-device td { background: #fffbeb; }
.sign-in-log td.nowrap { white-space: nowrap; }
.sign-in-log td, .users-table .last-device { font-size: .9rem; }

/* --- Forms -------------------------------------------------------------- */

.field { margin-bottom: 1.1rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: .35rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="tel"], input[type="number"],
select, textarea {
    width: 100%; padding: .55rem .7rem;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text);
    font: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
    outline-offset: 1px;
    border-color: var(--primary);
}

input[aria-invalid="true"] { border-color: var(--danger); }

textarea { resize: vertical; min-height: 80px; }

.hint { margin: .35rem 0 0; font-size: .8rem; color: var(--muted); }
.field-error { margin: .35rem 0 0; font-size: .825rem; color: var(--danger); }

.checkbox { display: inline-flex; align-items: center; gap: .45rem; font-weight: 400; margin: 0; }
.checkbox input { width: auto; }

.field-inline {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}

.form-actions { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

.filters {
    display: flex; gap: .75rem; align-items: center; flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.filters input[type="search"] { flex: 1; min-width: 200px; }
.filters select { width: auto; }

/* --- Buttons ------------------------------------------------------------ */

.btn {
    display: inline-block; padding: .55rem 1.1rem;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--primary); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-block { display: block; width: 100%; text-align: center; }

/* --- Alerts ------------------------------------------------------------- */

.alert {
    padding: .8rem 1rem; border-radius: var(--radius);
    border: 1px solid; margin-bottom: 1.25rem; font-size: .925rem;
}
.alert ul { margin: .5rem 0 0; padding-left: 1.25rem; }

.alert-success {
    background: color-mix(in srgb, var(--success) 10%, transparent);
    border-color: color-mix(in srgb, var(--success) 35%, transparent);
    color: var(--success);
}

.alert-warn { background: color-mix(in srgb, #f59e0b 16%, transparent); border-color: #f59e0b; color: #7c4a03; }
.alert-error {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    color: var(--danger);
}

/* --- Auth --------------------------------------------------------------- */

.auth-card {
    max-width: 380px; margin: 4rem auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 2rem;
}
.auth-card h1 { margin-bottom: 1.5rem; font-size: 1.35rem; }

/* --- Detail lists, notes ------------------------------------------------ */

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1.25rem; margin: 0; }
.detail-list dt { color: var(--muted); font-size: .85rem; font-weight: 600; }
.detail-list dd { margin: 0; }

.note-form { margin-bottom: 1.5rem; }
.note-form .btn { margin-top: .6rem; }

.note { padding: .85rem 0; border-bottom: 1px solid var(--border); }
.note:last-child { border-bottom: 0; }
.note header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .3rem; }
.note p { margin: 0; font-size: .925rem; }

.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.danger-zone p { margin: .2rem 0 0; }

/* --- Pagination --------------------------------------------------------- */

.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: .3rem; }
.pagination a, .pagination span {
    padding: .3rem .6rem; border-radius: 5px; font-size: .9rem;
}
.pagination .current { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.pagination .disabled, .pagination .gap { color: var(--muted); }

/* --- Empty / error states ----------------------------------------------- */

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

.error-page { text-align: center; padding: 4rem 1rem; }
.error-page .error-code { font-size: 4rem; font-weight: 700; margin: 0; opacity: .3; letter-spacing: -0.03em; }
.error-page h1 { margin: .5rem 0 .75rem; }
.error-page .btn { margin-top: 1.5rem; }

/* --- Footer ------------------------------------------------------------- */

.footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 0; margin-top: 2rem;
    font-size: .85rem; color: var(--muted);
}
.footer .shell { display: flex; justify-content: space-between; gap: 1rem; }

/* --- Mail ---------------------------------------------------------------- */
.mail-filter { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.mail-filter input[type="search"] { min-width: 16rem; }
.mail-list tr.unread td { font-weight: 600; }
.mail-list td.nowrap { white-space: nowrap; }
.mail-list td .muted { display: block; font-size: .8rem; font-weight: 400; }
.mail-message h1 { font-size: 1.25rem; }
.mail-meta { margin: .5rem 0 1rem; font-size: .9rem; }
.mail-meta th { text-align: left; color: var(--muted); font-weight: 500; padding-right: 1rem; width: 6rem; vertical-align: top; }
.mail-attachments { list-style: none; padding: 0; margin: 0 0 1rem; }
.mail-body { white-space: pre-wrap; word-break: break-word; font: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.share-list { list-style: none; padding: 0; }
.share-list li { display: flex; gap: .75rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.share-list .muted { flex: 1; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.summaries { margin: 1rem 0; }
.summaries-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.summaries-head h2 { margin: 0; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: .5rem; }
@media (max-width: 900px) { .summary-grid { grid-template-columns: 1fr; } }
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .9rem; min-width: 0; }
.summary-card h3 { margin: 0 0 .5rem; font-size: .95rem; }
.summary-card h3 .muted { font-weight: 400; font-size: .75rem; }
.summary-text { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: .9rem; margin: 0; }
.summary-failed { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.mail-list .snippet { display: block; font-size: .8rem; font-weight: 400; }
.alias-person { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.alias-person h3 { margin: 0 0 .5rem; font-size: 1rem; }
.alias-person h3 .muted { font-weight: 400; font-size: .85rem; }
.intel-import { margin-bottom: 1rem; }
.intel-import .inline-form { flex-wrap: wrap; }

/* --- Intel pages ----------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1150px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } }
.panel-title { margin: 0 0 .6rem; font-size: 1rem; }
.panel-title .small { font-weight: 400; margin-left: .4rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: 0 0 1rem; }
.tabs a { color: var(--muted); text-decoration: none; padding-bottom: .2rem; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--navy, #0869AE); border-bottom-color: var(--navy, #0869AE); font-weight: 600; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: flex; align-items: center; gap: .6rem; font-size: .85rem; padding: .15rem 0; }
.bars .bar-label { width: 64px; flex: none; color: var(--muted); }
.bars .bar { flex: 1; height: 10px; background: color-mix(in srgb, var(--muted) 15%, transparent); border-radius: 5px; overflow: hidden; }
.bars .bar-fill { display: block; height: 100%; background: #f59e0b; border-radius: 5px; }
.bars .bar-count { width: 28px; text-align: right; font-weight: 600; }
table.compact td { padding: .3rem .4rem; font-size: .85rem; }
.stat.tone-reach   { border-left: 4px solid #0869AE; }
.stat.tone-reply   { border-left: 4px solid #27ae60; }
.stat.tone-project { border-left: 4px solid #8b5cf6; }
.stat.tone-lead    { border-left: 4px solid #f59e0b; }
.pie-row .lbl a { color: inherit; }
.pie-row .lbl a:hover { text-decoration: underline; }
.dcard-sub { color: var(--dmuted, var(--muted)); font-size: 11px; margin: -4px 0 8px; }

/* --- Phone number in three boxes ------------------------------------------- */
.phone-boxes { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
.phone-boxes legend { padding: 0; margin-bottom: .35rem; font-weight: 600; font-size: .9rem; }
.phone-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.phone-mark { color: var(--muted); font-size: 1.05rem; }
input.phone-box { text-align: center; letter-spacing: .12em; font-variant-numeric: tabular-nums; font-size: 1.05rem; padding-left: .25rem; padding-right: .25rem; }
input.phone-box-3 { width: 4.6rem; }
input.phone-box-4 { width: 5.6rem; }

/* --- "No code?" help under a code box -------------------------------------- */
.code-help { margin-top: 1.25rem; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.code-help p { margin: 0 0 .6rem; font-size: .9rem; }
.code-help form.inline { display: inline-block; margin-right: .5rem; }
input.code-box { width: 11rem; text-align: center; letter-spacing: .25em; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* --- Projects board -------------------------------------------------------- */
.new-project { margin-bottom: 1rem; }
.new-project > summary { list-style: none; cursor: pointer; display: inline-block; }
.new-project > summary::-webkit-details-marker { display: none; }
.new-project[open] > summary { margin-bottom: 1rem; }
/* Closed, the two buttons (New project, New quote) sit side by side; the one that is opened takes the full width. */
.new-project:not([open]) { display: inline-block; vertical-align: top; margin-right: .5rem; }
.board { display: grid; grid-template-columns: repeat(7, minmax(170px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: .5rem; margin-bottom: 1.5rem; align-items: start; }
.board-col { background: color-mix(in srgb, var(--muted) 8%, transparent); border-radius: 10px; padding: 10px; min-width: 0; border-top: 3px solid #94a3b8; }
.board-col.stage-planning { border-top-color: #94a3b8; }
.board-col.stage-fieldWork { border-top-color: #f59e0b; }
.board-col.stage-draftingReport { border-top-color: #0869AE; }
.board-col.stage-reviewQa { border-top-color: #8b5cf6; }
.board-col.stage-delivered { border-top-color: #27ae60; }
.board-col.stage-revisionsRequested { border-top-color: #e74c3c; }
.board-col.stage-completed { border-top-color: #1a1a2e; }
.board-head { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .5rem; }
.board-head h3 { margin: 0; font-size: .9rem; }
.board-head .count { font-weight: 700; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .5rem; font-size: .85rem; box-shadow: var(--shadow); }
.pcard-title strong { font-size: .95rem; }
.pcard-title span { color: var(--muted); margin-left: .25rem; }
.pcard-client { margin-top: .1rem; }
.pcard-meta { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.pcard-address { color: var(--muted); font-size: .78rem; margin-top: .15rem; overflow-wrap: anywhere; }
.pcard-site { margin-top: .4rem; font-size: .78rem; display: flex; flex-wrap: wrap; gap: .25rem .4rem; align-items: center; word-break: break-word; }
.pcard-move { margin-top: .5rem; display: flex; gap: .3rem; }
.pcard-written { margin-top: .4rem; font-size: .78rem; display: flex; flex-wrap: wrap; gap: .25rem .4rem; align-items: center; }
.pcard-written form, .pcard-written .btn { max-width: 100%; }
.pcard-written .btn { white-space: normal; text-align: left; }
.pcard-move select { flex: 1; min-width: 0; padding: .25rem .35rem; font-size: .8rem; }
input.input-sm { width: 13rem; padding: .3rem .5rem; font-size: .85rem; }
.field-with-button { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; }
.field-with-button input, .field-with-button select { flex: 1; min-width: 9rem; }
.field-with-button .btn { white-space: nowrap; }
/* The answer of "Check the address", above the New project form's address boxes. */
.address-check { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; background: color-mix(in srgb, var(--muted) 6%, transparent); font-size: .925rem; }
.address-check p { margin: 0 0 .6rem; }
.address-check > :last-child { margin-bottom: 0; }
.address-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem 1.5rem; margin-bottom: .6rem; overflow-wrap: anywhere; }
.address-candidates { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.address-candidates .btn { white-space: normal; text-align: left; }
.address-map { display: block; width: 100%; height: 320px; border: 0; border-radius: var(--radius); }
.pcard-instance { margin-top: .45rem; font-size: .78rem; border-top: 1px dashed var(--border); padding-top: .35rem; }
.pcard-instance summary { cursor: pointer; color: var(--muted); }
.pcard-instance dl { margin: .35rem 0; }
.pcard-instance dt { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; margin-top: .35rem; }
.pcard-instance dd { margin: 0; overflow-wrap: anywhere; }
.pcard-instance code { font-size: .78rem; }
.pcard-instance .pcard-tool { border-top: 1px dotted var(--border); padding-top: .2rem; }
/* "How will the report be written?" is asked for an electrical planning report only. */
form:has(#serviceCategory option[value="depreciationReport"]:checked) .field-written-in { display: none; }

/* --- Project files --------------------------------------------------------- */
.crumbs { margin: 0 0 .75rem; font-size: .95rem; }
.files-table { width: 100%; }
.files-table td:first-child { width: 60%; word-break: break-word; }
.file-folder { font-weight: 600; }
.file-folder::before { content: "▸ "; color: var(--muted); }
.files-actions { margin-top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.files-actions .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.files-actions .inline-form label { flex-basis: 100%; margin: 0; }
.files-actions .inline-form .small { flex-basis: 100%; }
.files-actions input[type="text"] { width: auto; flex: 1; min-width: 12rem; max-width: 24rem; }
.pcard-files { margin-top: .4rem; font-size: .8rem; word-break: break-word; }

/* The Crew box on a project card: who is on it, and putting someone on it. */
.pcard-crew { margin-top: .45rem; font-size: .78rem; border-top: 1px dashed var(--border); padding-top: .35rem; }
.pcard-crew summary { cursor: pointer; color: var(--muted); }
.crew-list { list-style: none; margin: .35rem 0; padding: 0; }
.crew-list li { margin-bottom: .35rem; overflow-wrap: anywhere; }
.crew-list li .small { display: block; }
.crew-form { display: flex; flex-direction: column; gap: .25rem; margin-top: .35rem; }
.crew-form label { margin: 0; font-size: .72rem; color: var(--muted); }
.crew-form select, .crew-form input[type="date"] { width: 100%; font-size: .8rem; }
.crew-form .btn { align-self: flex-start; margin-top: .2rem; }
.crew-form .hint { margin: .2rem 0 0; font-size: .7rem; }

/* The Phones list and the Mileage rates screen. */
.phones-table td, .rates-table td { vertical-align: top; }
.rate-form { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: flex-end; }
.rate-form .field { margin: 0; }
.rate-form input[type="number"] { width: 7rem; }
.rate-form input[type="text"] { min-width: 18rem; }
.rate-form .rate-confirm { flex-basis: 100%; }

/* Field entries from the phone app: the review page, reimbursements and totals. */
.field-kind { margin-bottom: 1.5rem; }
.field-entry { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .75rem 1rem; margin-bottom: .75rem; }
.field-entry-head { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }
.field-entry-body p { margin: .2rem 0; overflow-wrap: anywhere; }
.field-flags { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--warn); font-size: .875rem; }
.field-entry-actions { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--border); }
.field-decision { display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: center; }
.field-decision label { margin: 0; font-weight: 400; font-size: .8rem; color: var(--muted); }
.field-decision input[type="text"] { width: auto; min-width: 10rem; flex: 1; }
.field-trail { margin-top: .5rem; font-size: .875rem; }
.field-trail summary, .field-correct summary { cursor: pointer; color: var(--muted); }
.field-trail ol { margin: .35rem 0 0; padding-left: 1.2rem; }
.field-trail li { overflow-wrap: anywhere; }
.field-correct { margin: -.4rem 0 1rem; font-size: .875rem; }
.field-facts { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; }
.field-facts dd { margin: 0; overflow-wrap: anywhere; }
.field-notes li { margin-bottom: .6rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.field-totals h3 { margin: 0 0 .25rem; font-size: .9rem; }
.field-sites td { overflow-wrap: anywhere; }

/* --- Outreach email ------------------------------------------------------- */
/* Writing one: the wording on the left, what the recipient will get on the right. */
.compose-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; margin-top: 1rem; }
@media (max-width: 900px) { .compose-grid { grid-template-columns: 1fr; } }
.compose-form textarea, .template-form textarea { min-height: 22rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.5; }
.compose-form .form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.compose-about { margin: 0 0 1rem; }
/* The email itself, in a frame that can run nothing and load nothing from outside. */
.email-frame { display: block; width: 100%; height: 640px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.email-subject { margin: 0 0 .6rem; font-size: .925rem; overflow-wrap: anywhere; }
.email-text { margin-top: 1rem; }
.email-text summary { cursor: pointer; font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.placeholder-list { margin: .5rem 0 0; display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; font-size: .85rem; }
.placeholder-list dt { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
.placeholder-list dd { margin: 0; color: var(--muted); }
.placeholder-help summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
/* The Sent emails list. What a remote mail server said is only ever shown as text. */
.sent-emails td { overflow-wrap: anywhere; }
.sent-emails td.nowrap { white-space: nowrap; }
.sent-emails .reason { display: block; font-size: .8rem; color: var(--muted); }
.lead-email { display: block; font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.firm-details { max-width: 44rem; }

/* Firm details: the logo for quotes. */
.firm-logo { margin-top: 16px; }
.firm-logo-preview { max-height: 32px; vertical-align: middle; background: #0869AE; padding: 4px; border-radius: 4px; }
/* Open quotes: the quote column. */
.quote-cell .btn-sm { margin-left: 6px; }
