:root {
    --bg: #f7fbff;
    --surface: #ffffff;
    --surface-2: #f4f8fb;
    --line: #d7e3ef;
    --line-strong: #b8c9da;
    --text: #172033;
    --muted: #667085;
    --primary: #009f9a;
    --primary-dark: #05736f;
    --accent: #ff6b4a;
    --accent-2: #2563eb;
    --sun: #f5b700;
    --success: #079669;
    --danger: #d92355;
    --warning: #b77905;
    --shadow: 0 18px 44px rgba(31, 48, 74, 0.1);
    --shadow-soft: 0 10px 24px rgba(31, 48, 74, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100%;
    margin: 0;
    overflow-x: hidden;
    background:
        linear-gradient(135deg, rgba(255, 247, 237, 0.92) 0%, rgba(236, 254, 255, 0.94) 36%, rgba(248, 250, 255, 0.96) 68%, rgba(240, 253, 244, 0.94) 100%),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    z-index: -1;
    height: 260px;
    background: linear-gradient(120deg, rgba(0, 159, 154, 0.22), rgba(255, 107, 74, 0.18) 48%, rgba(37, 99, 235, 0.18));
    pointer-events: none;
}

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

button,
input,
select {
    font: inherit;
}

button,
input,
select,
textarea {
    max-width: 100%;
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 22px 18px;
    overflow: hidden;
    background: linear-gradient(170deg, #0e2d48 0%, #047c7c 52%, #ff7a4f 100%);
    color: #eef9ff;
    box-shadow: 14px 0 38px rgba(14, 45, 72, 0.16);
}

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

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #ffe082, #ff6b4a);
    color: #192033;
    font-weight: 900;
    box-shadow: 0 12px 24px rgba(255, 107, 74, 0.28);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 18px;
    letter-spacing: 0;
}

.brand small {
    margin-top: 2px;
    color: rgba(238, 249, 255, 0.78);
    font-size: 12px;
}

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

.side-nav a,
.logout-form button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
    color: #eaf7ff;
    cursor: pointer;
    font-weight: 800;
    letter-spacing: 0;
    text-align: left;
}

.side-nav a:hover,
.logout-form button:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.side-nav a.active {
    border-color: rgba(255, 255, 255, 0.72);
    background: #ffffff;
    color: #0e2d48;
    box-shadow: var(--shadow-soft);
}

.logout-form {
    margin-top: auto;
}

.main-area {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 82px;
    padding: 18px 30px;
    border-bottom: 1px solid rgba(215, 227, 239, 0.86);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 30px rgba(31, 48, 74, 0.06);
}

.topbar h1 {
    margin: 0;
    font-size: 25px;
    line-height: 1.15;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.user-chip {
    display: grid;
    gap: 2px;
    min-width: 170px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(135deg, #ffffff, #fff7ed);
    box-shadow: var(--shadow-soft);
    text-align: right;
}

.user-chip span {
    font-weight: 900;
}

.user-chip small {
    color: var(--muted);
}

.content {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 28px;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    font-weight: 800;
}

.flash-success {
    border-color: #86efac;
    color: #05603a;
}

.flash-error {
    border-color: #fecdd3;
    color: #a30f3c;
}

.flash-info {
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.flash-close {
    border: 0;
    background: transparent;
    color: currentColor;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.section,
.table-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(215, 227, 239, 0.96);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.section::before,
.table-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--sun), var(--accent-2));
}

.section {
    padding: 20px;
}

.section + .section,
.section + .table-panel,
.table-panel + .table-panel,
.table-panel + .section {
    margin-top: 18px;
}

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

.section-header h2,
.toolbar h2 {
    margin: 0;
    font-size: 19px;
    letter-spacing: 0;
}

.section-header p,
.toolbar p {
    margin: 4px 0 0;
    color: var(--muted);
}

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

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    font-weight: 900;
    letter-spacing: 0;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(31, 48, 74, 0.06);
}

