/* ============================================================
   Green Orchard Apartments — Invoice Management System
   Modern Minimal Design System
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
    /* Surfaces */
    --bg-canvas: #F9F9F7;
    --bg-surface: #FFFFFF;
    --bg-subtle: #F3F2EE;
    --bg-hover: #F7F6F2;

    /* Ink & Typography */
    --ink-primary: #141413;
    --ink-secondary: #575652;
    --ink-muted: #767570;

    /* Borders & Rules */
    --border-subtle: #E6E5E0;
    --border-strong: #CECDC7;
    --border-ink: #141413;

    /* Brand Accent — Quiet Architectural Pine */
    --accent: #1F4D3D;
    --accent-hover: #173B2E;
    --accent-soft: #ECF4F0;
    --accent-border: #C5DDD2;

    /* Primary Interactive Ink */
    --btn-primary-bg: #141413;
    --btn-primary-hover: #2A2A27;

    /* Semantic Status (calm, desaturated, paired with non-color cues) */
    --status-paid-dot: #1F6E4E;
    --status-paid-text: #17523A;
    --status-paid-bg: #ECF6F1;

    --status-unpaid-dot: #B42318;
    --status-unpaid-text: #8F1D14;
    --status-unpaid-bg: #FDF1F0;
    --status-unpaid-border: #F5CECA;

    --status-partial-dot: #B4690E;
    --status-partial-text: #854D0E;
    --status-partial-bg: #FEF7EC;
    --status-partial-border: #F5DFB8;

    /* Spacing Scale (4px rhythm) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Shadows — reserved only for elevated overlays */
    --shadow-overlay: 0 20px 44px -12px rgba(20, 20, 19, 0.16), 0 4px 12px -2px rgba(20, 20, 19, 0.06);

    /* Motion */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --transition-fast: 150ms var(--ease-out);
    --transition-base: 220ms var(--ease-out);

    /* Font */
    --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset & Browser Surfaces ──────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    color: var(--ink-primary);
    background-color: var(--bg-canvas);
    line-height: 1.55;
    min-height: 100vh;
    caret-color: var(--accent);
}

::selection {
    background: rgba(31, 77, 61, 0.14);
    color: var(--ink-primary);
}

a {
    color: var(--ink-primary);
    text-decoration: none;
    text-underline-offset: 3px;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Typography ────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--ink-primary);
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

h1 { font-size: 1.625rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.875rem; }

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ── Layout Shell ──────────────────────────────────────── */
.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    min-width: 0;
    margin: 0 auto;
    padding: var(--space-10) var(--space-6) var(--space-12);
}

.composer-shell {
    max-width: 880px;
    min-width: 0;
    margin: 0 auto;
}

.settings-shell {
    max-width: 920px;
    min-width: 0;
    margin: 0 auto;
}

/* ── Navigation ────────────────────────────────────────── */
.navbar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    max-width: 1120px;
    height: 100%;
    margin: 0 auto;
    padding: 0 var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink-primary);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    flex-shrink: 0;
}

.navbar-brand:hover {
    color: var(--ink-primary);
}

/* Circular Green Orchard crest mark */
.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    background: var(--bg-surface);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
}

.navbar-nav li {
    display: flex;
    align-items: center;
}

.navbar-nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.navbar-nav a:hover {
    background: var(--bg-subtle);
    color: var(--ink-primary);
}

.navbar-nav a.active {
    background: var(--bg-subtle);
    color: var(--ink-primary);
    font-weight: 600;
}

.navbar-nav a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.72;
}

.navbar-nav a.active svg,
.navbar-nav a:hover svg {
    opacity: 1;
}

.nav-divider {
    width: 1px;
    height: 18px;
    background: var(--border-subtle);
    margin: 0 6px;
}

.navbar-nav a.nav-logout {
    color: var(--ink-muted);
}

.navbar-nav a.nav-logout:hover {
    color: var(--status-unpaid-text);
    background: var(--status-unpaid-bg);
}

