:root {
    --paper: #f4efe7;
    --paper-strong: #fffaf2;
    --ink: #1f2430;
    --muted: #6d6f73;
    --line: rgba(31, 36, 48, 0.12);
    --accent: #0d6b5f;
    --accent-soft: #d6eee9;
    --warning: #9c5f19;
    --warning-soft: #fff0d9;
    --error: #9a2f2f;
    --error-soft: #ffe4e1;
    --shadow: 0 18px 50px rgba(31, 36, 48, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(13, 107, 95, 0.12), transparent 28%),
        linear-gradient(180deg, #efe5d4 0%, var(--paper) 35%, #f8f4ec 100%);
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 120ms ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

.page-shell {
    width: min(1200px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.app-nav {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.hamburger-menu {
    position: relative;
}

.hamburger-summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.9);
    box-shadow: var(--shadow);
    cursor: pointer;
    list-style: none;
}

.hamburger-summary::-webkit-details-marker {
    display: none;
}

.hamburger-icon {
    display: grid;
    gap: 4px;
}

.hamburger-icon span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: var(--ink);
}

.hamburger-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    display: grid;
    gap: 4px;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.96);
    box-shadow: var(--shadow);
    z-index: 20;
}

.hamburger-link {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none;
    font: 600 0.92rem/1.2 "Avenir Next", "Gill Sans", sans-serif;
}

.hamburger-button {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.hamburger-link:hover {
    background: rgba(13, 107, 95, 0.08);
}

.hero,
.filters,
.summary-grid,
.message,
.dashboard-section,
.page-footer {
    margin-bottom: 14px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 18px;
    align-items: start;
}

.hero-compact h1 {
    max-width: 14ch;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font: 700 0.8rem/1.1 "Avenir Next", "Gill Sans", sans-serif;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 700;
}

h1 {
    font-size: clamp(2.4rem, 5vw, 4.2rem);
    line-height: 0.95;
    max-width: 10ch;
}

.lede,
.section-note,
.page-footer,
.meta-help,
.filters span {
    color: var(--muted);
}

.lede {
    max-width: 54ch;
    font-size: 1.05rem;
    line-height: 1.6;
}

.hero-meta,
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}