.button.primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary), #13b6a8);
    color: #ffffff;
}

.button.primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.button.danger {
    border-color: #fecdd3;
    color: var(--danger);
}

.button:hover {
    border-color: #8fb0c9;
    transform: translateY(-1px);
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

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

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

.metric-card {
    min-height: 112px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.metric-card small {
    display: block;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 24px;
    line-height: 1.12;
    letter-spacing: 0;
}

.metric-card span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.metric-card.success {
    border-color: #86efac;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
}

.metric-card.accent {
    border-color: #bfdbfe;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
}

.metric-card.warning {
    border-color: #fde68a;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
}

.metric-card.danger {
    border-color: #fecdd3;
    background: linear-gradient(135deg, #fff1f2, #ffe4e6);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
}

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

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

.field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.field input,
.field select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    outline: none;
    padding: 9px 10px;
}

.field input:focus,
.field select:focus,
.entry-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 159, 154, 0.16);
}

.help-text {
    display: block;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}

th {
    background: linear-gradient(180deg, #f8fbff, #eef7fb);
    color: #486074;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

td:first-child,
th:first-child {
    text-align: left;
}

.table-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line);
}

.table-panel-header h2 {
    margin: 0;
    font-size: 17px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    max-width: 100%;
    padding: 4px 9px;
    border-radius: var(--radius);
    background: #e7f6f5;
    color: #0b6764;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: normal;
}

.badge.dark {
    background: #172033;
    color: #ffffff;
}

.date-cell {
    display: grid;
    gap: 2px;
    min-width: 116px;
}

.date-cell strong {
    font-size: 18px;
}

.date-cell span {
    color: var(--muted);
    font-size: 12px;
}

.sunday td {
    background: #f8fafc;
    color: #94a3b8;
}

.entry-input {
    width: 118px;
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #f7fbff;
    padding: 7px 8px;
    text-align: right;
    outline: none;
}

.entry-input:hover {
    border-color: var(--line-strong);
    background: #ffffff;
}

.readonly-cell {
    font-weight: 900;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-accent {
    color: var(--accent-2);
}

.totals-row td {
    background: #f0fdfa;
    font-weight: 900;
}

.subtle-row td {
    color: var(--muted);
    font-size: 12px;
}

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

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(0, 159, 154, 0.96), rgba(37, 99, 235, 0.9) 48%, rgba(255, 107, 74, 0.94)),
        #10243f;
}

.login-card {
    display: grid;
    grid-template-columns: minmax(0, 0.86fr) minmax(320px, 1fr);
    width: min(980px, 100%);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: 0 28px 78px rgba(11, 28, 45, 0.36);
}

