@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
    --ink-950: #09131f;
    --ink-900: #102235;
    --ink-800: #18324d;
    --ink-700: #274764;
    --brand-600: #1d7a6d;
    --brand-500: #2f9d8f;
    --brand-100: #ddf3ef;
    --paper-50: #fbfaf6;
    --paper-100: #f3efe7;
    --paper-200: #e1d8c8;
    --paper-300: #cdbfaa;
    --gold-500: #b6873d;
    --text: #223041;
    --muted: #6f7c8a;
    --danger: #b42318;
    --shadow-lg: 0 22px 55px rgba(9, 19, 31, 0.12);
    --shadow-sm: 0 8px 24px rgba(9, 19, 31, 0.07);
}

* { box-sizing: border-box; }

html {
    background:
        radial-gradient(circle at top right, rgba(45, 157, 143, 0.13), transparent 35%),
        radial-gradient(circle at 15% 10%, rgba(182, 135, 61, 0.10), transparent 26%),
        linear-gradient(180deg, #f9f5ee 0%, #f3efe7 100%);
}

body {
    margin: 0;
    color: var(--text);
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    background:
        linear-gradient(rgba(255,255,255,0.6), rgba(255,255,255,0.6)),
        radial-gradient(circle at top right, rgba(45, 157, 143, 0.08), transparent 33%),
        linear-gradient(180deg, #f8f4ec 0%, #efe8dc 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, .metric-title {
    font-family: 'Fraunces', Georgia, serif;
    letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

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

.sidebar-backdrop {
    display: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    color: #fff;
    background:
        linear-gradient(180deg, rgba(9,19,31,0.97), rgba(16,34,53,0.98)),
        radial-gradient(circle at top, rgba(45,157,143,0.22), transparent 30%);
    border-right: 1px solid rgba(255,255,255,0.08);
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.03);
}

.sidebar-head {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px 18px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo,
.login-logo {
    width: 78px;
    height: 78px;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    background: #fff;
}

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

.nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(255,255,255,0.76);
    font-size: 14px;
    font-weight: 600;
    transition: transform .16s ease, background .16s ease, color .16s ease;
}

.nav a:hover,
.nav a.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(45,157,143,0.26), rgba(45,157,143,0.10));
    transform: translateX(2px);
}

.sidebar-foot {
    margin-top: auto;
    padding: 16px 10px 8px;
    color: rgba(255,255,255,0.64);
    display: grid;
    gap: 4px;
}

.sidebar-foot a {
    display: inline-flex;
    justify-content: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.88);
    font-weight: 700;
}

.portal-icon-link {
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
}

.portal-icon-link svg,
.sidebar-toggle svg,
.sidebar-close svg {
    width: 20px;
    height: 20px;
}

.main {
    min-width: 0;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
    background: rgba(251, 248, 242, 0.82);
    border-bottom: 1px solid rgba(16,34,53,0.08);
}

.sidebar-toggle,
.topbar-brand {
    display: none;
}

.page-title-wrap h1 {
    margin: 2px 0 0;
    font-size: 22px;
}

.eyebrow, .mini-label, .section-label, .kpi-label {
    text-transform: uppercase;
    letter-spacing: .12em;
}

.eyebrow {
    margin: 0;
    font-size: 11px;
    font-weight: 800;
    color: var(--brand-600);
}

.content {
    padding: 24px 28px 34px;
}

.userbar {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, var(--ink-800), var(--brand-600));
    color: #fff;
    font-weight: 800;
}

.logout {
    border: 0;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-weight: 700;
    padding: 8px 10px;
    border-radius: 10px;
}

.logout:hover { background: rgba(180,35,24,0.06); }

.grid {
    display: grid;
    gap: 14px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.section-label {
    margin: 20px 0 8px;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
}

.card,
.table-wrapper,
.form-section,
.report-hero,
.report-summary,
.report-order,
.report-preview,
.login-card,
.login-visual {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,244,236,0.96)),
        #fff;
    border: 1px solid rgba(16,34,53,0.08);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
}

.card { padding: 18px; }

.metric-grid {
    margin-top: 4px;
    margin-bottom: 4px;
}

.metric-card { min-height: 126px; }

.metric-accent {
    background:
        linear-gradient(145deg, rgba(29,122,109,0.12), rgba(255,255,255,0.96)),
        #fff;
}

