:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-alt: #f9fbfd;
    --surface-soft: #f2f5f9;
    --text: #172033;
    --text-soft: #5b667a;
    --border: #dbe3ee;
    --border-strong: #c9d4e3;
    --brand: #2563eb;
    --brand-strong: #1d4ed8;
    --brand-soft: #e8f0ff;
    --success: #15803d;
    --success-soft: #e9f8ef;
    --warning: #b45309;
    --warning-soft: #fff4e5;
    --neutral-soft: #eef2f7;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 12px 30px rgba(16, 24, 40, 0.06);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --sidebar-width: 248px;
    --font-body: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

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

a:hover {
    color: var(--brand-strong);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 8px;
}

.mobile-menu-toggle {
    display: none;
}

.mobile-menu-content {
    display: contents;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 0.95rem;
    font-weight: 700;
}

.brand-kicker,
.eyebrow,
.stat-label,
.section-kicker,
.empty-kicker {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
}

.brand-card h2 {
    margin: 2px 0 0;
    font-size: 1.35rem;
    line-height: 1.15;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: block;
    padding: 11px 14px;
    border-radius: 12px;
    color: var(--text-soft);
    font-weight: 600;
}

.nav-link:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.nav-link.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.sidebar-actions {
    margin-top: auto;
    display: grid;
    gap: 10px;
}

.app-main {
    padding: 28px;
    display: grid;
    gap: 22px;
}

.page-hero,
.card,
.stat-card,
.form-shell,
.empty-state,
.table-card,
.callers-board,
.results-board,
.login-shell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.page-hero {
    padding: 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.page-hero h1,
.section-header h2,
.card h2,
.card h3,
.empty-state h3,
.login-shell h1 {
    margin: 0;
    font-size: clamp(1.8rem, 2.5vw, 2.5rem);
    line-height: 1.1;
    color: var(--text);
}

.page-lead,
.section-header p,
.card p,
.stat-subtitle,
.muted,
.helper-text {
    margin: 10px 0 0;
    color: var(--text-soft);
}

.hero-actions,
.inline-actions,
.search-toolbar,
.filters,
.stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button,
button,
input[type="submit"] {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--brand);
    color: #fff;
    box-shadow: none;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--brand-strong);
    color: #fff;
}

.button.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}

.button.secondary:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.button.ghost,
button.ghost {
    background: transparent;
    color: var(--text-soft);
    border-color: var(--border);
}

.button.ghost:hover,
button.ghost:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.stats-grid,
.panel-grid,
.grid-2,
.grid-3,
.field-grid,
.detail-grid,
.quick-links {
    display: grid;
    gap: 18px;
}

.stats-grid,
.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel-grid,
.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card,
.form-shell,
.empty-state,
.table-card,
.callers-board,
.results-board {
    padding: 20px;
}

.stat-card {
    padding: 18px;
}

.stat-value {
    margin: 12px 0 4px;
    font-size: 2.2rem;
    font-weight: 700;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 18px;
}

.quick-links {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.quick-link,
.detail-card,
.result-card,
.caller-card {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.quick-link,
.detail-card {
    padding: 14px;
}

.quick-link strong,
.detail-card strong {
    display: block;
    margin-bottom: 6px;
}

.detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.highlight-panel {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
    border: 1px solid #d6e4ff;
}

.highlight-panel h2 {
    margin: 10px 0 0;
    font-size: 2rem;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-alt);
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="search"],
input[type="time"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--text);
    border-radius: 10px;
    padding: 12px 14px;
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

input[type="color"] {
    width: 100%;
    min-height: 56px;
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: 10px;
    padding: 6px;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 8px;
}

input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: 8px;
}

.field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-span-2 {
    grid-column: 1 / -1;
}

.field-hint {
    margin-top: 6px;
    font-size: 0.92rem;
    color: var(--text-soft);
}

.name-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    min-height: 20px;
}