.meta-card,
.summary-card,
.message,
.location-row,
.filters {
    background: rgba(255, 250, 242, 0.82);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.day-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: rgba(255, 250, 242, 0.82);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.day-pill {
    display: grid;
    justify-items: center;
    gap: 4px;
}

.day-arrow {
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(13, 107, 95, 0.08);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
}

.meta-card,
.summary-card {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-card strong,
.summary-card strong {
    font-size: 1.4rem;
}

.meta-label,
.summary-card span {
    font: 700 0.82rem/1.1 "Avenir Next", "Gill Sans", sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.filters {
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: end;
}

.filters label {
    display: grid;
    gap: 6px;
    min-width: 150px;
}

.filters input,
.filters button {
    border-radius: 12px;
    border: 1px solid var(--line);
    font: inherit;
}

.filters input {
    padding: 8px 10px;
    background: #fff;
}

.filters button {
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

.loading-note {
    font: 700 0.82rem/1.1 "Avenir Next", "Gill Sans", sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.message {
    padding: 10px 14px;
}

.message.warning {
    background: var(--warning-soft);
    border-color: rgba(156, 95, 25, 0.2);
}

.message.error {
    background: var(--error-soft);
    border-color: rgba(154, 47, 47, 0.2);
}

.message h2 {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.message ul {
    margin: 0;
    padding-left: 18px;
}

.dashboard-section {
    display: grid;
    gap: 10px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: end;
}

.stats-list {
    display: grid;
    gap: 10px;
}

.stats-list-head,
.stats-row {
    display: grid;
    align-items: center;
    gap: 12px;
}

.inbound-cols,
.outbound-cols {
    grid-template-columns: minmax(180px, 1.3fr) repeat(5, minmax(90px, 0.7fr));
}

.stats-list-head {
    padding: 0 14px;
    color: var(--muted);
    font: 700 0.76rem/1.1 "Avenir Next", "Gill Sans", sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stats-row {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.82);
    box-shadow: var(--shadow);
}

.row-name strong,
.row-cell strong {
    display: block;
    font-size: 1.3rem;
    line-height: 1;
}

.row-name small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
}

.row-cell {
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(31, 36, 48, 0.04);
}

.row-cell.service-center {
    background: rgba(255, 240, 217, 0.95);
}

.outbound-cols {
    grid-template-columns: minmax(180px, 1.3fr) repeat(5, minmax(90px, 0.65fr));
}

.page-footer {
    font-size: 0.9rem;
}

.message.success {
    background: var(--accent-soft);
    border-color: rgba(13, 107, 95, 0.2);
}

.analysis-section {
    margin-top: 28px;
}

.analysis-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.analysis-form {
    margin: 0;
}

.analysis-summary-grid {
    margin-bottom: 0;
}

.analysis-command-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 10px;
}

.activity-strip {
    display: grid;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(13, 107, 95, 0.07);
}

.activity-copy {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.activity-copy strong,
.activity-copy small {
    margin: 0;
}

.activity-copy small {
    color: var(--muted);
}

.activity-progress {
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(31, 36, 48, 0.08);
}

.activity-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0d6b5f 0%, #58a58f 100%);
}

.activity-progress span.warning,
.location-activity-progress span.warning {
    background: linear-gradient(90deg, #c07a2c 0%, #e4b16a 100%);
}

.activity-progress span.failed,
.location-activity-progress span.failed {
    background: linear-gradient(90deg, #9a2f2f 0%, #d96d6d 100%);
}

.command-strip {
    margin: 0;
}

.analysis-history-card,
.analysis-jobs-card {
    background: rgba(255, 250, 242, 0.82);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 12px 14px;
}

.compact-link {
    color: var(--ink);
    text-decoration: none;
}

.dashboard-loading-shell {
    display: grid;
    gap: 14px;
}

.skeleton-card {
    min-height: 120px;
    background:
        linear-gradient(110deg, rgba(255,255,255,0.24) 8%, rgba(255,255,255,0.56) 18%, rgba(255,255,255,0.24) 33%),
        rgba(255, 250, 242, 0.82);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
    to {
        background-position-x: -200%;
    }
}

.history-columns,
.history-compact-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
    gap: 10px;
}

.theme-breakdown {
    display: grid;
    gap: 10px;
}

.history-chart-card,
.history-signal-card {
    display: grid;
    gap: 8px;
}

.history-chart-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    min-height: 240px;
}

.history-chart-wrap {
    position: relative;
    height: 240px;
    width: 240px;
}

.history-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: start;
}

.history-legend-item {
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--theme-color-soft, rgba(31, 36, 48, 0.04));
    border: 1px solid var(--theme-color-line, rgba(31, 36, 48, 0.06));
    min-width: 150px;
}

.history-legend-item strong,
.history-legend-item small {
    margin: 0;
}

.history-legend-item strong {
    color: var(--theme-color, var(--ink));
    font: 700 0.78rem/1.1 "Avenir Next", "Gill Sans", sans-serif;
}

.history-legend-item small {
    color: var(--muted);
    font: 600 0.72rem/1.1 "Avenir Next", "Gill Sans", sans-serif;
}

.location-board {
    display: grid;
    gap: 8px;
}

.location-card {
    display: grid;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.82);
    box-shadow: var(--shadow);
}

.location-card.expanded {
    border-color: rgba(13, 107, 95, 0.28);
    background: linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(240, 248, 245, 0.9));
}

