:root {
    --bg: #f6f7fb;
    --ink: #17202a;
    --muted: #667085;
    --line: #e4e7ec;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --blue: #2563eb;
    --cyan: #06b6d4;
    --green: #16a34a;
    --yellow: #d97706;
    --red: #dc2626;
    --pink: #db2777;
    --purple: #7c3aed;
    --shadow: 0 18px 40px rgba(15, 23, 42, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .13), transparent 32rem),
        radial-gradient(circle at top right, rgba(219, 39, 119, .12), transparent 30rem),
        var(--bg);
    color: var(--ink);
}

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

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

button {
    cursor: pointer;
}

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

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 22px;
    background: #111827;
    color: #fff;
}

.brand-block {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #db2777, #f97316);
    font-weight: 900;
    letter-spacing: .02em;
}

.brand-block strong,
.brand-block span {
    display: block;
}

.brand-block span {
    margin-top: 3px;
    color: #cbd5e1;
    font-size: 12px;
}

.main-nav {
    display: grid;
    gap: 8px;
}

.main-nav a {
    min-height: 42px;
    padding: 11px 13px;
    border-radius: 14px;
    color: #d7dee9;
}

.main-nav a:hover,
.main-nav a.active {
    background: #ffffff;
    color: #111827;
    font-weight: 800;
}

.sidebar-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    color: #d7dee9;
    font-size: 14px;
}

.sidebar-footer a {
    color: #93c5fd;
    font-weight: 800;
}

.app-main {
    min-width: 0;
    padding: 28px;
}

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

.topbar h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 50px);
    line-height: 1;
    letter-spacing: 0;
}

.topbar-actions,
.card-actions,
.filter-row,
.form-actions,
.backup-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.eyebrow,
.card-kicker {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.btn,
.icon-button,
.file-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 14px;
    padding: 10px 15px;
    font-weight: 850;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #fff;
}

.btn-soft {
    background: #eef4ff;
    color: #1d4ed8;
}

.btn-green {
    background: #dcfce7;
    color: #166534;
}

.btn-yellow {
    background: #fef3c7;
    color: #92400e;
}

.btn-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-wide {
    width: 100%;
}

.icon-button {
    width: 40px;
    padding: 0;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.menu-toggle {
    display: none;
}

.alert {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: 16px;
    font-weight: 750;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.metric-grid,
.dashboard-grid,
.bucket-grid,
.cards-grid {
    display: grid;
    gap: 16px;
}

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

.dashboard-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(330px, .6fr);
}

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

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

.content-panel,
.metric-card,
.work-card,
.form-card,
.login-card,
.installer-panel,
.print-sheet {
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 24px;
    background: rgba(255, 255, 255, .9);
    box-shadow: var(--shadow);
}

.content-panel,
.form-card,
.print-sheet {
    padding: 20px;
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 18px;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: var(--metric, var(--blue));
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-weight: 800;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
}

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

.section-head h2 {
    margin: 0;
    font-size: 24px;
}

.work-card {
    --card-accent: var(--blue);
    position: relative;
    overflow: hidden;
    padding: 17px;
}

.work-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 7px;
    background: var(--card-accent);
}

.work-card-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.work-card h3 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.badge-stack,
.meta-row {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    font-weight: 900;
}

.status-open { background: #dbeafe; color: #1d4ed8; }
.status-progress { background: #fef3c7; color: #92400e; }
.status-waiting { background: #f3e8ff; color: #7e22ce; }
.status-done { background: #dcfce7; color: #166534; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }
.priority-low { background: #f1f5f9; color: #475569; }
.priority-normal { background: #dbeafe; color: #1d4ed8; }
.priority-high { background: #ffedd5; color: #c2410c; }
.priority-urgent { background: #fee2e2; color: #b91c1c; }

.meta-row {
    margin-top: 13px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.meta-row span {
    padding: 6px 9px;
    border-radius: 999px;
    background: var(--surface-2);
}

.card-copy {
    margin: 14px 0 0;
    color: #344054;
    line-height: 1.55;
}

.mini-list,
.note-strip {
    display: grid;
    gap: 7px;
    margin-top: 14px;
    padding: 11px;
    border-radius: 16px;
    background: #f8fafc;
    color: #475467;
    font-size: 13px;
}

.note-strip p {
    margin: 0;
}

.card-actions {
    margin-top: 14px;
}

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

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

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

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

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 850;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

input,
select {
    min-height: 44px;
    padding: 9px 12px;
}

textarea {
    resize: vertical;
    padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}

.checkbox-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}

.checkbox-card input {
    width: auto;
    min-height: auto;
    margin-top: 4px;
}

.note-input-row {
    display: grid;
    grid-template-columns: 1fr 40px;
    gap: 9px;
}

.empty-state {
    padding: 24px;
    border: 1px dashed #cbd5e1;
    border-radius: 20px;
    background: rgba(255, 255, 255, .7);
    color: var(--muted);
    text-align: center;
}

.login-body,
.installer-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.login-card {
    width: min(440px, 100%);
    padding: 28px;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 36px;
}

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

.installer-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: .9fr 1.1fr;
    border-radius: 30px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.installer-hero {
    padding: 38px;
    background: linear-gradient(145deg, #2563eb, #06b6d4 50%, #f97316);
    color: #fff;
}

.installer-hero h1 {
    margin: 18px 0 12px;
    font-size: clamp(34px, 5vw, 58px);
    line-height: .95;
}

.installer-hero p {
    line-height: 1.6;
}

.mini-pill {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    font-weight: 900;
}

.installer-panel {
    padding: 30px;
}

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

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

.print-only {
    display: none;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        z-index: 20;
        inset: 0 auto 0 0;
        width: min(310px, 84vw);
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: inline-flex;
    }

    .dashboard-grid,
    .installer-shell {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 680px) {
    .app-main {
        padding: 18px;
    }

    .topbar,
    .section-head,
    .work-card-top {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions .btn {
        flex: 1;
    }

    .form-grid,
    .form-grid.three,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .note-input-row {
        grid-template-columns: 1fr;
    }

    .installer-hero,
    .installer-panel,
    .login-card {
        padding: 24px;
    }
}

@media print {
    body {
        background: #fff;
    }

    .app-sidebar,
    .topbar,
    .no-print,
    .card-actions,
    .alert {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .app-main {
        padding: 0;
    }

    .content-panel,
    .work-card,
    .print-sheet {
        box-shadow: none;
        border: 1px solid #d0d5dd;
        break-inside: avoid;
    }

    .print-only {
        display: block;
    }
}