.info-card { min-height: 126px; }

.backlog {
    display: flex;
    gap: 14px;
    margin-top: 10px;
}

.backlog div {
    display: grid;
    gap: 3px;
    text-align: center;
    min-width: 64px;
}

.backlog strong {
    font-size: 22px;
    color: var(--ink-800);
}

.backlog span,
.muted,
.kpi-sub {
    color: var(--muted);
}

.kpi-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.kpi-value {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: var(--ink-900);
}

.kpi-sub {
    margin: 8px 0 0;
    font-size: 12px;
}

.toolbar {
    align-items: center;
    border-bottom: 1px solid rgba(16,34,53,0.08);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    padding: 14px 18px;
}

.toolbar form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.order-row-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-inline-form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-inline-form .input-sm {
    width: 155px;
}

.table-scroll { overflow-x: auto; }

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

th {
    background: rgba(29,122,109,0.06);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    padding: 12px 14px;
    text-align: left;
    text-transform: uppercase;
}

td {
    border-top: 1px solid rgba(16,34,53,0.07);
    color: var(--text);
    font-size: 14px;
    padding: 13px 14px;
    vertical-align: top;
}

.description-preview {
    max-width: 360px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

tr:hover td { background: rgba(247, 243, 236, 0.9); }

.right { text-align: right; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

.input,
.input-sm,
textarea,
select {
    background: rgba(255,255,255,0.94);
    border: 1px solid rgba(16,34,53,0.16);
    border-radius: 12px;
    color: var(--text);
    padding: 11px 12px;
    width: 100%;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.input-sm {
    min-height: 38px;
    padding: 8px 10px;
    width: auto;
}

.input:focus,
.input-sm:focus,
textarea:focus,
select:focus {
    border-color: rgba(29,122,109,0.55);
    box-shadow: 0 0 0 4px rgba(29,122,109,0.10);
}

textarea { min-height: 110px; }

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
    align-items: center;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    font-size: 14px;
    font-weight: 700;
    gap: 8px;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    white-space: nowrap;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn-primary {
    background: linear-gradient(145deg, var(--ink-800), var(--ink-700));
    border: 1px solid var(--ink-800);
    color: #fff;
    box-shadow: 0 14px 30px rgba(16,34,53,0.18);
}

.btn-secondary {
    background: #fff;
    border: 1px solid rgba(16,34,53,0.14);
    color: var(--ink-800);
}

.btn-danger {
    background: var(--danger);
    border: 1px solid var(--danger);
    color: #fff;
}

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

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.btn-ghost:hover {
    transform: translateY(-1px);
}

.btn-wide { width: 100%; }

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
}

.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f3f4f6; color: #4b5563; }

.flash {
    border-radius: 14px;
    font-weight: 700;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }

.form-section {
    margin-bottom: 16px;
    overflow: hidden;
}

.form-section h2 {
    border-bottom: 1px solid rgba(16,34,53,0.08);
    font-size: 15px;
    margin: 0;
    padding: 14px 16px;
}

.form-body {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.field label {
    color: var(--ink-800);
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pagination-bar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding: 0 4px;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 18px;
    align-items: center;
    padding: 24px;
}

.login-shell-centered {
    grid-template-columns: 1fr;
    justify-items: center;
}

.login-stack {
    width: min(100%, 460px);
    display: grid;
    gap: 18px;
    justify-items: center;
}

.login-visual {
    padding: 32px;
    min-height: 540px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        linear-gradient(180deg, rgba(16,34,53,0.92), rgba(16,34,53,0.78)),
        radial-gradient(circle at top right, rgba(45,157,143,0.20), transparent 32%);
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.login-visual h1 {
    margin: 14px 0 10px;
    font-size: clamp(40px, 6vw, 72px);
}

.login-visual p {
    margin: 0;
    max-width: 520px;
    color: rgba(255,255,255,0.82);
    font-size: 16px;
    line-height: 1.6;
}

.login-card {
    padding: 30px;
    box-shadow: var(--shadow-lg);
    width: 100%;
}

.login-card h2 {
    margin: 0 0 6px;
    font-size: 30px;
}

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

.mini-link {
    color: var(--brand-600);
    font-size: 13px;
    font-weight: 800;
}

.login-logo-large {
    width: 112px;
    height: 112px;
    border-radius: 18px;
}

.mini-label {
    font-size: 10px;
    color: rgba(255,255,255,0.58);
}

.report-hero {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 18px;
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-lg);
}

.report-hero-copy h2 {
    margin: 6px 0 10px;
    font-size: 34px;
    line-height: 1.02;
}

.report-hero-copy p:last-child {
    margin: 0;
    max-width: 60ch;
    color: var(--muted);
    line-height: 1.6;
}

.report-filters {
    display: grid;
    gap: 12px;
    align-content: start;
}

.report-filters .field { margin: 0; }

.report-summary {
    padding: 20px;
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, .9fr);
    gap: 18px;
    align-items: center;
}

.report-summary h3,
.report-order h3 {
    margin: 4px 0;
    font-size: 22px;
}

.report-summary-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.metric-value {
    display: block;
    font-size: 22px;
    color: var(--ink-900);
}

.report-actions {
    grid-column: 1 / -1;
    margin-top: 6px;
}

.report-orders {
    display: grid;
    gap: 14px;
}

.report-order {
    padding: 18px;
}

.report-order-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.report-order-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(16,34,53,0.08);
}

.report-order-total strong {
    font-size: 20px;
    color: var(--ink-900);
}

.report-preview {
    margin-top: 18px;
    padding: 18px;
}

.report-frame {
    display: block;
    width: 100%;
    height: 860px;
    border: 1px solid rgba(16,34,53,0.10);
    border-radius: 14px;
    background: #fff;
}

.dashboard-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.dashboard-hero h2 {
    margin: 4px 0 10px;
    font-size: 32px;
}

.dashboard-badge {
    min-width: 160px;
    padding: 14px 16px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(29,122,109,0.12), rgba(255,255,255,0.96));
    border: 1px solid rgba(29,122,109,0.15);
}

