:root {
    --bg: #080b12;
    --surface: #101620;
    --surface-raised: #151d29;
    --surface-soft: #1a2432;
    --border: #263447;
    --border-strong: #3a4b61;
    --text: #e6edf6;
    --text-muted: #8f9db0;
    --accent: #b8e35a;
    --accent-strong: #d8ff7d;
    --accent-ink: #111707;
    --danger: #ff655e;
    --danger-soft: rgba(255, 101, 94, 0.12);
    --warning: #f5c451;
    --success: #67d391;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 15% -20%, rgba(94, 129, 172, 0.14), transparent 34rem),
        var(--bg);
    color: var(--text);
    font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main {
    flex: 1 1 auto;
    min-height: 0;
    padding: 18px;
    overflow: auto;
}

#head {
    z-index: 20;
    display: flex;
    flex: 0 0 68px;
    align-items: center;
    gap: 20px;
    min-width: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 16, 24, 0.94);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid rgba(216, 255, 125, 0.45);
    border-radius: 10px;
    background: linear-gradient(145deg, rgba(216, 255, 125, 0.2), rgba(216, 255, 125, 0.04));
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.brand-copy strong {
    font-size: 13px;
    letter-spacing: 0.02em;
}

.brand-copy small {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.breadcrumbs {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
    overflow: hidden;
    color: var(--text-muted);
    white-space: nowrap;
}

.breadcrumbs a,
.breadcrumbs span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumbs a {
    color: #b9c5d4;
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--accent-strong);
}

.breadcrumb-separator {
    color: #536175;
    font-size: 20px;
    line-height: 1;
}

.breadcrumb-current {
    color: var(--text);
    font-weight: 650;
}

.header-actions {
    display: flex;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 8px;
}

.header-nav-btn {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
}

.header-nav-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

/* Cross-service switcher (templates/_service_nav.html) */
.service-nav {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.service-nav .header-nav-btn.current {
    border-color: rgba(184, 227, 90, 0.55);
    background: rgba(184, 227, 90, 0.1);
    color: var(--accent-strong);
    font-weight: 700;
}

.user-chip {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(103, 211, 145, 0.12);
}

.signout-form {
    display: inline;
    margin: 0;
}

.link-button {
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

h1,
h2,
h3 {
    margin: 0 0 14px;
    color: var(--text);
    line-height: 1.2;
}

h1 {
    font-size: 25px;
    letter-spacing: -0.025em;
}

h2 {
    margin-top: 28px;
    font-size: 17px;
}

h3 {
    margin-top: 22px;
    font-size: 14px;
}

p {
    color: var(--text-muted);
}

a {
    color: var(--accent);
}

.row {
    display: flex;
    flex: 1;
    flex-direction: row;
    width: 100%;
}

.column {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    margin: 8px;
}

.panel {
    margin: 8px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(21, 29, 41, 0.96), rgba(15, 21, 31, 0.96));
    box-shadow: var(--shadow);
}

.action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

table {
    width: 100%;
    margin: 10px 0 18px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(8, 12, 19, 0.35);
}

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

th {
    background: rgba(35, 47, 63, 0.55);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr {
    transition: background 120ms ease;
}

tbody tr:hover {
    background: rgba(184, 227, 90, 0.035);
}

form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin: 10px 0 18px;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

label {
    display: inline-flex;
    flex-direction: column;
    gap: 5px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
}

input,
select,
textarea {
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    outline: none;
    background: #0a0f17;
    color: var(--text);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184, 227, 90, 0.1);
}

input[type="color"] {
    width: 54px;
    padding: 4px;
    cursor: pointer;
}

input[type="file"] {
    display: none;
}

.main-btn {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    padding: 7px 13px;
    border: 1px solid rgba(184, 227, 90, 0.65);
    border-radius: 8px;
    background: rgba(184, 227, 90, 0.08);
    color: var(--accent-strong);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.main-btn:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: var(--accent-ink);
    transform: translateY(-1px);
}

.main-btn:disabled,
.main-btn.disabled {
    border-color: var(--border);
    background: transparent;
    color: #586578;
    cursor: not-allowed;
    transform: none;
}

.danger-btn {
    border-color: rgba(255, 101, 94, 0.62);
    background: var(--danger-soft);
    color: #ff938e;
}

.danger-btn:hover {
    border-color: var(--danger);
    background: var(--danger);
    color: #190403;
}

.progress {
    display: inline-flex;
    min-width: 66px;
    justify-content: center;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
}

.progress.ok {
    border-color: rgba(103, 211, 145, 0.3);
    background: rgba(103, 211, 145, 0.12);
    color: #94e8b4;
}

.progress.todo {
    border-color: rgba(245, 196, 81, 0.3);
    background: rgba(245, 196, 81, 0.12);
    color: #f8d77e;
}

.progress.neutral {
    border-color: var(--border);
    background: rgba(143, 157, 176, 0.08);
    color: var(--text-muted);
}

.color-block {
    display: block;
    width: 28px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

.dropdown-container {
    z-index: 30;
    display: none;
    position: absolute;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface-raised);
    box-shadow: var(--shadow);
}

.dropdown-item {
    padding: 7px 9px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--accent);
    color: var(--accent-ink);
}

.dropdown-menu:hover .dropdown-container {
    display: block;
}

#block-element {
    z-index: 999999999;
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 10, 0.48);
    backdrop-filter: blur(2px);
}

@keyframes subtle-blink {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.45); }
}

.blink {
    animation: subtle-blink 220ms ease-in-out 3;
}

@media (max-width: 900px) {
    #head {
        gap: 10px;
        padding: 0 12px;
    }

    .brand-copy,
    .user-chip {
        display: none;
    }

    main {
        padding: 10px;
    }

    .row {
        flex-direction: column;
    }
}

/* --- management panel: per-person access table ------------------------- */

/* The access table carries most of the page's content, so it gets the
   room; the search panel beside it only ever holds a field and a few hits. */
.column.wide {
    flex: 1.9;
}

.access-table td {
    vertical-align: top;
}

.access-table tbody td {
    padding-top: 12px;
}

.person-cell {
    white-space: nowrap;
}

.member-name {
    display: block;
    color: var(--text);
    font-weight: 650;
}

.person-cell small,
.search-hit small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

/* A held role: the label and its revoke button are one visual unit, and the
   whole chip is a form so the button can POST on its own. */
.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 6px 6px 0;
    padding: 3px 5px 3px 9px;
    border: 1px solid rgba(184, 227, 90, 0.45);
    border-radius: 999px;
    background: rgba(184, 227, 90, 0.08);
}

.role-chip code {
    color: var(--accent-strong);
    font-size: 12px;
}

.chip-remove {
    display: grid;
    width: 17px;
    height: 17px;
    padding: 0;
    place-items: center;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.chip-remove:hover {
    background: rgba(255, 107, 107, 0.22);
    color: #ffd7d7;
}

.access-table .inline-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.access-table select {
    padding: 3px 6px;
    font-size: 12px;
}

.muted {
    color: var(--text-muted);
}

.pending-service {
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-muted);
}

.search-hit {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.search-hit .inline-form {
    align-items: end;
    gap: 8px;
    margin-top: 8px;
}

/* --- reference data summaries (annotator, panel, references editor) ----- */

.tag {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}

.reference-list {
    margin: 6px 0 12px;
    padding: 0;
    list-style: none;
}

.reference-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.reference-list li:last-child {
    border-bottom: 0;
}

.reference-list small {
    display: block;
    color: var(--text-muted);
}