/* ── Page Header ───────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.625rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--ink-primary);
}

.page-header p {
    font-size: 0.875rem;
    color: var(--ink-secondary);
    margin-top: 4px;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: #FFFFFF;
    border-color: var(--btn-primary-bg);
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
    border-color: var(--btn-primary-hover);
    color: #FFFFFF;
}

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

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

.btn-secondary {
    background: var(--bg-surface);
    color: var(--ink-primary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--ink-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--ink-secondary);
    border-color: transparent;
    padding: 7px 10px;
}

.btn-ghost:hover {
    background: var(--bg-subtle);
    color: var(--ink-primary);
}

.btn-success {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-border);
}

.btn-success:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
}

.btn-danger {
    background: var(--status-unpaid-dot);
    color: #FFFFFF;
    border-color: var(--status-unpaid-dot);
}

.btn-danger:hover {
    background: var(--status-unpaid-text);
    border-color: var(--status-unpaid-text);
    color: #FFFFFF;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 11px 20px;
    font-size: 0.875rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    color: var(--ink-muted);
}

.btn-icon:hover {
    background: var(--bg-subtle);
    color: var(--ink-primary);
}

.btn-icon-danger:hover {
    background: var(--status-unpaid-bg);
    color: var(--status-unpaid-dot);
}

/* ── Unified Architectural KPI Ledger Strip ────────────── */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-8);
    overflow: hidden;
}

.kpi-cell {
    padding: 20px 24px;
    position: relative;
}

.kpi-cell + .kpi-cell {
    border-left: 1px solid var(--border-subtle);
}

.kpi-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-secondary);
    margin-bottom: 8px;
}

.kpi-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.kpi-dot-accent {
    background: var(--accent);
}

.kpi-dot-unpaid {
    background: var(--status-unpaid-dot);
}

.kpi-dot-neutral {
    background: var(--border-strong);
}

.kpi-value {
    font-size: clamp(1.125rem, 1.85vw, 1.4375rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--ink-primary);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kpi-currency {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-muted);
    margin-right: 4px;
    letter-spacing: 0;
}

/* ── Surfaces & Cards (Single Elevation Discipline) ────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    min-width: 0;
    max-width: 100%;
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink-primary);
}

.doc-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--ink-secondary);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

/* ── Filter Bar (Integrated Table Toolbar) ─────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.table-toolbar-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.table-count {
    font-size: 0.8125rem;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    width: 260px;
}

.search-box input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 34px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--ink-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.search-box input::placeholder {
    color: var(--ink-muted);
}

.search-box input:hover {
    border-color: var(--border-strong);
}

.search-box input:focus {
    border-color: var(--ink-primary);
    box-shadow: 0 0 0 3px rgba(20, 20, 19, 0.06);
}

.search-box svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--ink-muted);
    pointer-events: none;
}

.filter-select {
    height: 36px;
    padding: 0 32px 0 12px;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 34px;
    color: var(--ink-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767570' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-select::picker-icon,
.form-select::picker-icon {
    display: none;
}

.filter-select:hover {
    border-color: var(--border-strong);
}

.filter-select:focus {
    border-color: var(--ink-primary);
    box-shadow: 0 0 0 3px rgba(20, 20, 19, 0.06);
}

/* ── Tables ────────────────────────────────────────────── */
.table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table thead th {
    padding: 11px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.01em;
    color: var(--ink-muted);
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

table thead th:first-child {
    padding-left: 24px;
}

table thead th:last-child {
    padding-right: 24px;
}

table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--ink-primary);
}

table tbody td:first-child {
    padding-left: 24px;
    white-space: nowrap;
}

table tbody td:last-child {
    padding-right: 24px;
}

table tbody tr {
    transition: background-color var(--transition-fast);
}

table tbody tr:hover {
    background: var(--bg-hover);
}

table tbody tr:last-child td {
    border-bottom: none;
}