.location-summary {
    display: grid;
    grid-template-columns: minmax(220px, 1.6fr) minmax(360px, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.location-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}

.location-title h3 {
    font-size: 1.1rem;
    line-height: 1.1;
}

.location-title .theme-chip-row {
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.location-title .theme-chip-row::-webkit-scrollbar {
    display: none;
}

.location-title .mini-note {
    white-space: nowrap;
}

.location-subline {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.location-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(72px, 1fr));
    gap: 6px;
}

.mini-stat {
    padding: 6px 8px;
    border-radius: 12px;
    background: rgba(31, 36, 48, 0.04);
    border: 1px solid rgba(31, 36, 48, 0.06);
}

.mini-stat span,
.location-panel h4,
.transcript-mini-row p {
    color: var(--muted);
}

.mini-stat strong {
    display: block;
    margin-top: 2px;
    font-size: 1rem;
    line-height: 1.1;
}

.mini-stat small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.8rem;
}

.location-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}

.location-actions form {
    margin: 0;
}

.location-actions button,
.location-actions .ghost-button {
    width: auto;
    min-width: 0;
    padding: 7px 10px;
    font-size: 0.88rem;
    line-height: 1.1;
}

.location-detail {
    padding-top: 2px;
    border-top: 1px solid var(--line);
}

.location-activity-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 2px;
}

.location-activity-item {
    min-width: 180px;
    display: grid;
    gap: 4px;
}

.location-activity-item strong {
    font: 700 0.74rem/1.1 "Avenir Next", "Gill Sans", sans-serif;
    color: var(--muted);
}

.location-activity-progress {
    height: 5px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(31, 36, 48, 0.08);
}

.location-activity-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0d6b5f 0%, #58a58f 100%);
}

.location-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: 10px;
}

.location-panel {
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.4);
}

.transcript-mini-list {
    display: grid;
    gap: 6px;
}

.transcript-mini-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(31, 36, 48, 0.03);
    border: 1px solid transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    appearance: none;
    font: inherit;
}

.transcript-mini-row[data-theme-code] {
    background: var(--theme-color-soft, rgba(31, 36, 48, 0.03));
    border-color: var(--theme-color-line, rgba(31, 36, 48, 0.08));
}

.transcript-mini-row.selected {
    border-color: var(--theme-color, rgba(13, 107, 95, 0.35));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--theme-color, var(--accent)) 28%, transparent);
}

.transcript-mini-row[data-theme-code] > div:first-child strong {
    color: var(--theme-color, var(--ink));
}

.transcript-theme-label {
    color: var(--theme-color, var(--muted));
    font-weight: 700;
}

.transcript-model-label {
    color: var(--muted);
    font-size: 0.76rem;
}

.transcript-reader-meta {
    margin-bottom: 10px;
}

.detail-stack.compact {
    margin-top: 12px;
}

.transcript-reader {
    max-height: 420px;
    overflow: auto;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--theme-color-line, var(--line));
    background: var(--theme-color-soft, rgba(31, 36, 48, 0.03));
    line-height: 1.5;
    white-space: normal;
}

.muted-chip {
    background: rgba(31, 36, 48, 0.04);
}

.theme-breakdown-row,
.job-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(31, 36, 48, 0.03);
}

.theme-breakdown-row small,
.job-row p,
.job-row small,
.mini-kicker {
    color: var(--muted);
}

.jobs-list,
.theme-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.theme-chip-row.compact {
    display: grid;
    gap: 8px;
    justify-items: start;
    align-content: start;
}

.history-signal-card .theme-chip {
    width: max-content;
}

.job-row {
    width: 100%;
}

.job-meta {
    display: grid;
    justify-items: end;
    gap: 3px;
}

.theme-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--theme-color-line, var(--line));
    background: var(--theme-color-soft, rgba(13, 107, 95, 0.08));
    color: var(--theme-color, var(--ink));
    font: 700 0.68rem/1 "Avenir Next", "Gill Sans", sans-serif;
    letter-spacing: 0.03em;
}

.job-row strong,
.history-chart-card h4,
.history-signal-card h4 {
    margin: 0;
}

.job-row p,
.job-row small {
    line-height: 1.2;
}

.analysis-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.55fr);
    gap: 16px;
}

.analysis-list-card,
.analysis-detail-card,
.analysis-suggestions-card,
.analysis-panel {
    background: rgba(255, 250, 242, 0.82);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.analysis-list-card,
.analysis-detail-card,
.analysis-suggestions-card {
    padding: 18px;
}

.analysis-card-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    margin-bottom: 10px;
}

