/* Captura — a working tool for people who spend all day in it.
   Dense, high contrast, obvious focus, no decoration that costs a click. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #d6dae0;
    --border-strong: #aab3bd;
    --text: #16191d;
    --muted: #5b6572;
    --accent: #1f5fa8;
    --accent-text: #ffffff;
    --danger: #a3261f;
    --danger-bg: #fdeceb;
    --ok-bg: #e8f4ec;
    --ok-text: #1c5c33;
    --warn-bg: #fdf4e3;
    --warn-text: #7a5312;
    --sensitive: #7a3ea3;
    --radius: 6px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171b;
        --surface: #1c2026;
        --border: #333a43;
        --border-strong: #4c5661;
        --text: #e8ebee;
        --muted: #9aa5b1;
        --accent: #63a2e8;
        --accent-text: #0d1013;
        --danger: #f0837b;
        --danger-bg: #3a1f1d;
        --ok-bg: #1c3226;
        --ok-text: #8fd6a8;
        --warn-bg: #382c14;
        --warn-text: #e8c47c;
        --sensitive: #c79ae4;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

.sr-only {
    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 ---------------------------------------------------------- */

.top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    font-size: 17px;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
}

.search {
    position: relative;
    flex: 1;
    display: flex;
    gap: 8px;
    max-width: 720px;
}

.search input { flex: 1; }

/* --- Top bar live search --------------------------------------------- */

.omnisearch-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
    overflow: hidden;
}

.omnisearch-hit {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}

.omnisearch-hit:hover,
.omnisearch-hit[aria-selected="true"] {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.omnisearch-label {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.omnisearch-meta {
    margin-left: auto;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.omnisearch-empty {
    margin: 0;
    padding: 14px 12px;
    color: var(--muted);
}

.omnisearch-all {
    display: block;
    padding: 9px 12px;
    font-size: 13px;
    text-align: center;
}

.account {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.account .who { color: var(--muted); font-size: 14px; }

nav.main {
    display: flex;
    gap: 4px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

nav.main a {
    padding: 9px 14px;
    text-decoration: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}

nav.main a:hover { color: var(--text); }

nav.main a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
    border-bottom-color: var(--accent);
}

main { padding: 20px 16px 60px; max-width: 1180px; margin: 0 auto; }

/* --- Blocks ----------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}

.card.narrow { max-width: 460px; margin: 48px auto; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 10px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* --- Messages --------------------------------------------------------- */

.flash, .alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin: 0 0 16px;
    border: 1px solid transparent;
}

.flash-ok    { background: var(--ok-bg);   color: var(--ok-text);   border-color: currentColor; }
.flash-warn  { background: var(--warn-bg); color: var(--warn-text); border-color: currentColor; }
.flash-error,
.alert       { background: var(--danger-bg); color: var(--danger);  border-color: currentColor; }

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

.stack { display: flex; flex-direction: column; gap: 6px; }
.stack > label { margin-top: 10px; font-weight: 600; font-size: 14px; }
.stack > label:first-of-type { margin-top: 0; }

input, select, textarea, button {
    font: inherit;
    color: inherit;
}

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="date"], input[type="number"], select, textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
}

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

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 1px;
}

.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field .help { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }

.field-sensitive > label::after {
    content: " · dato sensible";
    color: var(--sensitive);
    font-weight: 600;
    font-size: 12px;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 18px; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 0 0 18px;
}

legend { font-weight: 600; padding: 0 6px; }

button {
    padding: 8px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

button:hover { border-color: var(--accent); }

button.primary {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
    font-weight: 600;
}

button.danger { color: var(--danger); border-color: var(--danger); }

button.link {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    text-decoration: underline;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

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

table { width: 100%; border-collapse: collapse; }

th, td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

td.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag {
    display: inline-block;
    padding: 1px 7px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.ref { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { padding: 32px; text-align: center; color: var(--muted); }

/* --- Entity picker ---------------------------------------------------- */

.picker { position: relative; }

.picker-results {
    position: absolute;
    z-index: 20;
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    max-height: 260px;
    overflow-y: auto;
    margin-top: 2px;
    box-shadow: 0 6px 18px rgb(0 0 0 / 12%);
}

.picker-results:empty { display: none; }

.picker-results button {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    padding: 8px 10px;
}

.picker-results button:hover,
.picker-results button[aria-selected="true"] {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.picker-name { font-weight: 600; }

.picker-meta {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.picker-chosen {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.picker-chosen .name { font-weight: 600; }

/* --- Repeatable values ------------------------------------------------ */

.values { display: flex; flex-direction: column; gap: 8px; }

.value-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.value-row input[type="text"], .value-row input[type="number"] { flex: 1; }
.value-row .as-of { width: 150px; flex: none; }
.value-row .as-of-precision { width: 130px; flex: none; }

/* --- History ---------------------------------------------------------- */

.history { font-size: 14px; }
.history td { padding: 6px 10px; }
.history .field-name { font-weight: 600; }
.history del { color: var(--danger); text-decoration: line-through; }
.history ins { color: var(--ok-text); text-decoration: none; }

/* --- Duplicates ------------------------------------------------------- */

.duplicates {
    background: var(--warn-bg);
    color: var(--warn-text);
    border: 1px solid currentColor;
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
}

.duplicates ul { margin: 8px 0 0; padding-left: 20px; }

@media (max-width: 720px) {
    .top { flex-wrap: wrap; }
    .search { order: 3; width: 100%; max-width: none; }
    nav.main { overflow-x: auto; }
}