.login-hero {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 520px;
    padding: 34px;
    background: linear-gradient(160deg, #0e2d48 0%, #009f9a 54%, #ff7a4f 100%);
    color: #ffffff;
}

.login-hero h1 {
    margin: 0;
    font-size: 42px;
    letter-spacing: 0;
}

.login-hero p {
    max-width: 360px;
    color: rgba(255, 255, 255, 0.82);
}

.login-body {
    display: grid;
    align-content: center;
    gap: 20px;
    padding: 42px;
}

.login-body h2 {
    margin: 0;
    font-size: 26px;
    letter-spacing: 0;
}

.error-box {
    padding: 12px;
    border: 1px solid #fecdd3;
    border-radius: var(--radius);
    background: #fff1f2;
    color: #a30f3c;
    font-weight: 800;
}

.login-footnote {
    color: #64748b;
    font-size: 12px;
}

@media (max-width: 1180px) {
    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .app-shell {
        display: block;
        width: 100%;
        padding-bottom: 86px;
    }

    .sidebar {
        position: fixed;
        inset: auto 0 0;
        z-index: 80;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 76px;
        align-items: stretch;
        gap: 6px;
        height: auto;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        overflow: visible;
        border-top: 1px solid rgba(255, 255, 255, 0.18);
        background: rgba(13, 48, 70, 0.94);
        backdrop-filter: blur(16px);
        box-shadow: 0 -14px 34px rgba(11, 28, 45, 0.18);
    }

    .brand {
        display: none;
    }

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

    .side-nav a {
        justify-content: center;
        min-height: 48px;
        padding: 7px 4px;
        font-size: 11px;
        line-height: 1.1;
        text-align: center;
        white-space: normal;
    }

    .logout-form {
        position: static;
        width: 100%;
        margin: 0;
    }

    .logout-form button {
        justify-content: center;
        width: 100%;
        min-height: 48px;
        padding: 7px 4px;
        border-color: rgba(255, 255, 255, 0.18);
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
        font-size: 11px;
        line-height: 1.1;
        text-align: center;
        box-shadow: none;
    }

    .topbar {
        position: sticky;
        min-height: 66px;
        align-items: center;
        padding: 14px;
    }

    .topbar h1 {
        font-size: 21px;
    }

    .user-chip {
        display: none;
    }

    .content {
        width: 100%;
        max-width: 100%;
        padding: 14px;
    }

    .section {
        padding: 18px 14px 14px;
    }

    .section-header,
    .toolbar,
    .table-panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .actions .field,
    .actions .button,
    .actions button.button {
        width: 100%;
    }

    .button,
    button.button {
        min-width: 0;
        white-space: normal;
    }

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

    .metric-card {
        min-height: 0;
    }

    .metric-card strong {
        font-size: 21px;
    }

    .table-wrap {
        overflow: visible;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    table {
        border-collapse: separate;
        border-spacing: 0;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 10px;
        padding: 10px;
    }

    tr {
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: #ffffff;
        box-shadow: 0 8px 18px rgba(31, 48, 74, 0.06);
    }

    td,
    td:first-child {
        display: grid;
        grid-template-columns: minmax(0, 42%) minmax(0, 58%);
        gap: 10px;
        align-items: center;
        padding: 10px 12px;
        border-bottom: 1px solid #edf3f8;
        text-align: right;
        white-space: normal;
    }

    td:last-child {
        border-bottom: 0;
    }

    td:empty {
        display: none;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 900;
        letter-spacing: 0.04em;
        text-align: left;
        text-transform: uppercase;
    }

    td:not([data-label])::before {
        content: "";
        display: none;
    }

    td:not([data-label]) {
        grid-template-columns: 1fr;
    }

    .date-cell {
        min-width: 0;
        justify-items: end;
    }

    .date-cell strong {
        font-size: 17px;
    }

    .entry-input {
        width: 100%;
        min-width: 0;
        border-color: var(--line-strong);
        background: #ffffff;
    }

    .sunday td {
        background: #f8fafc;
    }

    .totals-row td {
        background: #ecfdf5;
    }

    .login-card {
        grid-template-columns: 1fr;
    }

    .login-hero {
        min-height: 240px;
    }
}

@media (max-width: 520px) {
    body {
        font-size: 13px;
    }

    .content {
        padding: 10px;
    }

    .topbar {
        padding-left: 12px;
    }

    .eyebrow {
        font-size: 10px;
    }

    .actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .field input,
    .field select,
    .button,
    button.button {
        min-height: 38px;
    }

    .table-panel-header {
        padding: 16px 12px 12px;
    }

    tbody {
        padding: 8px;
    }

    td,
    td:first-child {
        grid-template-columns: 1fr;
        gap: 4px;
        text-align: left;
    }

    td::before {
        text-align: left;
    }

    .date-cell {
        justify-items: start;
    }

    .entry-input {
        text-align: left;
    }

    .login-page {
        padding: 12px;
    }

    .login-body,
    .login-hero {
        padding: 24px;
    }

    .login-hero h1 {
        font-size: 34px;
    }
}
