@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f2f4ef;
    --bg-soft: #e8efe8;
    --paper: #ffffff;
    --paper-alt: #fbfdfb;
    --ink: #1a2c2e;
    --muted: #5e6f72;
    --brand: #1e7a73;
    --brand-dark: #145d58;
    --brand-soft: #d4efec;
    --accent: #b9853b;
    --border: #d9e2de;
    --ok-bg: #d8f2e0;
    --ok-ink: #21643b;
    --err-bg: #f9e0de;
    --err-ink: #8f2e2b;
    --pending-bg: #f7ead7;
    --pending-ink: #805021;
    --partial-bg: #f7f1ca;
    --partial-ink: #6e5b12;
    --neutral-bg: #e5eceb;
    --neutral-ink: #3f595d;
    --paid-bg: #d9f0df;
    --paid-ink: #266746;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --shadow-1: 0 16px 36px rgba(22, 52, 54, 0.09);
    --shadow-2: 0 8px 18px rgba(22, 52, 54, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 88% 10%, rgba(184, 133, 59, 0.14), transparent 30%),
        radial-gradient(circle at 10% 22%, rgba(30, 122, 115, 0.14), transparent 34%),
        linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 40%, #f6f6f1 100%);
}

body::before,
body::after {
    content: "";
    position: fixed;
    z-index: -1;
    filter: blur(14px);
    pointer-events: none;
}

body::before {
    width: 220px;
    height: 220px;
    right: -60px;
    top: 120px;
    background: rgba(30, 122, 115, 0.12);
    border-radius: 40% 60% 58% 42% / 43% 54% 46% 57%;
}

body::after {
    width: 260px;
    height: 260px;
    left: -90px;
    bottom: 90px;
    background: rgba(185, 133, 59, 0.1);
    border-radius: 56% 44% 49% 51% / 51% 50% 50% 49%;
}

a {
    color: var(--brand-dark);
    text-decoration: none;
    transition: color 0.18s ease;
}

.container {
    width: min(1720px, 90vw);
    margin: 0 auto;
}

.topbar,
.guest-top {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(10px);
    background: linear-gradient(90deg, rgba(13, 44, 43, 0.92), rgba(19, 64, 62, 0.86));
    border-bottom: 1px solid rgba(236, 245, 243, 0.16);
}

.guest-top {
    position: relative;
}

.topbar-inner {
    min-height: 78px;
    padding: 12px 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f0f9f7;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #113735;
    background: linear-gradient(145deg, #e6f4f0, #cce8df);
    box-shadow: inset 0 -2px 0 rgba(20, 93, 88, 0.2), 0 8px 18px rgba(3, 19, 21, 0.28);
}

.brand-copy {
    display: grid;
    line-height: 1.1;
    gap: 3px;
}

.brand-copy strong {
    font-size: 1rem;
    letter-spacing: 0.2px;
}

.brand-copy small {
    color: rgba(232, 246, 243, 0.78);
    font-size: 0.73rem;
}

.tag {
    margin-left: 8px;
    padding: 5px 10px;
    border: 1px solid rgba(247, 252, 251, 0.35);
    border-radius: 999px;
    font-size: 0.74rem;
    background: rgba(240, 249, 247, 0.08);
    color: #edf9f7;
}

button.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 11px;
    border-radius: 11px;
    border: 1px solid rgba(235, 247, 245, 0.2);
    color: #eaf6f4;
    background: rgba(236, 249, 246, 0.08);
    box-shadow: none;
}

button.menu-toggle:hover {
    transform: none;
    box-shadow: none;
    background: rgba(236, 249, 246, 0.16);
}

.menu-toggle-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.menu-toggle-icon {
    position: relative;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #eaf6f4;
    transition: background-color 0.18s ease;
}

.menu-toggle-icon::before,
.menu-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #eaf6f4;
    transition: transform 0.18s ease, top 0.18s ease;
}

.menu-toggle-icon::before {
    top: -6px;
}

.menu-toggle-icon::after {
    top: 6px;
}

.topbar.nav-open .menu-toggle-icon {
    background: transparent;
}

