:root {
    --bg: #f3f3f3;
    --shell: #ffffff;
    --sidebar: #fafafa;
    --surface: #ffffff;
    --surface-soft: #f7f7f7;
    --ink: #111111;
    --muted: #6b7280;
    --line: #e6e6e6;
    --line-strong: #d4d4d4;
    --accent: #111111;
    --accent-2: #2563eb;
    --success: #0f8f62;
    --warning: #a16207;
    --danger: #b42318;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

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

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

h1,
h2,
p {
    margin: 0;
}

.auth-page {
    display: grid;
    place-items: center;
}

.auth-shell {
    width: min(100%, 480px);
    padding: 24px;
}

.login-panel {
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--shell);
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    margin-bottom: 18px;
    place-items: center;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.login-panel h1 {
    font-size: 26px;
    line-height: 1.1;
}

.login-panel p,
.login-panel small {
    color: var(--muted);
}

.login-panel p {
    margin-top: 8px;
}

.login-panel small {
    display: block;
    margin-top: 18px;
}

.app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    width: 90vw;
    min-height: calc(100vh - 64px);
    margin: 32px auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--shell);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 18px 12px;
    border-right: 1px solid var(--line);
    background: var(--sidebar);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 4px 8px;
    font-size: 13px;
}

.sidebar-user {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.sidebar-user span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.sidebar-user strong {
    overflow-wrap: anywhere;
    font-size: 14px;
}

.sidebar-brand span {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
}

.side-nav {
    display: grid;
    gap: 3px;
}

.side-nav a,
.side-action,
.sidebar-footer {
    display: flex;
    min-height: 34px;
    align-items: center;
    padding: 0 10px;
    border-radius: 7px;
    color: #3f3f46;
    font-size: 14px;
    font-weight: 600;
}

.side-action {
    width: 100%;
    margin-bottom: 8px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    justify-content: flex-start;
}

.side-nav a:hover,
.side-nav a.is-active {
    background: #eeeeee;
    color: var(--ink);
}

.sidebar-footer {
    margin-top: auto;
    border: 1px solid var(--line);
    background: var(--surface);
}

.main-panel {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.eyebrow {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.topbar h1 {
    font-size: 24px;
    line-height: 1.1;
}

.top-actions,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.btn {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.btn-secondary,
.btn-ghost {
    background: var(--surface);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.alert {
    margin-bottom: 16px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    font-size: 14px;
    font-weight: 600;
}

.alert-error {
    border-color: rgba(180, 35, 24, 0.22);
    color: var(--danger);
}

.alert-success {
    border-color: rgba(15, 143, 98, 0.22);
    color: var(--success);
}

.control-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.period-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}

.period-switch.compact {
    justify-content: flex-end;
}

.period-switch.compact label {
    width: 145px;
}

.period-note {
    color: var(--muted);
    font-size: 13px;
    text-align: right;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: #27272a;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 8px 10px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.overview,
.table-card,
.panel {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.overview {
    display: grid;
    grid-template-columns: minmax(200px, 1.2fr) repeat(4, minmax(120px, 1fr));
    margin-bottom: 16px;
    overflow: hidden;
}

.overview-title,
.overview article {
    padding: 16px;
    border-right: 1px solid var(--line);
}

.overview article:last-child {
    border-right: 0;
}

.overview-title {
    background: var(--surface-soft);
}

.overview-title h2,
.section-heading h2 {
    font-size: 17px;
    line-height: 1.2;
}

.overview-title span,
.overview small,
.section-heading p,
.table-row small,
.review-item small {
    color: var(--muted);
    font-size: 13px;
}

.overview article span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.overview article strong {
    display: block;
    margin-bottom: 4px;
    font-size: 22px;
    line-height: 1;
}

.table-card,
.panel {
    padding: 18px;
    margin-bottom: 16px;
}

.section-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.metric-table,
#metricsRows,
.reviews-list,
.user-list,
.settings-stack {
    display: grid;
    gap: 8px;
}

.table-head,
.table-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 0.8fr 0.9fr 1.2fr;
    gap: 14px;
    align-items: center;
}

.table-head {
    padding: 0 10px 9px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.table-row,
.review-item,
.user-edit {
    padding: 12px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.table-row-button {
    width: 100%;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.table-row:hover,
.review-item:hover,
.user-edit:hover {
    background: var(--surface-soft);
}

.table-row strong,
.table-row small {
    display: block;
    overflow-wrap: anywhere;
}

.table-row small {
    margin-top: 3px;
}

.status-pill {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fff;
    font-size: 12px;
    font-weight: 800;
}

.status-pill.is-good {
    border-color: rgba(15, 143, 98, 0.24);
    color: var(--success);
}

.status-pill.is-warn {
    border-color: rgba(161, 98, 7, 0.24);
    color: var(--warning);
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.9fr);
    gap: 16px;
}

.settings-column {
    display: grid;
    gap: 16px;
}

.goal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.goal-item {
    min-height: 92px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.goal-item span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.goal-item strong {
    display: block;
    font-size: 18px;
    overflow-wrap: anywhere;
}

.goal-item small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.form-stack {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

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

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

.divider {
    height: 1px;
    margin: 3px 0;
    background: var(--line);
}

.user-edit {
    display: grid;
    grid-template-columns: 1fr 1.35fr 0.7fr 0.75fr auto auto;
    gap: 8px;
    align-items: center;
}

.data-footer {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
}

.data-footer div {
    display: grid;
    gap: 4px;
}

.data-footer span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.data-footer strong {
    font-size: 13px;
}

.checkline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.checkline input {
    width: auto;
    min-height: auto;
}

.review-item {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
}

.review-item p {
    margin-top: 8px;
    color: var(--muted);
}

.empty-state {
    padding: 26px 14px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
}

.tabs a {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.tabs a.is-active {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

.setting-note,
.copy-box {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
}

.copy-box {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    overflow-wrap: anywhere;
}

.modal {
    width: min(520px, calc(100% - 28px));
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
}

.detail-modal {
    width: min(980px, calc(100% - 32px));
}

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

.detail-header h2 {
    margin: 0;
    font-size: 22px;
}

.detail-header strong {
    color: var(--muted);
    font-size: 13px;
}

.detail-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.detail-tabs button {
    min-height: 38px;
    padding: 0 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
}

.detail-tabs button.is-active {
    border-color: var(--ink);
    color: var(--ink);
}

.detail-panel {
    display: none;
    min-height: 360px;
}

.detail-panel.is-active {
    display: grid;
    align-content: start;
    gap: 10px;
}

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

.detail-columns h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.detail-item {
    display: grid;
    gap: 4px;
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.detail-item strong {
    font-size: 14px;
}

.detail-item small,
.detail-item p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.modal::backdrop {
    background: rgba(17, 17, 17, 0.28);
    backdrop-filter: blur(3px);
}

.modal-close-form {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.loading-pulse {
    position: relative;
    overflow: hidden;
}

.loading-pulse::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
    content: "";
    transform: translateX(-100%);
    animation: pulse-sweep 1.4s ease-in-out infinite;
}

@keyframes pulse-sweep {
    to {
        transform: translateX(100%);
    }
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
        width: min(100% - 24px, 1180px);
        margin: 12px auto;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .side-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .sidebar-footer {
        display: none;
    }

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

    .overview-title,
    .overview article {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .table-head {
        display: none;
    }

    .table-row,
    .user-edit {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .data-footer {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .main-panel {
        padding: 16px;
    }

    .topbar,
    .control-row,
    .review-item,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .period-note {
        text-align: left;
    }

    .period-switch,
    .top-actions,
    .inline-actions {
        width: 100%;
    }

    .period-switch label,
    .period-switch.compact label,
    .period-switch .btn,
    .top-actions .btn,
    .inline-actions .btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .side-nav,
    .overview,
    .table-row,
    .goal-grid,
    .detail-columns,
    .form-grid,
    .user-edit {
        grid-template-columns: 1fr;
    }
}