.invoice-link {
    font-weight: 500;
    color: var(--ink-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.cell-guest {
    min-width: 120px;
}

.invoice-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.cell-amount {
    text-align: right;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-currency {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--ink-muted);
    margin-right: 4px;
}

.cell-date {
    color: var(--ink-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* ── Status Badges (Calm dot + sentence-case label) ────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.badge-paid {
    background: var(--status-paid-bg);
    color: var(--status-paid-text);
}

.badge-paid::before {
    background: var(--status-paid-dot);
}

.badge-unpaid {
    background: var(--status-unpaid-bg);
    color: var(--status-unpaid-text);
}

.badge-unpaid::before {
    background: var(--status-unpaid-dot);
}

.badge-partial {
    background: var(--status-partial-bg);
    color: var(--status-partial-text);
}

.badge-partial::before {
    background: var(--status-partial-dot);
}

/* ── Forms ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-5);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--status-unpaid-dot);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--ink-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--ink-primary);
    box-shadow: 0 0 0 3px rgba(20, 20, 19, 0.06);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--ink-muted);
}

.form-input[type="number"],
.form-input[type="date"] {
    font-variant-numeric: tabular-nums;
}

.form-textarea {
    resize: vertical;
    min-height: 88px;
    line-height: 1.55;
}

.form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767570' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
    cursor: pointer;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--ink-muted);
    margin-top: 5px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding-top: var(--space-6);
    margin-top: var(--space-6);
    border-top: 1px solid var(--border-subtle);
}

/* ── Line Items Table (Create / Edit Invoice) ──────────── */
.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table thead th {
    padding: 10px 10px;
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ink-muted);
}

.items-table thead th:first-child {
    padding-left: 12px;
    border-top-left-radius: var(--radius-sm);
}

.items-table thead th:last-child {
    padding-right: 8px;
    border-top-right-radius: var(--radius-sm);
}

.items-table tbody td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.items-table tbody td:first-child {
    padding-left: 0;
}

.items-table tbody td:last-child {
    padding-right: 0;
}

.items-table tbody tr:hover {
    background: transparent;
}

.items-table .form-input {
    padding: 8px 10px;
    font-size: 0.875rem;
}

.items-table .col-desc { width: 44%; }
.items-table .col-qty { width: 14%; }
.items-table .col-price { width: 19%; }
.items-table .col-total { width: 18%; }
.items-table .col-action { width: 5%; text-align: center; }

.items-table .col-qty .form-input,
.items-table .col-price .form-input {
    text-align: right;
}

.items-table .line-total {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    padding: 8px 10px;
    background: var(--bg-canvas);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    text-align: right;
    color: var(--ink-primary);
    white-space: nowrap;
}

.btn-remove-item {
    background: none;
    border: none;
    color: var(--ink-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-item:hover {
    color: var(--status-unpaid-dot);
    background: var(--status-unpaid-bg);
}

.btn-remove-item svg {
    width: 16px;
    height: 16px;
}

/* ── Invoice Composer Totals ───────────────────────────── */
.invoice-totals {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-6);
}

.totals-table {
    width: 320px;
}

.totals-table .total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 8px 0;
    font-size: 0.875rem;
    color: var(--ink-primary);
}

.totals-table .total-value {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    white-space: nowrap;
}

.totals-table .currency-code {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--ink-muted);
    margin-right: 4px;
}

.totals-table .tax-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-secondary);
}

.totals-table .tax-input {
    width: 68px;
    padding: 4px 8px;
    font-size: 0.8125rem;
    text-align: right;
}

.totals-table .total-row.grand-total {
    border-top: 1px solid var(--border-ink);
    margin-top: var(--space-2);
    padding-top: var(--space-4);
    font-weight: 600;
    font-size: 1rem;
}

.totals-table .total-row.grand-total .total-value {
    font-weight: 600;
    font-size: 1.0625rem;
}

