:root {
    --ink: #1f2933;
    --muted: #64748b;
    --line: #d8dee8;
    --panel: #ffffff;
    --soft: #eef6f8;
    --primary: #0f6b7a;
    --primary-dark: #094856;
    --accent: #b7791f;
    --danger: #a33a2a;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #f4f7fa; color: var(--ink); }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
.app-frame { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #102a33; color: #fff; padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.brand { color: #fff; font-weight: 800; font-size: 20px; display: flex; gap: 10px; align-items: center; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--primary); color: #fff; font-weight: 900; }
.nav-list { display: grid; gap: 6px; }
.nav-list a { color: #dbeafe; padding: 10px 12px; border-radius: 8px; }
.nav-list a:hover { background: rgba(255,255,255,.1); }
.app-version { margin-top: auto; color: #aac6cf; font-size: 13px; }
.topbar { height: 70px; display: flex; justify-content: space-between; align-items: center; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar span { display: block; color: var(--muted); font-size: 13px; text-transform: capitalize; }
.content { padding: 28px; }
.page-heading, .record-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-heading p, .record-header p, .muted { color: var(--muted); }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 10px 14px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ghost { background: transparent; }
.grid, .metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.card, .metric, .panel, .auth-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.metric span { color: var(--muted); display: block; }
.metric strong { font-size: 26px; display: block; margin-top: 8px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.pill, .tag-pill { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; background: var(--soft); color: var(--primary-dark); padding: 0 10px; font-size: 13px; font-weight: 800; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.workspace-main, .workspace-side { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.workspace-side { display: grid; gap: 14px; background: transparent; border: 0; padding: 0; }
.side-form, .section { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.section-heading { display: flex; justify-content: space-between; gap: 12px; margin: 22px 0 10px; align-items: center; }
.section-heading:first-child { margin-top: 0; }
.record-editor, .data-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 20px; }
label { display: grid; gap: 7px; font-weight: 800; font-size: 14px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; font: inherit; background: #fff; }
textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; }
.list { display: grid; gap: 8px; }
.row-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.row-card { position: relative; padding-right: 96px; }
.row-card span { color: var(--muted); display: block; font-size: 13px; margin-top: 4px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--primary); font-weight: 900; cursor: pointer; display: inline-grid; place-items: center; }
.row-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.row-actions .icon-btn { position: static; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.tabs a { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; color: var(--ink); font-weight: 800; }
.tab-panel { display: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.tab-panel:target { display: block; }
.tab-panel:first-of-type { display: block; }
.tabs:has(+ #tab-details:target) ~ .tab-panel:first-of-type,
.tabs:has(~ #tab-comms:target) ~ #tab-details,
.tabs:has(~ #tab-addresses:target) ~ #tab-details,
.tabs:has(~ #tab-relationships:target) ~ #tab-details,
.tabs:has(~ #tab-activities:target) ~ #tab-details,
.tabs:has(~ #tab-notes:target) ~ #tab-details,
.tabs:has(~ #tab-audit:target) ~ #tab-details { display: none; }
.compact { margin-bottom: 0; }
dialog.modal { border: 1px solid var(--line); border-radius: 8px; width: min(620px, calc(100vw - 32px)); padding: 20px; }
dialog.modal::backdrop { background: rgba(16,42,51,.35); }
.auth-page { min-height: 100vh; display: grid; place-items: center; background: #e8f2f4; padding: 24px; }
.auth-shell { width: min(430px, 100%); }
.form-stack { display: grid; gap: 14px; }
.notice { background: #e8f5ee; color: #226344; padding: 12px; border-radius: 8px; margin-bottom: 14px; }
.alert { background: #fdeeee; color: var(--danger); padding: 12px; border-radius: 8px; margin-bottom: 14px; }
.banner { position: relative; padding-right: 36px; }
.banner-close { position: absolute; top: 8px; right: 8px; background: transparent; border: none; font-size: 18px; line-height: 1; cursor: pointer; color: inherit; opacity: 0.6; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; }
.banner-close:hover { opacity: 1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pipeline-board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; }
.pipeline-column { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-height: 240px; }
.pipeline-column h2 { font-size: 16px; }
.autosave-status { grid-column: 1 / -1; color: var(--muted); min-height: 20px; font-weight: 800; }
.autosave-status[data-state="saved"] { color: #226344; }
.autosave-status[data-state="error"] { color: var(--danger); }
@media (max-width: 900px) {
    .app-frame, .workspace-grid { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .grid, .metric-grid, .record-editor, .data-form { grid-template-columns: 1fr; }
}
