@font-face {
    font-family: "AI Text";
    src: url("/assets/fonts/text/ai-text-regular.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "AI Text";
    src: url("/assets/fonts/text/ai-text-semibold.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "AI Headline";
    src: url("/assets/fonts/headline/ai-headline-semibold.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f5f7;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --card: #ffffff;
    --primary: #6d2bbd;
    --primary-ink: #ffffff;
    --accent: #ece1fb;
    --accent-ink: #4c1d95;
    --warning: #f59e0b;
    --success: #16a34a;
    --danger: #dc2626;
    --shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    --sidebar-start: #172554;
    --sidebar-end: #3b0764;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "AI Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: var(--primary-ink);
    height: 44px;
    padding: 0 0.75rem;
}

.app-header-title {
    font-family: "AI Headline", "AI Text", "Segoe UI", system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
}

.app-header-subtitle {
    font-size: 0.8rem;
    opacity: 0.85;
}

.app-header-sep {
    opacity: 0.6;
    font-size: 0.8rem;
}

.app-search {
    flex: 1;
    display: flex;
    justify-content: center;
}

.app-search input {
    width: 260px;
    height: 26px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0 0.5rem;
    font-size: 0.75rem;
}

.app-search input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.icon-button {
    height: 28px;
    width: 28px;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 2px;
    cursor: pointer;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.waffle {
    display: grid;
    grid-template-columns: repeat(3, 4px);
    gap: 2px;
}

.waffle span {
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 1px;
    display: block;
}

.avatar {
    height: 26px;
    width: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 220px;
    background: linear-gradient(180deg, var(--sidebar-start), var(--sidebar-end));
    color: #e2e8f0;
    padding: 0.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
}

.sidebar-link,
.sidebar-section button {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    color: inherit;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
}

.sidebar-link.active,
.sidebar-link:hover,
.sidebar-section button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 600;
}

.sidebar-title {
    padding: 0.6rem 0.85rem 0.25rem;
    font-size: 0.6rem;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 0.08em;
}


.app-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: var(--bg);
}

.command-bar {
    height: 44px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    gap: 0.5rem;
    overflow-x: auto;
    font-size: 0.78rem;
}

.command-action {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.78rem;
    padding: 0.35rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
}

.command-action:hover {
    background: var(--bg);
}

.command-spacer {
    flex: 1;
}

.content {
    flex: 1;
    overflow: auto;
    padding: 1.5rem 2rem;
}

.page-title {
    border-left: 4px solid var(--primary);
    padding-left: 0.75rem;
    margin-bottom: 1rem;
}

.page-title h1 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--text);
}

.page-title h1:focus,
.page-title h1:focus-visible {
    outline: none;
}

.page-title p {
    margin: 0.25rem 0 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
}

.card + .card {
    margin-top: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.grid {
    display: grid;
    gap: 1rem;
}

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

.grid.cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.18rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: #312e81;
    color: #ffffff;
}

.badge.pending {
    background: #b45309;
    color: #ffffff;
}

.badge.in-progress {
    background: #3730a3;
    color: #ffffff;
}

.badge.fulfilled {
    background: #166534;
    color: #ffffff;
}

.badge.cancelled {
    background: #b91c1c;
    color: #ffffff;
}

.btn {
    border: none;
    border-radius: 6px;
    padding: 0.45rem 0.8rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-ink);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
}

.edit-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    font-size: 0.78rem;
    background: var(--surface, #fff);
    color: var(--text);
}

textarea.edit-input {
    resize: vertical;
    font-family: inherit;
}

.edit-bool {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
}

.review-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.table th,
.table td {
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.5rem;
    text-align: left;
}