.suggestion-chip {
    appearance: none;
    border: 1px solid var(--border-strong);
    background: var(--surface-soft);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.suggestion-chip:hover {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.results-list,
.caller-list,
.list {
    display: grid;
    gap: 14px;
}

.result-card,
.caller-card {
    padding: 14px;
}

.result-row,
.caller-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tag,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
}

.tag {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.status-pill {
    background: var(--neutral-soft);
    color: var(--text-soft);
}

.status-pill.success {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill.warn {
    background: var(--warning-soft);
    color: var(--warning);
}

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

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

th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
}

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

.empty-state {
    text-align: center;
    padding: 32px 24px;
}

.notice {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #f3d2a6;
    background: #fff8ef;
    color: var(--warning);
}

.success-notice {
    border-color: #b7ebc5;
    background: #f1fbf4;
    color: var(--success);
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.login-shell {
    width: min(100%, 420px);
    padding: 30px;
    box-shadow: var(--shadow-md);
}

.mobile-only {
    display: none;
}

.search-page-shell {
    max-width: 980px;
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

.search-page-shell.compact-view .card,
.search-page-shell.compact-view .callers-board,
.search-page-shell.compact-view .results-board {
    padding: 16px;
}

.search-page-shell.compact-view .section-header {
    margin-bottom: 12px;
}

.search-page-shell.compact-view .section-header p {
    margin-top: 6px;
    font-size: 0.95rem;
}

.search-page-shell.compact-view .caller-list,
.search-page-shell.compact-view .results-list {
    gap: 10px;
}

.search-page-shell.compact-view .caller-card,
.search-page-shell.compact-view .result-card {
    padding: 12px 14px;
    gap: 8px;
    font-size: 0.94rem;
}

.search-page-shell.compact-view .search-input-wrap {
    padding: 10px;
}

@media (min-width: 1081px) {
    .search-page-shell.compact-view .caller-card {
        display: grid;
        grid-template-columns: minmax(220px, 1fr) auto minmax(320px, auto) auto;
        align-items: center;
        gap: 16px;
    }

    .search-page-shell.compact-view .caller-card .result-row {
        display: contents;
    }

    .search-page-shell.compact-view .caller-card .result-row > div,
    .search-page-shell.compact-view .caller-card .caller-meta > .inline-actions,
    .search-page-shell.compact-view .caller-card .caller-meta > .status-pill,
    .search-page-shell.compact-view .caller-card .caller-meta > .muted,
    .search-page-shell.compact-view .caller-card .result-row > .checkbox-row {
        min-width: 0;
    }

    .search-page-shell.compact-view .caller-card .result-row > div {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-self: start;
        width: 100%;
        text-align: left;
    }

    .search-page-shell.compact-view .caller-card .result-row > div .muted {
        margin: 2px 0 0;
        font-size: 0.92rem;
        text-align: left;
    }

    .search-page-shell.compact-view .caller-card .caller-meta {
        display: contents;
    }

    .search-page-shell.compact-view .caller-card .inline-actions {
        gap: 8px;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }

    .search-page-shell.compact-view .caller-card .compact-actions .button {
        padding: 6px 10px;
        font-size: 0.88rem;
        white-space: nowrap;
        min-height: auto;
    }

    .search-page-shell.compact-view .caller-card .checkbox-row {
        white-space: nowrap;
        justify-content: flex-start;
        font-size: 0.95rem;
    }

    .search-page-shell.compact-view .caller-card .status-pill,
    .search-page-shell.compact-view .caller-card .muted:last-child {
        white-space: nowrap;
    }

    .search-page-shell.compact-view .caller-card .status-pill {
        justify-self: start;
        width: auto;
        max-width: max-content;
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    .search-page-shell.compact-view .caller-card .muted:last-child {
        text-align: right;
        font-size: 0.92rem;
    }

    .search-page-shell.compact-view .caller-card strong,
    .search-page-shell.compact-view .caller-card a,
    .search-page-shell.compact-view .caller-card .checkbox-row,
    .search-page-shell.compact-view .caller-card .muted {
        font-size: 0.94rem;
    }
}

body > .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    z-index: 10;
}

body > .sidebar ~ * {
    margin-left: var(--sidebar-width);
    padding-left: 28px;
    padding-right: 28px;
}

@media (max-width: 1080px) {
    .app-shell,
    .stats-grid,
    .panel-grid,
    .grid-2,
    .grid-3,
    .field-grid {
        grid-template-columns: 1fr;
    }

    .sidebar,
    body > .sidebar {
        position: relative;
        width: auto;
        min-height: auto;
    }

    body > .sidebar ~ * {
        margin-left: 0;
        padding-left: 18px;
        padding-right: 18px;
    }

    .app-main {
        padding: 18px;
    }

    .search-page-shell {
        max-width: none;
    }

    .page-hero,
    .search-input-wrap,
    .hero-actions,
    .result-row,
    .caller-meta,
    .inline-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 720px) {
    .sidebar {
        padding: 12px;
        gap: 14px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-topbar {
        align-items: center;
    }

    .brand-card {
        padding: 4px 2px;
        gap: 12px;
        flex: 1;
        min-width: 0;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .brand-card h2 {
        font-size: 1.05rem;
    }

    .brand-kicker {
        font-size: 0.68rem;
        letter-spacing: 0.06em;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        background: var(--surface-soft);
        color: var(--text);
        border-color: var(--border);
        padding: 9px 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .mobile-menu-content {
        display: none;
    }

    .mobile-menu-content.mobile-open {
        display: grid;
        gap: 12px;
    }

    .sidebar-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .nav-link {
        padding: 10px 12px;
        text-align: center;
        font-size: 0.96rem;
    }

    .sidebar-actions {
        margin-top: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .sidebar-actions .button {
        width: 100%;
        padding: 10px 12px;
    }

    .app-main {
        padding: 12px;
        gap: 16px;
    }

    .page-hero {
        padding: 14px 16px;
        gap: 14px;
    }

    .page-hero h1 {
        font-size: 1.15rem;
        line-height: 1.15;
    }

    .page-lead {
        margin-top: 6px;
        font-size: 0.96rem;
    }

    .eyebrow {
        font-size: 0.66rem;
    }

    .card,
    .form-shell,
    .empty-state,
    .table-card,
    .callers-board,
    .results-board,
    .stat-card,
    .login-shell {
        padding: 14px;
        border-radius: 16px;
    }

    .section-header {
        margin-bottom: 12px;
        gap: 12px;
    }

    .section-header h2,
    .card h2 {
        font-size: 1rem;
        line-height: 1.2;
    }

    .section-header p,
    .card p,
    .muted {
        font-size: 0.95rem;
    }

    .search-input-wrap {
        padding: 10px;
        gap: 10px;
        margin-bottom: 10px;
    }

    .search-input-wrap input[type="search"] {
        padding: 12px 14px;
        font-size: 0.98rem;
    }

    .search-input-wrap .button {
        width: 100%;
        min-height: 48px;
    }

    .hero-actions .button,
    .hero-actions button,
    .section-header .button,
    .section-header button {
        width: 100%;
    }

    .caller-card,
    .result-card,
    .detail-card,
    .quick-link {
        padding: 12px;
    }

    .caller-card .result-row,
    .caller-card .caller-meta {
        gap: 10px;
    }

    .caller-card .inline-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        width: 100%;
    }

    .caller-card .inline-actions .button {
        width: 100%;
    }

    body.search-page .page-hero {
        display: none;
    }

    body.search-page .app-main {
        padding: 8px;
        gap: 12px;
    }

    body.search-page .search-page-shell {
        width: 100%;
        max-width: none;
        gap: 12px;
    }

    body.search-page .search-page-shell > * {
        width: 100%;
    }

    body.search-page .search-page-shell .card,
    body.search-page .search-page-shell .callers-board {
        padding: 10px;
    }

    body.search-page .search-input-wrap {
        margin-bottom: 0;
    }

    body.search-page .callers-board .section-header {
        display: block;
        margin-bottom: 10px;
    }

    body.search-page .callers-board .section-header h2 {
        font-size: 1.15rem;
        line-height: 1.15;
    }

    body.search-page .callers-board .section-header .button {
        width: 100%;
        margin-top: 10px;
    }

    body.search-page .caller-card {
        padding: 12px;
    }

    body.search-page .search-page-shell.compact-view .caller-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 10px;
        align-items: center;
        padding: 10px 12px;
    }

    body.search-page .search-page-shell.compact-view .caller-card .result-row,
    body.search-page .search-page-shell.compact-view .caller-card .caller-meta {
        display: contents;
    }

    body.search-page .search-page-shell.compact-view .caller-card .result-row > div {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        min-width: 0;
    }

    body.search-page .search-page-shell.compact-view .caller-card .result-row > div strong,
    body.search-page .search-page-shell.compact-view .caller-card .result-row > div a {
        font-size: 0.98rem;
        line-height: 1.15;
    }

    body.search-page .search-page-shell.compact-view .caller-card .result-row > div .muted {
        margin: 2px 0 0;
        font-size: 0.82rem;
        line-height: 1.1;
    }

    body.search-page .search-page-shell.compact-view .caller-card .checkbox-row {
        grid-column: 1;
        grid-row: 2;
        font-size: 0.88rem;
        line-height: 1.1;
        white-space: nowrap;
    }

    body.search-page .search-page-shell.compact-view .caller-card .caller-meta > .muted:last-child {
        grid-column: 2;
        grid-row: 1;
        margin: 0;
        font-size: 0.8rem;
        white-space: nowrap;
        text-align: right;
        align-self: start;
    }

    body.search-page .search-page-shell.compact-view .caller-card .caller-meta > .status-pill,
    body.search-page .search-page-shell.compact-view .caller-card .caller-meta > .compact-actions {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
        align-self: center;
    }

    body.search-page .search-page-shell.compact-view .caller-card .caller-meta > .status-pill {
        max-width: max-content;
        padding: 5px 10px;
        font-size: 0.78rem;
    }

    body.search-page .search-page-shell.compact-view .caller-card .compact-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
        max-width: 220px;
    }

    body.search-page .search-page-shell.compact-view .caller-card .compact-actions .button {
        width: auto;
        min-height: 0;
        padding: 5px 8px;
        font-size: 0.76rem;
        line-height: 1.1;
        border-radius: 999px;
    }

    .checkbox-row {
        font-size: 0.95rem;
    }

    .search-page-shell.compact-view .caller-card,
    .search-page-shell.compact-view .result-card {
        padding: 12px;
        font-size: 0.92rem;
    }

    .search-page-shell.compact-view .caller-card .inline-actions {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 9px 7px;
    }
}