.topbar.nav-open .menu-toggle-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.topbar.nav-open .menu-toggle-icon::after {
    top: 0;
    transform: rotate(-45deg);
}

.nav-links {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 35px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.81rem;
    font-weight: 600;
    color: rgba(235, 247, 245, 0.9);
    background: rgba(236, 249, 246, 0.05);
    border: 1px solid rgba(235, 247, 245, 0.14);
    transition: transform 0.14s ease, background-color 0.14s ease, border-color 0.14s ease;
}

.nav-links a:hover {
    transform: translateY(-1px);
    border-color: rgba(234, 247, 245, 0.42);
    background: rgba(234, 247, 245, 0.14);
}

.nav-links a.active {
    color: #113735;
    background: linear-gradient(140deg, #d6f0ec, #f6f8dc);
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(8, 25, 24, 0.24);
}

.nav-links .logout-link {
    color: #ffe9e7;
    background: rgba(198, 90, 74, 0.18);
    border-color: rgba(250, 186, 177, 0.24);
}

.nav-links .logout-link:hover {
    background: rgba(198, 90, 74, 0.3);
    border-color: rgba(250, 186, 177, 0.4);
}

.content {
    padding: 28px 0 44px;
}

.content > section:first-child:not(.card) {
    margin-bottom: 8px;
    padding-left: 2px;
}

.content > section:first-child:not(.card) h1 {
    margin-bottom: 6px;
}

.guest-content {
    padding-top: 34px;
}

section,
article {
    margin-bottom: 16px;
}

.card,
.stat-card {
    background: linear-gradient(180deg, var(--paper) 0%, var(--paper-alt) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-1);
    position: relative;
    overflow: hidden;
    animation: rise-in 0.38s ease;
}

.card::before,
.stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand) 0%, rgba(185, 133, 59, 0.95) 100%);
}

.card.narrow {
    max-width: 460px;
    margin: 40px auto;
    padding: 24px;
}

.card.narrow button {
    width: 100%;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2 {
    color: #153537;
    letter-spacing: 0.2px;
    font-weight: 700;
}

h1 {
    font-size: clamp(1.45rem, 2.4vw, 1.9rem);
    margin-bottom: 8px;
}

h2 {
    font-size: clamp(1.14rem, 1.6vw, 1.46rem);
}

h3 {
    margin-bottom: 8px;
    font-size: 0.96rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #4b6467;
}

p {
    color: var(--muted);
    line-height: 1.5;
}

small,
code {
    color: #355457;
}

code {
    padding: 1px 6px;
    border-radius: 6px;
    background: #e8f0ef;
    border: 1px solid #d6e4e2;
}

.form-grid {
    display: grid;
    gap: 13px;
}

.form-grid-inline {
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    align-items: end;
}

.form-grid label {
    display: grid;
    gap: 6px;
    font-size: 0.86rem;
    font-weight: 500;
    color: #3f5f63;
}

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

.checkbox-inline {
    display: flex !important;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.checkbox-inline input[type="checkbox"] {
    min-height: auto;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
}

.immediate-payment-panel {
    padding: 12px;
    border: 1px dashed #c7d8d5;
    border-radius: 12px;
    background: #f7fbfa;
}

.reconciliation-form {
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) auto;
    gap: 10px;
}

.reconciliation-form label {
    min-width: 0;
}

.reconciliation-form button {
    align-self: end;
    margin-bottom: 1px;
}

.desktop-two-col-form {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 12px;
}

.desktop-two-col-form label {
    min-width: 0;
}

.desktop-two-col-form .actions {
    justify-self: start;
}

.liability-payments-form {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 12px;
}

.liability-payments-form label {
    min-width: 0;
}

.liability-payments-form button {
    justify-self: start;
    align-self: end;
    width: auto;
}

.compact-filter-form {
    grid-template-columns: minmax(180px, 260px) auto;
    gap: 10px;
    margin-bottom: 10px;
}

.compact-filter-form button {
    align-self: end;
    justify-self: start;
    width: auto;
}

.payment-expense-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 10px;
}

.payment-expense-picker label {
    min-width: 0;
    flex: 1 1 360px;
    max-width: 620px;
}

