:root {
    --ink:            #0f0e0d;
    --paper:          #f5f2ee;
    --paper-dark:     #ece8e2;
    --accent:         #c84b2f;
    --muted:          #7a746c;
    --border:         #d4cfc8;
    --success-accent: #2d6a2d;
    --error-bg:       #fdf3f0;
}

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

html {
    background: var(--paper);
    color: var(--ink);
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
}

body {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
}

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

/* Header */
header {
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.logo-mark {
    width: 32px; height: 32px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: var(--accent);
    flex-shrink: 0;
}

.logo-text {
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
}

/* Nav */
nav.admin-nav {
    display: flex;
    gap: 2rem;
    padding: 1rem 2rem 1rem;
    border-bottom: 1px solid var(--border);
}
nav.admin-nav a {
    font-size: 16px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid transparent;
}
nav.admin-nav a:hover,
nav.admin-nav a.active {
    color: var(--ink);
    border-bottom-color: var(--accent);
}
nav.admin-nav .spacer { flex: 1; }

/* Main */
main {
    padding: 3rem 2rem 4rem;
    display: flex;
    justify-content: center;
}
.page {
    width: 100%;
    max-width: 1400px;
    animation: fadeUp 0.5s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

h1.page-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    font-weight: 400;
    margin-bottom: 0.5rem;
}
h2.section-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 400;
    margin: 2.5rem 0 1rem;
}
p.page-sub {
    font-size: 16px;
    color: var(--muted);
    margin-bottom: 1rem;
}

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

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    table-layout: fixed;
}
.data-table th {
    text-align: left;
    padding: 1rem 1.25rem;
    border-bottom: 2px solid var(--ink);
    font-weight: 400;
    font-size: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
}
.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-table tr:last-child td {
    border-bottom: none;
}
.data-table tr:hover td {
    background: var(--paper-dark);
}
.data-table .actions {
    text-align: right;
    white-space: nowrap;
    min-width: 90px;
}
.data-table .question-cell {
    white-space: normal;
    word-break: break-word;
    line-height: 1.45;
}
.data-table .actions a,
.data-table .actions button {
    margin-left: 0.5rem;
}
.data-table .empty {
    text-align: center;
    padding: 3rem;
    color: var(--muted);
    font-style: italic;
}
.data-table details summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 16px;
}
.data-table details[open] summary { color: var(--accent); }
.data-table details .full-doc {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-left: 2px solid var(--border);
    white-space: pre-wrap;
    font-size: 16px;
    line-height: 1.6;
}

/* Forms */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 600px;
    margin: 2rem 0;
}
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.form-field label {
    font-size: 16px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    background-color: white;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    color: var(--ink);
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s ease;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--accent);
}
.form-field textarea {
    min-height: 120px;
    resize: vertical;
}
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.5rem !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237a746c' d='M1.4 0L6 4.6 10.6 0 12 1.4l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}
.form-field .model-toggle {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 14px;
    color: var(--muted);
}
/* iOS-style toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #c8c2bc;
    transition: 0.2s;
    border-radius: 24px;
}
.switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .slider {
    background-color: var(--accent);
}
.switch input:checked + .slider:before {
    transform: translateX(18px);
}
.form-field .help {
    font-size: 16px;
    color: var(--muted);
    font-style: italic;
}
.form-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--ink);
    color: var(--paper);
    border: none;
    border-radius: 3px;
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease;
}
.btn:hover { background: var(--accent); }
.btn-secondary {
    background: transparent;
    color: var(--ink);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: transparent;
}
.btn-danger { background: var(--accent); }
.btn-danger:hover { background: #a23a23; }
.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--ink);
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    text-decoration: underline;
    cursor: pointer;
}
.btn-link:hover { color: var(--accent); }

/* Small button variant for inline table actions */
.btn-small {
    padding: 0.45rem 0.9rem;
    font-size: 16px;
    letter-spacing: 0.06em;
}

/* Icon-style button used in table action columns */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
    margin-left: 0.4rem;
    padding: 0;
    text-decoration: none;
}
.icon-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}
.icon-btn:first-child { margin-left: 0; }
.detail-actions .icon-btn {
    width: 40px;
    height: 40px;
}
.icon-btn:hover {
    border-color: var(--ink);
    background: var(--paper-dark);
    color: var(--ink);
}
.icon-btn-danger {
    color: var(--accent);
    border-color: var(--border);
}
.icon-btn-danger:hover {
    border-color: var(--accent);
    background: var(--error-bg);
    color: var(--accent);
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--paper-dark);
    border-radius: 4px;
    flex-wrap: wrap;
}
.filter-bar .form-field { margin: 0; max-width: 240px; flex: 1 1 180px; }
.filter-bar .form-field.wide { max-width: 420px; }