/* ── Login Page ────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-canvas);
    padding: var(--space-6);
}

.login-card {
    width: 100%;
    max-width: 396px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-10) var(--space-8);
}

.login-brand {
    text-align: center;
    margin-bottom: var(--space-8);
}

.login-logo {
    width: 184px;
    height: auto;
    margin: 0 auto var(--space-3);
    mix-blend-mode: multiply;
}

.login-subtitle {
    font-size: 0.8125rem;
    color: var(--ink-muted);
    letter-spacing: 0.01em;
}

.login-card .btn {
    width: 100%;
    margin-top: var(--space-2);
}

/* ── Alerts / Flash Messages ───────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--space-6);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.alert svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.alert-error {
    background: var(--status-unpaid-bg);
    color: var(--status-unpaid-text);
    border-color: var(--status-unpaid-border);
}

.alert-success {
    background: var(--status-paid-bg);
    color: var(--status-paid-text);
    border-color: var(--accent-border);
}

.alert-warning {
    background: var(--status-partial-bg);
    color: var(--status-partial-text);
    border-color: var(--status-partial-border);
}

/* ── Empty State ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 56px var(--space-6);
}

.empty-state-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--bg-subtle);
    color: var(--ink-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
}

.empty-state-icon svg {
    width: 20px;
    height: 20px;
}

.empty-state h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink-primary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--ink-secondary);
    max-width: 34ch;
    margin: 0 auto var(--space-5);
}

/* ── Pagination ────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    border-radius: var(--radius-md);
    color: var(--ink-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.pagination a:hover {
    background: var(--bg-subtle);
    color: var(--ink-primary);
}

.pagination .active {
    background: var(--btn-primary-bg);
    color: #FFFFFF;
    cursor: default;
}

/* ── Invoice View (Document Sheet + Action Bar) ────────── */
.invoice-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    max-width: 820px;
    margin: 0 auto var(--space-6);
    flex-wrap: wrap;
}

.invoice-action-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

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

.invoice-view {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 48px 52px;
    max-width: 820px;
    margin: 0 auto;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-8);
    margin-bottom: 36px;
    padding-bottom: 24px;
    border-bottom: 1.5px solid var(--ink-primary);
}

.invoice-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.invoice-brand-mark {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.invoice-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.invoice-brand-text h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-primary);
}

.invoice-brand-text p {
    font-size: 0.75rem;
    color: var(--ink-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 2px;
}

.invoice-title-block {
    text-align: right;
}

.invoice-title-block h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.invoice-meta {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end;
    gap: 3px 16px;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.invoice-meta dt {
    color: var(--ink-muted);
    font-weight: 400;
}

.invoice-meta dd {
    color: var(--ink-primary);
    font-weight: 500;
    text-align: right;
}

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-10);
    margin-bottom: 36px;
}

.invoice-party h4 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ink-muted);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.invoice-party p {
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--ink-secondary);
}

.invoice-party .name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--ink-primary);
}

.stay-dates {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 2px 14px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    color: var(--ink-secondary);
    font-variant-numeric: tabular-nums;
}

.stay-dates span:nth-child(odd) {
    color: var(--ink-muted);
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 28px;
}

.invoice-items-table thead th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.01em;
    color: var(--ink-secondary);
    background: var(--bg-canvas);
    border-top: 1px solid var(--ink-primary);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.invoice-items-table thead th:first-child,
.invoice-items-table tbody td:first-child {
    padding-left: 14px;
}

.invoice-items-table thead th:last-child,
.invoice-items-table tbody td:last-child {
    padding-right: 14px;
    text-align: right;
}

.invoice-items-table tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    color: var(--ink-primary);
}

.invoice-items-table tbody tr:hover {
    background: transparent;
}

.invoice-items-table .num-col {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.invoice-items-table tbody td:last-child {
    font-weight: 500;
}

.invoice-summary {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 36px;
}

.invoice-summary-table {
    width: 310px;
}

.invoice-summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-6);
    padding: 7px 0;
    font-size: 0.875rem;
}

.invoice-summary-row span:first-child {
    color: var(--ink-secondary);
    white-space: nowrap;
}

.invoice-summary-row span:last-child {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--ink-primary);
    white-space: nowrap;
    text-align: right;
}

.invoice-summary-row.total {
    border-top: 1.5px solid var(--ink-primary);
    margin-top: 8px;
    padding-top: 12px;
}

.invoice-summary-row.subtotal-rule {
    border-top: 1px solid var(--border-subtle);
    margin-top: 4px;
    padding-top: 9px;
}

.invoice-summary-row.paid span:first-child,
.invoice-summary-row.paid span:last-child {
    color: var(--status-paid-text);
}

.invoice-summary-row.total span:first-child {
    color: var(--ink-primary);
    font-weight: 600;
    font-size: 0.9375rem;
}

.invoice-summary-row.total span:last-child {
    font-weight: 600;
    font-size: 1.0625rem;
}

.doc-status {
    font-weight: 600;
    color: var(--ink-primary);
}

.doc-status-paid {
    color: var(--status-paid-text);
}