.payment-expense-picker select {
    width: 100%;
}

.payment-expense-picker button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 6px 12px;
    border-radius: 10px;
    width: auto;
    margin-bottom: 1px;
    white-space: nowrap;
}

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

input,
select {
    min-height: 42px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fefefe;
    color: #213437;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: rgba(30, 122, 115, 0.65);
    box-shadow: 0 0 0 3px rgba(30, 122, 115, 0.14);
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 44px;
    border-radius: 12px;
    border-color: #c7d4d1;
    background:
        linear-gradient(45deg, transparent 50%, #5a6c6f 50%) calc(100% - 22px) 52% / 7px 7px no-repeat,
        linear-gradient(135deg, #5a6c6f 50%, transparent 50%) calc(100% - 16px) 52% / 7px 7px no-repeat,
        linear-gradient(180deg, #ffffff 0%, #f3f8f7 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 3px 8px rgba(23, 70, 67, 0.08);
}

select:hover {
    border-color: #b9c9c5;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 5px 10px rgba(23, 70, 67, 0.11);
}

select:focus {
    border-color: rgba(30, 122, 115, 0.65);
    box-shadow: 0 0 0 3px rgba(30, 122, 115, 0.14), 0 5px 10px rgba(23, 70, 67, 0.11);
}

select[multiple],
select[size]:not([size="1"]) {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    padding-right: 12px;
    background: #fefefe;
    box-shadow: none;
}

button,
.button {
    cursor: pointer;
    min-height: 42px;
    border-radius: 11px;
    border: 1px solid rgba(13, 76, 72, 0.18);
    color: #f4f9f9;
    padding: 10px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    background: linear-gradient(135deg, var(--brand) 0%, #19635e 100%);
    box-shadow: 0 10px 20px rgba(23, 84, 80, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

button:hover,
.button:hover {
    transform: translateY(-1px);
    filter: saturate(1.05);
    box-shadow: 0 12px 20px rgba(23, 84, 80, 0.28);
    color: #fff;
}

button:active,
.button:active {
    transform: translateY(0);
}

.button.button-alt {
    color: #173c3f;
    background: #eef5f4;
    border-color: #c9d9d6;
    box-shadow: none;
}

.button.button-alt:hover {
    color: #102f31;
    background: #e4efed;
    box-shadow: none;
}

.button.button-small,
button.button-small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.78rem;
    border-radius: 9px;
    box-shadow: none;
}

.button.button-danger,
button.button-danger {
    background: linear-gradient(135deg, #a84236 0%, #8f352b 100%);
    border-color: rgba(136, 40, 30, 0.3);
    color: #fff1ef;
}

.button.button-danger:hover,
button.button-danger:hover {
    filter: saturate(1.05);
    box-shadow: none;
}

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

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

.inline-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.inline-form {
    margin: 0;
}

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

.inline-form-stack select {
    min-width: 230px;
    max-width: 320px;
}

.supplier-delete-form {
    margin-top: 10px;
    grid-template-columns: auto minmax(240px, 1fr);
    align-items: center;
}

.supplier-delete-form button {
    justify-self: start;
    width: auto;
}

.supplier-delete-form small {
    display: block;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 13px;
}

.stat-card p {
    margin: 8px 0 0;
    color: #173c3f;
    font-size: clamp(1.32rem, 2.2vw, 1.7rem);
    font-weight: 800;
}

.stats-grid .stat-card:nth-child(1)::before {
    background: linear-gradient(90deg, #ad6a2f, #e2ab6d);
}

.stats-grid .stat-card:nth-child(2)::before {
    background: linear-gradient(90deg, #207b74, #57b0a7);
}

.stats-grid .stat-card:nth-child(3)::before {
    background: linear-gradient(90deg, #92594a, #d88873);
}

.stats-grid .stat-card:nth-child(4)::before {
    background: linear-gradient(90deg, #3f6883, #6fa2c4);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.card form + .table-wrap,
.card form + .stats-grid {
    margin-top: 12px;
}

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

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #4d6669;
    background: #f2f7f6;
    border-bottom: 1px solid var(--border);
    padding: 11px 10px;
}

tbody td {
    border-bottom: 1px solid #edf2f1;
    padding: 9px 10px;
    font-size: 0.9rem;
}

tbody tr:nth-child(even) {
    background: #fcfefd;
}

tbody tr:hover {
    background: #f4faf8;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.pill-pending,
.pill.pending {
    background: var(--pending-bg);
    color: var(--pending-ink);
}

.pill-partial,
.pill.partial {
    background: var(--partial-bg);
    color: var(--partial-ink);
}

.pill-paid,
.pill.paid {
    background: var(--paid-bg);
    color: var(--paid-ink);
}

.pill-neutral {
    background: var(--neutral-bg);
    color: var(--neutral-ink);
}

.flash {
    border-radius: 11px;
    padding: 11px 13px;
    margin-bottom: 12px;
    border: 1px solid transparent;
    box-shadow: var(--shadow-2);
    animation: rise-in 0.22s ease;
}

.flash-success {
    color: var(--ok-ink);
    background: var(--ok-bg);
    border-color: rgba(33, 100, 59, 0.2);
}

.flash-error {
    color: var(--err-ink);
    background: var(--err-bg);
    border-color: rgba(143, 46, 43, 0.2);
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: 14px;
}

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

.report-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
}

.report-list li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 0;
    border-bottom: 1px dashed #dbe3e0;
    font-size: 0.9rem;
}

.report-list li strong {
    color: #1f4246;
}

.entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.entry-header strong {
    color: #183d40;
    font-weight: 700;
}

.guest {
    min-height: 100vh;
}

.guest-brand {
    min-height: 74px;
    padding: 14px 0;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1280px) {
    .container {
        width: min(95vw, 95vw);
    }

    .topbar-inner {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
    }

    .tag {
        display: none;
    }

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

    .nav-links {
        display: none;
        grid-column: 1 / -1;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 8px;
        width: 100%;
        padding: 10px 0 2px;
        border-top: 1px solid rgba(235, 247, 245, 0.18);
    }

    .topbar.nav-open .nav-links {
        display: flex;
    }

    .nav-links a {
        width: 100%;
        justify-content: flex-start;
        border-radius: 12px;
        min-height: 39px;
        padding: 8px 12px;
        font-size: 0.83rem;
    }

    .nav-links a:hover {
        transform: none;
    }
}

@media (max-width: 1040px) {
    .reconciliation-form,
    .compact-filter-form,
    .payment-expense-picker,
    .desktop-two-col-form,
    .liability-payments-form {
        grid-template-columns: 1fr;
    }

    .supplier-delete-form {
        grid-template-columns: 1fr;
        align-items: end;
    }
}

@media (max-width: 760px) {
    .container {
        width: min(96vw, 96vw);
    }

    .content {
        padding: 20px 0 34px;
    }

    .card,
    .stat-card {
        border-radius: 14px;
        padding: 14px;
    }

    .brand-copy small {
        display: none;
    }

    .brand-copy strong {
        font-size: 0.95rem;
    }

    button.menu-toggle {
        min-height: 35px;
        padding: 6px 10px;
        gap: 6px;
    }

    .menu-toggle-label {
        font-size: 0.73rem;
    }

    .menu-toggle-icon,
    .menu-toggle-icon::before,
    .menu-toggle-icon::after {
        width: 16px;
    }

    .nav-links a {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 0.79rem;
    }

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

    .reconciliation-form,
    .compact-filter-form,
    .payment-expense-picker,
    .desktop-two-col-form,
    .liability-payments-form {
        grid-template-columns: 1fr;
    }

    table {
        min-width: 540px;
    }

    .role-department .department-ledger-table {
        min-width: 460px;
    }

    .role-department .department-ledger-table thead th {
        font-size: 0.67rem;
        letter-spacing: 0.05em;
        padding: 8px 6px;
    }

    .role-department .department-ledger-table tbody td {
        font-size: 0.8rem;
        padding: 7px 6px;
    }

    .role-department .department-ledger-table .pill {
        font-size: 0.63rem;
        padding: 3px 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