/* Definition list */
dl.detail-list {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.75rem 1.5rem;
    margin: 1.5rem 0 2rem;
    padding: 1.5rem;
    background: var(--paper-dark);
    border-radius: 4px;
}
dl.detail-list dt {
    font-size: 16px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}
dl.detail-list dd {
    font-size: 16px;
    color: var(--ink);
    word-break: break-word;
}

/* Pre blocks */
pre.block {
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.25rem 1.5rem;
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ink);
    margin: 1rem 0;
}

/* Error message */
.inline-error-msg {
    font-size: 16px;
    color: var(--accent);
    padding: 0.75rem 1rem;
    background: var(--error-bg);
    border-left: 3px solid var(--accent);
    border-radius: 2px;
    margin-bottom: 1rem;
}
.extraction-status {
    font-size: 16px;
    color: var(--muted);
}
.extraction-status.success { color: var(--success-accent); }
.extraction-status.error { color: var(--accent); }

/* "Asking" indicator next to the employee status when a question is in
   flight. Editorial paper aesthetic — uppercase letter-spaced accent
   text, no fill, no border-radius. Mirrors the same treatment used on
   the email header's accent line. */
.badge-asking {
    margin-left: 0.75rem;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

/* Inline flash message in a row's actions cell after a click. Same
   uppercase-letter-spaced treatment as the rest of the table labels. */
.inline-flash {
    margin-right: 0.75rem;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.inline-flash-success { color: var(--success-accent); }
.inline-flash-error   { color: var(--accent); }
.row-flash-error td:first-child { border-left: 3px solid var(--accent); }

/* Dialog */
dialog {
    border: 1.5px solid var(--border);
    border-radius: 4px;
    padding: 0;
    background: var(--paper);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(15,14,13,0.15);
}
dialog::backdrop {
    background: rgba(15, 14, 13, 0.4);
}
.modal-body {
    padding: 2.5rem;
}
.modal-body h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.6rem;
    margin-bottom: 1rem;
    font-weight: 400;
}
.modal-body p {
    font-size: 16px;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 2rem;
}
.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Conversation turn blocks (session detail) */
.turn {
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--border);
    background: white;
}
.turn .speaker {
    font-size: 16px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.turn .text {
    white-space: pre-wrap;
    font-size: 16px;
    line-height: 1.6;
}

hr.section-rule {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

/* Settings page tabs */
.settings-form {
    margin-top: 2rem;
}
.settings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}
.settings-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 1rem 1.75rem;
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.settings-tab:hover {
    color: var(--ink);
}
.settings-tab.active {
    color: var(--ink);
    border-bottom-color: var(--accent);
}
.settings-panel {
    animation: fadeUp 0.3s ease both;
}
.hidden {
    display: none !important;
}
.settings-actions {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.subsection-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 400;
    margin: 2.5rem 0 0.5rem;
}
.test-email-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}
.test-email-row input {
    flex: 1;
}
.inline-success-msg {
    padding: 1rem 1.25rem;
    background: #eef5ee;
    border-left: 3px solid var(--success-accent);
    color: var(--success-accent);
    font-size: 16px;
    margin-bottom: 1.5rem;
}
.inline-success {
    color: var(--success-accent);
    font-size: 16px;
    margin-top: 0.5rem;
}
.inline-error {
    color: var(--accent);
    font-size: 16px;
    margin-top: 0.5rem;
}
code {
    font-family: 'DM Mono', monospace;
    font-size: 0.9em;
    background: var(--paper-dark);
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
}

.code-block {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    background: var(--paper-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    overflow-x: auto;
    white-space: pre;
}

.help-disclosure {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}
.help-disclosure > summary {
    cursor: pointer;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    list-style: none;
}
.help-disclosure > summary::-webkit-details-marker { display: none; }
.help-disclosure > summary::before {
    content: "+ ";
    display: inline-block;
    width: 1em;
}
.help-disclosure[open] > summary::before { content: "− "; }
.help-disclosure[open] > summary { color: var(--ink); margin-bottom: 0.75rem; }
.help-disclosure p { margin-top: 0.75rem; }
.help-disclosure p:first-of-type { margin-top: 0; }

/* Footer */
footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
footer p {
    font-size: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
    font-weight: 400;
}
