:root {
    color-scheme: dark;
    --bg: #101112;
    --panel: #181a1c;
    --panel-strong: #202326;
    --line: #34383d;
    --text: #f5f2ee;
    --muted: #aeb4bb;
    --accent: #ff7a1a;
    --accent-strong: #ff8f3d;
    --silver: #d8dadd;
    --danger: #ff4d4d;
    --success: #54d18b;
    --radius: 8px;
    --shadow: 0 18px 48px rgba(0, 0, 0, .35);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(145deg, rgba(255, 122, 26, .12), transparent 32rem),
        radial-gradient(circle at top, #202224, #101112 62%);
    color: var(--text);
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 96px;
}

.topbar,
.page-head,
.section-head,
.client-card,
.user-card,
.detail-grid article,
.metric-card,
.fold-card,
.analytics-grid article,
.auth-card,
.filter-panel,
.record-form fieldset {
    border: 1px solid var(--line);
    background: rgba(24, 26, 28, .9);
    box-shadow: var(--shadow);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 10px 12px;
    border-radius: var(--radius);
    backdrop-filter: blur(16px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 6px;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.05;
}

.brand strong {
    font-size: 16px;
}

.brand small {
    margin-top: 4px;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: .08em;
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-strong);
    color: var(--silver);
    cursor: pointer;
}

.tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 6px;
    max-width: 760px;
    margin: 0 auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(16, 17, 18, .94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.tab-item {
    display: grid;
    place-items: center;
    min-height: 42px;
    padding: 0 6px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.tab-primary {
    background: var(--accent);
    color: #121212;
}

.content {
    padding-top: 18px;
}

.page-head,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    padding: 16px;
    border-radius: var(--radius);
}

.page-head h1,
.section-head h2,
.analytics-section h2 {
    margin: 0;
    font-size: clamp(24px, 5vw, 36px);
    line-height: 1.05;
}

.section-head h2,
.analytics-section h2 {
    font-size: 22px;
}

.page-head p {
    margin: 8px 0 0;
    color: var(--muted);
}

.primary-link,
.ghost-link,
.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 800;
    white-space: nowrap;
}

.primary-link,
.primary-button {
    background: linear-gradient(180deg, var(--accent-strong), var(--accent));
    color: #15120f;
}

.secondary-button,
.ghost-link {
    border-color: var(--line);
    background: var(--panel-strong);
    color: var(--silver);
}

.danger-button {
    background: transparent;
    border-color: rgba(255, 77, 77, .55);
    color: var(--danger);
}

.small-button {
    min-height: 36px;
    padding: 0 10px;
}

.metric-grid,
.detail-grid,
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metric-card,
.detail-grid article,
.analytics-grid article {
    min-width: 0;
    padding: 14px;
    border-radius: var(--radius);
}

.metric-card span,
.detail-grid span,
.analytics-grid span,
.user-card span,
.client-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.metric-card strong,
.detail-grid strong,
.analytics-grid strong {
    display: block;
    margin-top: 8px;
    overflow-wrap: anywhere;
    font-size: 24px;
    line-height: 1.1;
}

.client-list,
.user-list {
    display: grid;
    gap: 10px;
}

.client-card,
.user-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius);
}

.client-card strong,
.user-card strong {
    display: block;
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.client-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 112px;
    text-align: right;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: #303338;
    color: var(--silver);
    font-size: 12px;
    font-weight: 800;
}

.status-queued {
    background: rgba(216, 218, 221, .16);
}

.status-in_progress {
    background: rgba(255, 122, 26, .18);
    color: #ffd2b1;
}

.status-completed {
    background: rgba(84, 209, 139, .15);
    color: #aef0c9;
}

.status-cancelled {
    background: rgba(255, 77, 77, .16);
    color: #ffb5b5;
}

.filter-panel,
.record-form fieldset {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 16px;
    padding: 14px;
    border-radius: var(--radius);
}

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