.doc-status-partial {
    color: var(--status-partial-text);
}

.invoice-flash {
    max-width: 820px;
    margin: 0 auto;
}

.action-balance-hint {
    font-size: 0.8125rem;
    color: var(--ink-secondary);
    white-space: nowrap;
}

/* ── Payments Received Statement (Inside Invoice Sheet) ── */
.invoice-payments-section {
    margin-bottom: 32px;
    padding-top: 22px;
    border-top: 1px solid var(--border-subtle);
}

.invoice-payments-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.invoice-payments-heading h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-primary);
    letter-spacing: 0.02em;
}

.invoice-payments-heading span {
    font-size: 0.75rem;
    color: var(--ink-muted);
}

.invoice-payments-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.invoice-payments-table thead th {
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ink-muted);
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.invoice-payments-table thead th:first-child,
.invoice-payments-table tbody td:first-child {
    padding-left: 12px;
}

.invoice-payments-table thead th:last-child,
.invoice-payments-table tbody td:last-child {
    padding-right: 12px;
    text-align: right;
}

.invoice-payments-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
}

.invoice-payments-table tbody tr:hover {
    background: transparent;
}

.invoice-payments-table tbody tr:last-child td {
    border-bottom: none;
}

.invoice-payments-table .num-col {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* ── Payment History Manager (Below Sheet, No Print) ───── */
.payments-manager {
    max-width: 820px;
    margin: var(--space-6) auto 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.payments-manager-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.payments-manager-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink-primary);
}

.payments-manager-header p {
    font-size: 0.8125rem;
    color: var(--ink-muted);
    margin-top: 2px;
}

.payments-manager-list {
    list-style: none;
}

.payments-manager-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.payments-manager-item:last-child {
    border-bottom: none;
}

.payments-manager-amount {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink-primary);
}

.payments-manager-meta {
    font-size: 0.8125rem;
    color: var(--ink-secondary);
    margin-top: 2px;
}

.payments-manager-note {
    color: var(--ink-muted);
}

/* ── Record Payment Modal ──────────────────────────────── */
.modal-payment {
    max-width: 468px;
}

.modal-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.modal-header-row h3 {
    margin-bottom: 2px;
}

.modal-sub {
    font-size: 0.8125rem;
    color: var(--ink-muted);
    margin-bottom: 0 !important;
}

.payment-balance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: var(--space-3);
    padding: 12px 14px;
    background: var(--bg-canvas);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
}

.payment-summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--ink-muted);
    margin-bottom: 2px;
}

.payment-summary-val {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink-primary);
    white-space: nowrap;
}

.payment-summary-val.strong {
    font-weight: 600;
    color: var(--accent);
}

.label-with-chips {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: 6px;
}

.label-with-chips .form-label {
    margin-bottom: 0;
}

.quick-fill-chips {
    display: inline-flex;
    gap: 6px;
}

.chip-btn {
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ink-secondary);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 2px 9px;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.chip-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--ink-primary);
}

.cell-sub {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--ink-muted);
    margin-top: 2px;
    white-space: nowrap;
}

.invoice-footer {
    border-top: 1px solid var(--border-subtle);
    padding-top: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-10);
    font-size: 0.8125rem;
    color: var(--ink-secondary);
}

.invoice-footer h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-primary);
    margin-bottom: 8px;
}

.invoice-footer p {
    line-height: 1.65;
}

.invoice-footer strong {
    color: var(--ink-primary);
    font-weight: 500;
}

.invoice-notes-block {
    margin-top: 18px;
}

/* ── Settings (Clean Split-Column Architectural Sheet) ─── */
.settings-sheet {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-row {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: var(--space-8);
    padding: var(--space-8);
    border-bottom: 1px solid var(--border-subtle);
}

.settings-row:last-of-type {
    border-bottom: none;
}

.settings-row-info h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink-primary);
    margin-bottom: 6px;
}

.settings-row-info p {
    font-size: 0.8125rem;
    color: var(--ink-secondary);
    line-height: 1.55;
}

.settings-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 16px var(--space-8);
    background: var(--bg-canvas);
    border-top: 1px solid var(--border-subtle);
}