.table th {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.table tr:hover {
    background: #f9fafb;
}

.clickable-row {
    cursor: pointer;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0;
    font-size: 0.85rem;
}

.tree-toggle {
    display: inline-block;
    width: 1rem;
    color: var(--muted);
}

.review-flag {
    font-weight: 700;
    color: #b45309;
}

.review-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.review-tree {
    flex: 1 1 58%;
    min-width: 0;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.review-panel {
    flex: 1 1 42%;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.tree-selected {
    background: #eef2ff;
    border-radius: 6px;
}

.diff-changed {
    background: #fff7ed;
}

.diff-del {
    background: #fde2e1;
    text-decoration: line-through;
    border-radius: 2px;
    padding: 0 1px;
}

.diff-add {
    background: #dcfce7;
    border-radius: 2px;
    padding: 0 1px;
}

.diff-json {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7rem;
    max-height: 16rem;
    overflow: auto;
}

.diff-json > div {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.diff-line-del {
    background: #fde2e1;
}

.diff-line-add {
    background: #dcfce7;
}

.diff-value {
    max-height: 8rem;
    overflow: auto;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-size: 0.72rem;
}

.badge.summary-pill {
    background: #312e81;
    color: #ffffff;
}

.badge.summary-pill.selectable {
    cursor: pointer;
}

.badge.summary-pill.active {
    background: #4338ca;
    box-shadow: 0 0 0 2px #c7d2fe;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.78rem;
    background: #fff;
}

.filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.app-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

.app-modal {
    background: var(--card);
    border-radius: 10px;
    padding: 1.25rem;
    max-width: 720px;
    width: 90%;
    max-height: 85vh;
    overflow: auto;
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.bar-list {
    display: grid;
    gap: 0.5rem;
}

.bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 40px;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
}

.bar-track {
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--primary);
}

.alert {
    border: 1px solid rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
}

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

@media (max-width: 900px) {
    .sidebar {
        width: 180px;
    }

    .content {
        padding: 1.25rem;
    }
}

.status {
    margin-top: 0.6rem;
    font-size: 0.9rem;
    color: var(--accent);
}

.card {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 0.9rem;
    display: grid;
    gap: 0.4rem;
}

.step-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.step {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    padding: 0.5rem;
    font-size: 0.8rem;
}

.queue-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--muted);
}

.bg-shape {
    position: fixed;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.4;
    z-index: 0;
}

.shape-a {
    background: #b2c9e7;
    top: -60px;
    left: -20px;
}

.shape-b {
    background: #f7d6b8;
    bottom: -60px;
    right: -20px;
}

.filters-card {
    padding: 0.75rem 1rem;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.status-tabs {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.status-tab {
    border: 1px solid var(--border);
    background: #fff;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    cursor: pointer;
}

.status-tab.active {
    background: var(--primary);
    color: var(--primary-ink);
    border-color: var(--primary);
}

.request-list {
    display: grid;
    gap: 1rem;
}

.request-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: grid;
    gap: 0.5rem;
    background: #fff;
}

.request-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.request-id {
    font-size: 0.75rem;
    color: var(--muted);
}

.request-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.request-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.request-meta {
    color: var(--muted);
    font-size: 0.78rem;
}

.request-notes {
    font-size: 0.78rem;
    color: var(--text);
}

.request-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.comment-block {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.comment-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.line-items {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.line-item-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.line-item-title {
    font-weight: 600;
    font-size: 0.82rem;
}

.line-items-editor {
    margin-top: 1rem;
    display: grid;
    gap: 0.75rem;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.line-item-editor {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    display: grid;
    gap: 0.75rem;
    background: #f8fafc;
}

.line-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.line-item-actions {
    display: flex;
    justify-content: flex-end;
}

.toggle-group {
    display: flex;
    gap: 0.4rem;
}

.toggle-button {
    border: 1px solid var(--border);
    background: #fff;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.72rem;
    cursor: pointer;
}

.toggle-button.active {
    border-color: var(--primary);
    background: var(--accent);
    color: var(--accent-ink);
}

.cadence-panel {
    border-top: 1px dashed var(--border);
    padding-top: 0.75rem;
    display: grid;
    gap: 0.75rem;
}

.cadence-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.weekday-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.weekday-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 0.72rem;
}

.modal-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

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

.toggle-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mono {
    font-family: "Consolas", "Courier New", monospace;
}

.tab-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.tab-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--border);
    background: #fff;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
}

.tab-button.active {
    border-color: var(--primary);
    background: var(--accent);
    color: var(--accent-ink);
}

.tab-close {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    padding: 0 0.35rem;
    font-size: 0.7rem;
}

.tab-add {
    border: 1px dashed var(--border);
    background: transparent;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
}

.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.field-row {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.step-list {
    padding-left: 1.2rem;
    display: grid;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.scaled-amount {
    background: rgba(99, 102, 241, 0.15);
    color: #4338ca;
    font-weight: 700;
    padding: 0 0.2rem;
    border-radius: 4px;
}

.component-list {
    display: grid;
    gap: 0.75rem;
}

.component-row {
    display: grid;
    gap: 0.5rem;
    border: 1px solid var(--border);
    padding: 0.7rem;
    border-radius: 10px;
    background: #f8fafc;
}

.component-title {
    font-weight: 600;
}

.component-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

.complete-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
}

.request-banner {
    margin-bottom: 0.75rem;
    display: grid;
    gap: 0.4rem;
}

.request-banner-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

.request-banner-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text);
}

.archived-row {
    opacity: 0.5;
}

.warning-banner {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    margin-bottom: 1rem;
}

.chart-tabs {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.chart-tab {
    border: 1px solid var(--border);
    background: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    cursor: pointer;
}

.chart-tab.active {
    background: var(--primary);
    color: var(--primary-ink);
    border-color: var(--primary);
}

.table-input {
    max-width: 120px;
}

.low-row {
    background: rgba(245, 158, 11, 0.08);
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    gap: 0.5rem;
    z-index: 200;
    max-width: 320px;
}

.toast {
    background: #111827;
    color: #fff;
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    font-size: 0.78rem;
}

.toast-success {
    background: #065f46;
}

.toast-error {
    background: #b91c1c;
}

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

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .line-item {
        grid-template-columns: 1fr 1fr;
    }
}