.analysis-list {
    display: grid;
    gap: 10px;
}

.analysis-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(31, 36, 48, 0.03);
    color: inherit;
    text-decoration: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    appearance: none;
}

.analysis-row.selected {
    border-color: rgba(13, 107, 95, 0.35);
    background: rgba(13, 107, 95, 0.08);
}

.analysis-row p,
.analysis-row small,
.suggestion-card small,
.detail-stack span,
.status-inquiry-grid span {
    color: var(--muted);
}

.analysis-row p,
.suggestion-card p,
.detail-stack p,
.status-inquiry-grid p {
    margin: 4px 0 0;
}

.analysis-row-meta {
    display: grid;
    justify-items: end;
    gap: 6px;
}

.tag.neutral {
    background: rgba(31, 36, 48, 0.06);
}

.analysis-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.analysis-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 14px;
}

.analysis-panel {
    padding: 16px;
}

.analysis-panel h4,
.suggestion-card h4 {
    margin: 0 0 12px;
}

.manage-layout {
    display: grid;
    gap: 14px;
}

.manage-panel h3 {
    margin: 0 0 10px;
}

.code-block {
    margin: 0;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(31, 36, 48, 0.04);
    overflow: auto;
    white-space: pre-wrap;
    font: 0.88rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.login-panel {
    max-width: 420px;
}

.login-form {
    display: grid;
    gap: 12px;
}

.login-form label {
    display: grid;
    gap: 6px;
}

.login-form input {
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    background: #fff;
    font: inherit;
}

.transcript-block {
    margin: 0;
    white-space: pre-wrap;
    font: 0.92rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    max-height: 620px;
    overflow: auto;
}

.detail-stack {
    display: grid;
    gap: 12px;
}

.status-inquiry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.analysis-actions,
.suggestion-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.analysis-actions form,
.suggestion-actions form {
    margin: 0;
}

.ghost-button {
    background: transparent;
    color: var(--ink);
}

.filters .ghost-button,
.analysis-actions .ghost-button,
.suggestion-actions .ghost-button,
.compact-link.ghost-button {
    border: 1px solid var(--line);
}

.suggestion-list {
    display: grid;
    gap: 12px;
}

.location-analytics {
    margin-top: 6px;
    display: grid;
    gap: 6px;
}

.mini-note {
    margin: 0;
    font-size: 0.84rem;
    color: var(--muted);
}

.suggestion-card {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: start;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(31, 36, 48, 0.03);
}

.empty-state,
.error-copy {
    color: var(--muted);
}

@media (max-width: 860px) {
    .hero,
    .section-heading {
        grid-template-columns: 1fr;
        display: grid;
    }

    .inbound-cols,
    .outbound-cols {
        grid-template-columns: 1fr;
    }

    .stats-list-head {
        display: none;
    }

    .analysis-layout,
    .analysis-columns,
    .history-columns,
    .history-compact-grid,
    .location-summary,
    .location-detail-grid {
        grid-template-columns: 1fr;
    }

    .activity-copy {
        flex-direction: column;
        align-items: start;
    }

    .history-chart-layout {
        grid-template-columns: 1fr;
        justify-items: start;
        min-height: 0;
    }

    .history-chart-wrap {
        height: 190px;
        width: 190px;
    }

    .history-signal-card .theme-chip-row.compact {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    .location-title {
        display: grid;
        gap: 6px;
        align-items: start;
    }

    .location-kpis {
        grid-template-columns: repeat(2, minmax(90px, 1fr));
    }

    .location-actions {
        justify-content: stretch;
    }

    .location-actions button,
    .location-actions .ghost-button {
        width: 100%;
    }

    .day-nav {
        flex-direction: column;
    }

    .suggestion-card,
    .analysis-row,
    .transcript-mini-row {
        flex-direction: column;
        align-items: start;
    }

    .analysis-row-meta {
        justify-items: start;
    }
}