/* ── Confirm Modal ─────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.36);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 160ms var(--ease-out);
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-overlay);
    max-width: 420px;
    width: 100%;
    animation: modalReveal 200ms var(--ease-out);
}

.modal h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal p {
    font-size: 0.875rem;
    color: var(--ink-secondary);
    line-height: 1.55;
    margin-bottom: var(--space-6);
}

.modal strong {
    color: var(--ink-primary);
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Utilities ─────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--ink-secondary); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-sm { margin-top: var(--space-2); }
.mt-md { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }
.mb-md { margin-bottom: var(--space-4); }
.mb-lg { margin-bottom: var(--space-6); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-4); }

/* ── Minimal Motion (User-Triggered Only) ──────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalReveal {
    from { opacity: 0; transform: translateY(6px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rowInsert {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: rowInsert 200ms var(--ease-out);
}

.input-narrow {
    max-width: 220px;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .kpi-cell {
        padding: 16px 18px;
    }
}

@media (max-width: 960px) {
    table thead th,
    table tbody td {
        padding: 12px 10px;
    }

    table thead th:first-child,
    table tbody td:first-child {
        padding-left: 16px;
    }

    table thead th:last-child,
    table tbody td:last-child {
        padding-right: 16px;
    }

    .table-actions {
        gap: 2px;
    }

    .btn-icon {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 900px) {
    .action-balance-hint {
        display: none;
    }
}

@media (max-width: 860px) {
    .settings-row {
        grid-template-columns: 1fr;
        gap: var(--space-5);
        padding: var(--space-6);
    }
}

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

    .kpi-cell:nth-child(3) {
        border-left: none;
    }

    .kpi-cell:nth-child(3),
    .kpi-cell:nth-child(4) {
        border-top: 1px solid var(--border-subtle);
    }
    .navbar-inner {
        padding: 0 var(--space-4);
    }

    .navbar-nav a span {
        display: none;
    }

    .navbar-nav a {
        padding: 8px;
    }

    .main-content {
        padding: var(--space-6) var(--space-4) var(--space-10);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: var(--space-6);
    }

    .table-toolbar {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar {
        width: 100%;
    }

    .search-box {
        flex: 1;
        width: auto;
        min-width: 180px;
    }

    table thead th:first-child,
    table tbody td:first-child {
        padding-left: 16px;
    }

    table thead th:last-child,
    table tbody td:last-child {
        padding-right: 16px;
    }

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

    .invoice-action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-action-left {
        justify-content: space-between;
    }

    .invoice-view {
        padding: 28px 20px;
    }

    .invoice-header {
        flex-direction: column;
        gap: var(--space-6);
    }

    .invoice-title-block {
        text-align: left;
    }

    .invoice-meta {
        justify-content: start;
    }

    .invoice-meta dd {
        text-align: left;
    }

    .invoice-parties,
    .invoice-footer {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }

    .invoice-summary-table,
    .totals-table {
        width: 100%;
    }

    .form-actions {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .settings-footer {
        padding: 16px var(--space-6);
    }
}

@media (max-width: 480px) {
    .kpi-strip {
        grid-template-columns: 1fr;
    }

    .kpi-cell + .kpi-cell {
        border-left: none;
        border-top: 1px solid var(--border-subtle);
    }

    .kpi-value {
        font-size: 1.375rem;
    }

    .login-card {
        padding: var(--space-8) var(--space-6);
    }
}

/* ── Print Styles ──────────────────────────────────────── */
@media print {
    body {
        background: #FFFFFF;
        color: #000000;
        font-size: 11pt;
    }

    .navbar,
    .invoice-action-bar,
    .btn,
    .no-print {
        display: none !important;
    }

    .main-content {
        padding: 0;
        max-width: none;
    }

    .invoice-view {
        border: none;
        padding: 0;
        border-radius: 0;
        max-width: none;
    }

    .invoice-header {
        border-bottom-color: #000000;
    }

    .invoice-items-table thead th,
    .invoice-payments-table thead th {
        background: #F4F4F4 !important;
        border-top-color: #000000;
        border-bottom-color: #333333;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .invoice-summary-row.total {
        border-top-color: #000000;
    }

    * {
        color: #000000 !important;
    }
}

/* ── Reduced Motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-canvas);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ink-muted);
}