.record-form legend {
    padding: 0 8px;
    color: var(--accent);
    font-weight: 900;
}

label {
    display: grid;
    gap: 6px;
    min-width: 0;
}

label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #101214;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 122, 26, .18);
}

.full-span,
.wide {
    grid-column: 1 / -1;
}

.form-actions,
.danger-zone {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.danger-zone {
    justify-content: flex-end;
    padding-top: 14px;
}

.alert,
.empty-state {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
}

.alert-error {
    border-color: rgba(255, 77, 77, .42);
    color: #ffc0c0;
}

.alert-success {
    border-color: rgba(84, 209, 139, .44);
    color: #b6f0cf;
}

.auth-panel {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 120px);
}

.auth-card {
    width: min(420px, 100%);
    padding: 22px;
    border-radius: var(--radius);
}

.auth-logo {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: var(--radius);
}

.auth-card h1 {
    margin: 16px 0 6px;
    font-size: 32px;
}

.auth-card p {
    margin: 0 0 18px;
    color: var(--muted);
}

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

.analytics-section {
    margin-bottom: 18px;
}

.fold-card {
    margin-bottom: 10px;
    padding: 12px;
    border-radius: var(--radius);
}

.fold-card summary {
    cursor: pointer;
    font-weight: 900;
}

.fold-card .analytics-grid {
    margin: 12px 0 0;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}

.check-row input {
    width: 20px;
    min-height: 20px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, .62);
}

.reminder-modal {
    width: min(620px, 100%);
    max-height: min(760px, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.reminder-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-strong);
}

.reminder-head span {
    color: var(--accent);
    font-size: 13px;
    font-weight: 900;
}

.reminder-head h2 {
    margin: 4px 0 0;
    font-size: 24px;
    line-height: 1.1;
}

.reminder-list {
    display: grid;
    gap: 10px;
    padding: 14px;
    overflow: auto;
}

.reminder-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #101214;
}

.reminder-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.reminder-item-head strong,
.reminder-item-head a {
    overflow-wrap: anywhere;
}

.reminder-item-head a {
    color: var(--accent);
    font-weight: 900;
}

.reminder-item p {
    margin: 10px 0;
    color: var(--silver);
    line-height: 1.4;
}

.reminder-item blockquote {
    margin: 0;
    padding: 10px 12px;
    border-left: 3px solid var(--accent);
    color: var(--muted);
    background: rgba(255, 122, 26, .08);
    line-height: 1.45;
}

.reminder-actions {
    padding: 14px;
    border-top: 1px solid var(--line);
    background: var(--panel-strong);
}

.reminder-actions .primary-button {
    width: 100%;
}

@media (max-width: 820px) {
    .metric-grid,
    .detail-grid,
    .analytics-grid,
    .filter-panel,
    .record-form fieldset {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-head .primary-link,
    .page-head .ghost-link {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .app-shell {
        padding: 10px;
        padding-bottom: 92px;
    }

    .brand strong {
        font-size: 14px;
    }

    .tabbar {
        left: 8px;
        right: 8px;
        bottom: 8px;
        gap: 4px;
    }

    .tab-item {
        font-size: 11px;
        min-height: 40px;
    }

    .metric-grid,
    .detail-grid,
    .analytics-grid,
    .filter-panel,
    .record-form fieldset {
        grid-template-columns: 1fr;
    }

    .client-card,
    .user-card {
        flex-direction: column;
    }

    .client-meta {
        align-items: flex-start;
        min-width: 0;
        text-align: left;
    }

    .form-actions,
    .danger-zone {
        flex-direction: column;
    }

    .form-actions > *,
    .danger-zone > *,
    .filter-panel button {
        width: 100%;
    }

    .modal-backdrop {
        align-items: end;
        padding: 8px;
    }

    .reminder-modal {
        max-height: calc(100vh - 16px);
    }

    .reminder-head h2 {
        font-size: 20px;
    }

    .reminder-item-head {
        align-items: flex-start;
        flex-direction: column;
    }
}