.dashboard-badge .mini-label {
    color: var(--ink-700);
}

.dashboard-period-form {
    align-items: center;
    display: flex;
    gap: 8px;
    margin: 8px 0 6px;
}

.dashboard-period-form .input-sm {
    min-width: 152px;
}

.dashboard-badge strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
    color: var(--ink-900);
}

.metric-title {
    display: block;
    font-size: 18px;
    color: var(--ink-900);
}

@media (max-width: 1060px) {
    .app-shell,
    .login-shell,
    .report-hero,
    .report-summary {
        grid-template-columns: 1fr;
    }

    .app-shell {
        position: relative;
        max-width: 100vw;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(320px, 84vw);
        z-index: 60;
        transform: translateX(-102%);
        transition: transform .22s ease;
        box-shadow: 18px 0 50px rgba(9, 19, 31, 0.28);
        max-width: 84vw;
    }

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

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(9, 19, 31, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-head {
        display: flex;
        justify-content: flex-end;
        padding-bottom: 8px;
    }

    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: 0;
        border-radius: 999px;
        background: rgba(255,255,255,0.08);
        color: #fff;
        cursor: pointer;
    }

    .sidebar-toggle,
    .topbar-brand {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
    }

    .sidebar-toggle {
        width: 42px;
        height: 42px;
        border: 0;
        border-radius: 12px;
        background: rgba(16,34,53,0.06);
        color: var(--ink-800);
        cursor: pointer;
    }

    .topbar {
        position: relative;
        justify-content: flex-start;
        gap: 10px;
        max-width: 100vw;
    }

    .topbar-brand {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .topbar-brand .brand-logo {
        width: 48px;
        height: 48px;
    }

    .page-title-wrap {
        display: none;
    }

    .userbar {
        margin-left: auto;
        gap: 8px;
        min-width: 0;
    }

    .login-visual {
        min-height: 320px;
    }
}

@media (max-width: 900px) {
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6,
    .report-summary-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stacked-grid,
    .wide-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content,
    .topbar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6,
    .report-summary-metrics,
    .dashboard-hero,
    .report-order-head {
        grid-template-columns: 1fr;
        display: grid;
    }

    .login-card,
    .login-visual,
    .report-hero,
    .report-summary,
    .report-order,
    .report-preview,
    .dashboard-hero {
        padding: 18px;
    }

    .login-stack {
        width: min(100%, 100%);
    }

    .userbar span {
        display: none;
    }

    .logout {
        padding: 8px;
    }

    .report-frame {
        height: 620px;
    }
}
