/* ==========================================================================
   HMB CONSTRUCTION OPERATIONS PLATFORM - STRICT STACK CSS DESIGN SYSTEM
   Zero JavaScript • System Typography • Optimized for Office & Jobsite
   ========================================================================== */

:root {
    color-scheme: light;

    /* Base Palette */
    --ink: #18211f;
    --ink-soft: #52605c;
    --ink-muted: #7d8c87;
    --canvas: #f1f2ed;
    --surface: #ffffff;
    --surface-soft: #f8f8f4;
    --surface-subtle: #f2f4ee;

    /* Borders & Lines */
    --line: #d9ddd6;
    --line-strong: #bfc7c1;

    /* Sidebar Dark Theme */
    --sidebar: #17211f;
    --sidebar-soft: #22302d;
    --sidebar-surface: #2b3a36;
    --sidebar-line: rgba(255, 255, 255, .08);
    --sidebar-muted: #8d9e98;

    /* Brand Gold Accent */
    --accent: #c99825;
    --accent-hover: #b3851c;
    --accent-dark: #8d6812;
    --accent-soft: #fdf6e2;
    --accent-border: #e6c56d;

    /* Status Colors */
    --danger: #a33f39;
    --danger-hover: #8f342e;
    --danger-soft: #faecea;
    --danger-border: #f0bdb8;

    --success: #2e6f52;
    --success-hover: #245a42;
    --success-soft: #e4f2ea;
    --success-border: #a8d9bf;

    --warning: #8a5f0a;
    --warning-soft: #fff2d1;
    --warning-border: #f5d580;

    --info: #2d5e70;
    --info-soft: #e2eff4;
    --info-border: #a6cfdd;

    /* Shadows */
    --shadow-sm: 0 2px 6px rgba(24, 33, 31, .04);
    --shadow-md: 0 8px 22px rgba(24, 33, 31, .06);
    --shadow-lg: 0 18px 45px rgba(24, 33, 31, .09);

    /* Radius Hierarchy (8px / 14px / 18px) */
    --radius-control: 8px;
    --radius-panel: 14px;
    --radius-large: 18px;

    /* Layout Dimensions */
    --sidebar-width: 260px;
}

/* Base Reset & Typography */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background-color: var(--canvas);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-dark);
    text-decoration: none;
    transition: color .15s ease;
}

a:hover {
    color: #654906;
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: .5em;
    color: var(--ink);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.02em;
    text-wrap: balance;
}

h1 { font-size: clamp(24px, 3.2vw, 36px); }
h2 { font-size: clamp(18px, 2.2vw, 22px); }
h3 { font-size: clamp(15px, 1.8vw, 17px); }

p {
    margin-top: 0;
    margin-bottom: 1em;
    text-wrap: pretty;
}

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

.mono, .number, code, pre {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-variant-numeric: tabular-nums;
}

.number {
    text-align: right;
}

.subline {
    display: block;
    color: var(--ink-soft);
    font-size: 12px;
}

.eyebrow, .context-label, .nav-section-label {
    display: block;
    color: var(--accent-dark);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

/* Accessibility */
.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    padding: 10px 16px;
    color: var(--ink);
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: var(--radius-control);
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    transform: translateY(-160%);
    transition: transform .2s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

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

/* ==========================================================================
   BUTTONS (Design System Hierarchy)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    cursor: pointer;
    user-select: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .12s ease;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled, .btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

/* 1. Primary Action (Gold Brand) */
.btn-primary, .btn-hmb {
    color: #18211f;
    background-color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

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

/* 2. Secondary Action (Bordered) */
.btn-secondary, .btn-outline-hmb {
    color: var(--ink);
    background-color: var(--surface);
    border-color: var(--line-strong);
}

.btn-secondary:hover, .btn-outline-hmb:hover {
    color: var(--accent-dark);
    background-color: var(--accent-soft);
    border-color: var(--accent-border);
}

/* 3. Tertiary Action (Text button) */
.btn-tertiary {
    color: var(--ink-soft);
    background-color: transparent;
    border-color: transparent;
}

.btn-tertiary:hover {
    color: var(--ink);
    background-color: rgba(0, 0, 0, .04);
}

/* 4. Danger Action (Red) */
.btn-danger {
    color: #ffffff;
    background-color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    color: #ffffff;
    background-color: var(--danger-hover);
    border-color: var(--danger-hover);
}

/* 5. Success Action (Green) */
.btn-success {
    color: #ffffff;
    background-color: var(--success);
    border-color: var(--success);
}

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

/* Premium Review Action Buttons */
.action-btn-group {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
    vertical-align: middle;
}

.btn-review-approve,
.btn-review-reject {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 700;
    line-height: 30px;
    border-radius: 6px;
    box-sizing: border-box;
    vertical-align: middle;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    margin: 0;
}

.btn-review-approve {
    background: #10b981;
    color: #ffffff !important;
    border: 1px solid #059669;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.2);
}

.btn-review-approve:hover {
    background: #059669;
    border-color: #047857;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

.btn-review-approve:active {
    transform: translateY(0);
}

.btn-review-reject {
    background: #ffffff;
    color: #dc2626 !important;
    border: 1px solid #fca5a5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-review-reject:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #b91c1c !important;
    box-shadow: 0 2px 5px rgba(220, 38, 38, 0.15);
    transform: translateY(-1px);
}

.btn-review-reject:active {
    transform: translateY(0);
}

/* Sizes */
.btn-sm {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
}

.btn-lg {
    min-height: 52px;
    padding: 14px 28px;
    font-size: 16px;
    border-radius: 10px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0;
    width: 36px;
    height: 36px;
    min-height: 36px;
    border-radius: var(--radius-control);
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .02em;
    line-height: 1.25;
    white-space: nowrap;
    border: 1px solid transparent;
}

.status-active, .status-ACTIVE, .status-approved, .status-APPROVED {
    color: var(--success);
    background-color: var(--success-soft);
    border-color: var(--success-border);
}

.status-draft, .status-DRAFT, .status-PLANNING {
    color: var(--ink-soft);
    background-color: var(--surface-soft);
    border-color: var(--line);
}

.status-submitted, .status-SUBMITTED, .status-IN_PROGRESS {
    color: var(--info);
    background-color: var(--info-soft);
    border-color: var(--info-border);
}

.status-rejected, .status-REJECTED, .status-danger, .status-SUSPENDED {
    color: var(--danger);
    background-color: var(--danger-soft);
    border-color: var(--danger-border);
}

.status-revision-required {
    color: #9c4b12;
    background-color: #fcefe3;
    border-color: #f5cfaf;
}

.status-on-hold, .status-hold, .status-ON_HOLD {
    color: var(--warning);
    background-color: var(--warning-soft);
    border-color: var(--warning-border);
}

.status-finalized, .status-FINALIZED, .status-COMPLETED {
    color: #3b3a6b;
    background-color: #eeeefc;
    border-color: #c9c8f0;
}

.status-void, .status-VOID, .status-ARCHIVED {
    color: #6a6a6a;
    background-color: #eaeaea;
    border-color: #ccc;
    text-decoration: line-through;
}

.status-disabled {
    color: var(--ink-muted);
    background-color: var(--surface-soft);
    border-color: var(--line);
}

/* ==========================================================================
   ALERTS & FEEDBACK
   ========================================================================== */
.alert-box {
    margin-bottom: 20px;
    padding: 14px 18px;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius-control);
    font-size: 13px;
    line-height: 1.5;
}

.alert-box strong {
    display: block;
    margin-bottom: 2px;
}

.alert-info {
    color: var(--info);
    background-color: var(--info-soft);
    border-left-color: var(--info);
    border-color: var(--info-border);
}

.alert-success {
    color: var(--success);
    background-color: var(--success-soft);
    border-left-color: var(--success);
    border-color: var(--success-border);
}

.alert-warning {
    color: var(--warning);
    background-color: var(--warning-soft);
    border-left-color: var(--warning);
    border-color: var(--warning-border);
}

.alert-danger {
    color: var(--danger);
    background-color: var(--danger-soft);
    border-left-color: var(--danger);
    border-color: var(--danger-border);
}

/* ==========================================================================
   PANELS & CARDS
   ========================================================================== */
.panel {
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    overflow: hidden;
    margin-bottom: 20px;
}

.panel-elevated {
    border-color: transparent;
    box-shadow: var(--shadow-md);
}

.panel-header {
    display: flex;
    min-height: 56px;
    padding: 16px 20px;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background-color: var(--surface);
}

.panel-header h2, .panel-header h3 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -.01em;
}

.panel-header p {
    margin: 2px 0 0;
    color: var(--ink-soft);
    font-size: 12px;
}

.panel-body {
    padding: 20px;
}

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px 20px;
    background-color: var(--surface-soft);
    border-top: 1px solid var(--line);
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.table th {
    padding: 12px 16px;
    color: var(--ink-soft);
    background-color: var(--surface-soft);
    border-bottom: 1px solid var(--line);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td {
    padding: 14px 16px;
    min-height: 52px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--ink);
}

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

.table tbody tr:hover {
    background-color: var(--surface-subtle);
}

.table .col-action {
    text-align: right;
    white-space: nowrap;
    width: 1%;
    min-width: 160px;
}

.table-empty {
    text-align: center;
    padding: 48px 24px !important;
    color: var(--ink-soft);
}

.table-empty strong {
    display: block;
    font-size: 15px;
    color: var(--ink);
    margin-bottom: 4px;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */
.form-group {
    margin-bottom: 18px;
}

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

.form-label .req {
    color: var(--danger);
    margin-left: 2px;
}

.form-control, .form-select, textarea.form-control {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-control:hover, .form-select:hover {
    border-color: #95a39d;
}

.form-control:focus, .form-select:focus, textarea.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 152, 37, .2);
}

.form-control::placeholder {
    color: var(--ink-muted);
}

.form-text {
    display: block;
    margin-top: 5px;
    color: var(--ink-soft);
    font-size: 11px;
}

.form-error {
    display: block;
    margin-top: 5px;
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
}

/* Step Forms */
.form-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.form-step-badge {
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.form-step-badge strong {
    color: var(--accent-dark);
    font-size: 11px;
    text-transform: uppercase;
}

.form-step-badge span {
    color: var(--ink);
    font-weight: 600;
}

/* Role Choice Cards */
.role-choice-grid {
    display: grid;
    gap: 10px;
}

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

.role-create-fieldset {
    min-width: 0;
    margin: 22px 0 0;
    padding: 0;
    border: 0;
}

.role-create-fieldset legend {
    margin-bottom: 4px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
}

.role-create-fieldset > .form-text {
    margin-bottom: 12px;
}

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

.personnel-create-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding: 16px 0 0;
    background: transparent;
    border-top: 1px solid var(--line);
}

.role-choice-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.role-choice-card:hover {
    border-color: var(--accent);
    background-color: var(--accent-soft);
}

.role-choice-card input[type="checkbox"],
.role-choice-card input[type="radio"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-dark);
    cursor: pointer;
}

.role-choice-info {
    flex: 1;
}

.role-choice-info strong {
    display: block;
    font-size: 14px;
    color: var(--ink);
}

.role-choice-info small {
    display: block;
    color: var(--ink-soft);
    font-size: 12px;
    margin-top: 2px;
}

/* ==========================================================================
   APP SHELL & NAVIGATION
   ========================================================================== */
.app-shell {
    min-height: 100dvh;
    display: flex;
}

.app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background-color: var(--sidebar);
    color: #ecf0ee;
    padding: 20px 16px 16px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .08);
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 20px;
    border-bottom: 1px solid var(--sidebar-line);
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: var(--radius-control);
    background: rgba(255, 255, 255, .92);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    color: var(--sidebar);
    background-color: var(--accent);
    border-radius: 9px;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -.03em;
}

.brand-copy strong {
    display: block;
    font-size: 16px;
    line-height: 1.15;
    color: #fff;
}

.brand-copy small {
    display: block;
    color: var(--sidebar-muted);
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.sidebar-nav-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 14px 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 14px;
    color: #b3c2bc;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 550;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, .06);
    text-decoration: none;
}

.nav-link.active {
    color: #ffffff;
    background-color: var(--sidebar-soft);
    box-shadow: inset 3px 0 var(--accent);
}

/* Nav Group Dropdown (details/summary, zero JS) */
.nav-group {
    border-radius: 8px;
}

.nav-section {
    min-width: 0;
}

.nav-section > summary {
    list-style: none;
    cursor: pointer;
}

.nav-section > summary::-webkit-details-marker {
    display: none;
}

.nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 36px;
    margin: 8px 0 4px;
    padding: 8px 12px;
    border-radius: 7px;
}

.nav-section-toggle:hover,
.nav-section-toggle:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .06);
    outline: none;
}

.nav-section[open] > .nav-section-toggle .nav-chevron {
    transform: rotate(90deg);
}

.nav-section-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-group > summary {
    list-style: none;
    cursor: pointer;
}

.nav-group > summary::-webkit-details-marker {
    display: none;
}

.nav-group-toggle {
    justify-content: space-between;
}

.nav-chevron {
    font-size: 11px;
    transition: transform .2s ease;
    opacity: .6;
}

.nav-group[open] > .nav-group-toggle .nav-chevron {
    transform: rotate(90deg);
}

.nav-group-items {
    padding-left: 10px;
    margin-top: 2px;
    margin-bottom: 4px;
    border-left: 2px solid var(--sidebar-line);
    margin-left: 14px;
}

.nav-child {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 13px;
}

.nav-child.active {
    box-shadow: none;
    background-color: var(--sidebar-surface);
}

.sidebar-profile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 14px 8px 4px;
    border-top: 1px solid var(--sidebar-line);
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: #fff;
    background-color: var(--sidebar-surface);
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 11px;
}

.profile-copy strong {
    display: block;
    font-size: 12px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-copy small {
    display: block;
    color: var(--sidebar-muted);
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    padding: 6px 8px;
    color: var(--sidebar-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.btn-logout:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, .08);
}

.mobile-nav-toggle {
    display: none;
}

.mobile-taskbar {
    display: none;
}

.mobile-nav-details {
    flex: 1;
    min-height: 0;
}

@media (min-width: 901px) {
    .mobile-nav-details > .sidebar-nav-wrap {
        display: block !important;
        height: 100%;
    }
}

/* App Frame & Main Content */
.app-frame {
    flex: 1;
    min-height: 100dvh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 12px 32px;
    background-color: rgba(248, 248, 244, .95);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
}

.header-context strong {
    font-size: 13px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px;
}

.app-footer {
    width: 100%;
    padding: 16px 32px 20px;
    color: var(--ink-muted);
    border-top: 1px solid var(--line);
    background: var(--surface);
    font-size: 12px;
    font-weight: 650;
    line-height: 1.5;
    text-align: center;
}

.login-footer {
    margin-top: 30px;
    padding-top: 18px;
    color: var(--ink-muted);
    border-top: 1px solid var(--line);
    font-size: 12px;
    font-weight: 650;
    line-height: 1.5;
    text-align: center;
}

.agency-footer-preview {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

/* Page Structure */
.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-heading p {
    color: var(--ink-soft);
    margin: 4px 0 0;
    font-size: 14px;
}

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

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

/* Grids & Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

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

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, .9fr);
    gap: 24px;
    align-items: start;
}

.dashboard-stack {
    display: grid;
    gap: 20px;
}

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric {
    padding: 18px 20px;
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-sm);
}

.metric-label {
    display: block;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.metric-value {
    display: block;
    font-size: clamp(24px, 2.5vw, 32px);
    font-weight: 750;
    letter-spacing: -.03em;
    color: var(--ink);
    margin: 6px 0 4px;
}

.metric-meta {
    display: block;
    color: var(--ink-muted);
    font-size: 11px;
}

/* Task List */
.task-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

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

.task-item:last-child {
    border-bottom: 0;
}

.task-content strong {
    display: block;
    font-size: 13px;
    color: var(--ink);
}

.task-content small {
    display: block;
    color: var(--ink-soft);
    font-size: 11px;
    margin-top: 2px;
}

/* Tabs */
.tabs-nav {
    display: flex;
    gap: 6px;
    padding: 4px;
    background-color: var(--surface-subtle);
    border-radius: var(--radius-control);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-link {
    padding: 8px 16px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 650;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
}

.tab-link:hover {
    color: var(--ink);
    text-decoration: none;
}

.tab-link.active {
    color: var(--ink);
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* Pagination */
.pagination-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background-color: var(--surface);
}

.pagination {
    display: flex;
    gap: 4px;
}

.page-link {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.page-link:hover {
    background-color: var(--accent-soft);
    border-color: var(--accent-border);
    text-decoration: none;
}

.page-link.active {
    color: #18211f;
    background-color: var(--accent);
    border-color: var(--accent);
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
.login-page {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr);
    background-color: var(--surface);
}

.login-story {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100dvh;
    padding: clamp(32px, 5vw, 64px);
    color: #f8f5e8;
    background-color: var(--sidebar);
    overflow: hidden;
}

.login-story::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 85% 20%, rgba(201, 152, 37, .2), transparent 40%),
                repeating-linear-gradient(120deg, transparent 0 40px, rgba(255, 255, 255, .02) 41px 42px);
}

.login-brand, .login-message, .login-proof {
    position: relative;
    z-index: 2;
}

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

.login-brand strong {
    display: block;
    font-size: 18px;
    color: #fff;
}

.login-brand span:not(.brand-mark) {
    color: var(--sidebar-muted);
    font-size: 12px;
}

.login-message {
    max-width: 620px;
    margin: clamp(48px, 10vh, 100px) 0;
}

.login-message h1 {
    color: #fff;
    font-size: clamp(32px, 4.5vw, 54px);
    margin: 16px 0 20px;
    letter-spacing: -.04em;
}

.login-message p {
    color: #b8c7c2;
    font-size: clamp(15px, 1.4vw, 18px);
    line-height: 1.6;
    margin: 0;
}

.login-proof {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius-panel);
    overflow: hidden;
}

.login-proof div {
    padding: 16px;
    background: rgba(255, 255, 255, .03);
}

.login-proof span {
    display: block;
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.login-proof strong {
    display: block;
    color: #fff;
    font-size: 13px;
    margin-top: 4px;
}

.login-panel {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: clamp(24px, 5vw, 64px);
    background-color: var(--surface-soft);
}

.login-form-wrap {
    width: min(100%, 400px);
}

.login-form-wrap h2 {
    font-size: 26px;
    margin-bottom: 6px;
}

.login-form-wrap > p {
    color: var(--ink-soft);
    margin-bottom: 28px;
}

/* ==========================================================================
   AGENCY UI & PREVIEWS
   ========================================================================== */
.agency-3pane {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) minmax(320px, 1.1fr);
    gap: 20px;
    align-items: start;
}

.agency-screen-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.agency-screen-item {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    border-radius: 6px;
}

.agency-screen-item:hover {
    background-color: var(--surface-subtle);
    text-decoration: none;
}

.agency-screen-item.active {
    background-color: var(--accent-soft);
    font-weight: 700;
    border-left: 3px solid var(--accent);
}

.agency-field-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
}

.agency-field-heading .form-label {
    margin-bottom: 0;
}

.agency-field-kind {
    flex: 0 0 auto;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .02em;
}

.swatch-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.swatch-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.swatch-preview {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,.15);
    flex-shrink: 0;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (390px, 768px, 1280px, 1440px)
   ========================================================================== */
@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .agency-3pane {
        grid-template-columns: 240px 1fr;
    }
    .agency-3pane > :last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 0px;
    }

    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        position: static;
        width: 100%;
        padding: 14px 18px;
        box-shadow: none;
        border-bottom: 1px solid var(--sidebar-line);
    }

    .mobile-nav-details {
        display: block;
        min-height: auto;
    }

    .brand-lockup {
        padding: 0;
        border-bottom: 0;
    }

    .mobile-nav-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-top: 12px;
        min-height: 48px;
        padding: 10px 14px;
        color: #ffffff;
        background-color: var(--sidebar-soft);
        border: 1px solid var(--sidebar-line);
        border-radius: var(--radius-control);
        cursor: pointer;
        font-size: 13px;
        font-weight: 650;
        user-select: none;
    }

    .mobile-nav-toggle small {
        color: var(--sidebar-muted);
        font-size: 10px;
        font-weight: 500;
    }

    .mobile-nav-details:not([open]) .sidebar-nav-wrap {
        display: none;
    }

    .sidebar-nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding-top: 10px;
    }

    .nav-section-label {
        grid-column: 1 / -1;
        margin-top: 10px;
    }

    .sidebar-nav > .nav-section,
    .sidebar-nav > .nav-group {
        grid-column: 1 / -1;
    }

    .sidebar-profile {
        display: none;
    }

    .app-frame {
        margin-left: 0;
    }

    .app-header {
        padding: 12px 18px;
    }

    .app-main {
        padding: 20px 16px 104px;
    }

    .app-footer {
        padding: 15px 18px calc(82px + env(safe-area-inset-bottom));
    }

    .mobile-taskbar {
        position: fixed;
        bottom: max(8px, env(safe-area-inset-bottom));
        left: 50%;
        z-index: 60;
        display: grid;
        width: min(520px, calc(100% - 16px));
        grid-template-columns: repeat(var(--mobile-task-columns, 5), minmax(0, 1fr));
        gap: 2px;
        padding: 5px;
        background: rgba(16, 31, 27, .96);
        border: 1px solid rgba(255, 255, 255, .14);
        border-radius: 18px;
        box-shadow: 0 18px 42px rgba(8, 22, 18, .32), inset 0 1px rgba(255, 255, 255, .06);
        transform: translateX(-50%);
        backdrop-filter: blur(18px) saturate(130%);
    }

    .mobile-taskbar-link {
        position: relative;
        display: grid;
        grid-template-rows: 28px minmax(2.3em, auto);
        justify-items: center;
        align-items: center;
        gap: 2px;
        min-width: 0;
        min-height: 62px;
        padding: 7px 2px 6px;
        color: #b8c7c1;
        border: 1px solid transparent;
        border-radius: 13px;
        font-size: 10px;
        font-weight: 650;
        line-height: 1.12;
        text-align: center;
        text-decoration: none;
        transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .16s ease;
    }

    .mobile-taskbar-form {
        position: relative;
        min-width: 0;
        margin: 0;
    }

    .mobile-taskbar-form::before {
        position: absolute;
        top: 10px;
        bottom: 10px;
        left: -2px;
        width: 1px;
        content: "";
        background: rgba(255, 255, 255, .1);
    }

    .mobile-taskbar-form .mobile-taskbar-link {
        width: 100%;
        appearance: none;
        cursor: pointer;
        font-family: inherit;
    }

    .mobile-taskbar-logout {
        color: #ffd8d2;
        background: transparent;
    }

    .mobile-taskbar-logout .mobile-taskbar-icon {
        color: #ff9f91;
        background: rgba(255, 122, 103, .1);
    }

    .mobile-taskbar-link:hover,
    .mobile-taskbar-link:focus-visible,
    .mobile-taskbar-link.active {
        color: #fff;
        background: rgba(255, 255, 255, .075);
        border-color: rgba(255, 255, 255, .08);
        text-decoration: none;
    }

    .mobile-taskbar-link.active {
        background: rgba(255, 255, 255, .1);
        box-shadow: inset 0 1px rgba(255, 255, 255, .07);
    }

    .mobile-taskbar-link:active {
        transform: translateY(1px) scale(.98);
    }

    .mobile-taskbar-icon {
        display: grid;
        place-items: center;
        width: 28px;
        height: 28px;
        color: var(--accent);
        border-radius: 9px;
        transition: color .2s ease, background-color .2s ease, transform .2s ease;
    }

    .mobile-taskbar-icon svg {
        width: 19px;
        height: 19px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .mobile-taskbar-link.active .mobile-taskbar-icon {
        color: var(--sidebar);
        background: var(--accent);
        transform: translateY(-1px);
    }

    .mobile-taskbar-label {
        display: flex;
        min-height: 2.3em;
        align-items: flex-start;
        justify-content: center;
        text-wrap: balance;
    }

    .mobile-taskbar-all .mobile-taskbar-icon {
        color: var(--sidebar);
        background: var(--accent);
    }

    @media (max-width: 360px) {
        .mobile-taskbar {
            width: calc(100% - 10px);
            padding: 4px;
        }

        .mobile-taskbar-link {
            min-height: 59px;
            padding-inline: 1px;
            font-size: 9px;
        }
    }

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

    .grid-2, .grid-3, .personnel-contact-grid, .role-choice-grid-create {
        grid-template-columns: 1fr;
    }

    .agency-3pane {
        grid-template-columns: minmax(0, 1fr);
    }

    .agency-3pane > :last-child {
        grid-column: auto;
    }

    .form-steps {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .login-story {
        min-height: auto;
        padding: 32px 24px;
    }

    .login-message {
        margin: 40px 0 24px;
    }

    .login-proof {
        display: none;
    }

    .login-panel {
        min-height: auto;
        padding: 40px 20px 60px;
    }
}

@media (max-width: 560px) {
    .page-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions {
        margin-top: 12px;
    }

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

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

    .app-header {
        align-items: flex-start;
    }

    .header-actions .status-badge {
        display: none;
    }

    .header-context strong {
        display: block;
        max-width: 72vw;
        overflow-wrap: anywhere;
    }

    .personnel-create-actions {
        flex-direction: column-reverse;
    }

    .personnel-create-actions .btn,
    .panel-footer .btn {
        width: 100%;
        min-height: 44px;
    }

    .role-choice-card {
        min-height: 58px;
        padding: 13px 14px;
    }

    .form-control, .form-select {
        font-size: 16px; /* Prevents auto zoom on mobile iOS/Android */
    }

    .pagination-wrap {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .pagination {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
.finance-heading{align-items:flex-end}.finance-tabs{display:flex;gap:6px;width:max-content;max-width:100%;padding:5px;margin:-8px 0 22px;border:1px solid var(--line);border-radius:12px;background:var(--surface);overflow-x:auto}.finance-tabs a{padding:9px 15px;border-radius:8px;color:var(--ink-soft);font-size:13px;font-weight:700;text-decoration:none;white-space:nowrap}.finance-tabs a:hover{color:var(--ink);background:var(--canvas)}.finance-tabs a.is-active{color:#fff;background:var(--ink);box-shadow:0 4px 12px rgba(15,35,31,.18)}.section-kicker{display:block;margin-bottom:5px;color:var(--brand,#b27b0d);font-size:10px;font-weight:800;letter-spacing:.12em;text-transform:uppercase}.step-chip,.count-chip{align-self:flex-start;padding:6px 9px;border:1px solid var(--line);border-radius:999px;color:var(--ink-soft);background:var(--canvas);font-size:11px;font-weight:700;white-space:nowrap}.finance-create{border-top:3px solid var(--brand,#c99118)}.finance-form-row{display:grid;grid-template-columns:minmax(180px,1fr) minmax(180px,1fr) auto;gap:14px;align-items:end}.bonus-form-row{grid-template-columns:minmax(260px,1.5fr) minmax(160px,.8fr) minmax(160px,.8fr) auto}.finance-form-row .form-group{margin:0}.finance-submit{min-height:42px}.finance-summary{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin:18px 0}.finance-summary article{position:relative;min-width:0;padding:18px 19px;border:1px solid var(--line);border-radius:12px;background:var(--surface);overflow:hidden}.finance-summary article:before{content:'';position:absolute;inset:0 auto 0 0;width:3px;background:#d6a12c}.finance-summary span,.formula-flow span{display:block;margin-bottom:7px;color:var(--ink-soft);font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em}.finance-summary strong{display:block;overflow:hidden;color:var(--ink);font-size:clamp(18px,2vw,25px);line-height:1.1;text-overflow:ellipsis}.finance-summary small,.formula-flow small{display:block;margin-top:5px;color:var(--ink-muted);font-size:10px}.finance-summary .accent-card{border-color:#d3a440;background:#fff9e9}.finance-detail-header{gap:18px}.finance-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.finance-actions form{margin:0}.meta-separator{padding:0 5px;color:var(--ink-muted)}.snapshot-strip{display:flex;align-items:center;gap:12px;min-width:0;padding:10px 16px;border-top:1px solid var(--line);border-bottom:1px solid var(--line);background:var(--canvas)}.snapshot-strip span{flex:0 0 auto;color:var(--ink-soft);font-size:10px;font-weight:800;text-transform:uppercase}.snapshot-strip code{min-width:0;overflow:hidden;color:var(--ink-soft);font-size:11px;text-overflow:ellipsis;white-space:nowrap}.total-cell{color:var(--ink);font-weight:800}.kpi-score{display:inline-flex;justify-content:center;min-width:43px;padding:4px 7px;border-radius:7px;color:#136447;background:#eaf7f0;font-weight:800}.finance-note{align-items:flex-start;justify-content:flex-start;gap:10px}.finance-note span{color:var(--ink);font-size:11px;font-weight:800;text-transform:uppercase}.finance-note p{margin:0;color:var(--ink-soft);font-size:12px}.history-panel{margin-top:18px}.formula-flow{display:grid;grid-template-columns:1fr auto 1fr auto 1fr auto 1fr;gap:12px;align-items:center;padding:18px;border-top:1px solid var(--line);background:#fbfaf6}.formula-flow>div{min-width:0;padding:12px;border:1px solid var(--line);border-radius:9px;background:var(--surface)}.formula-flow strong{font-size:15px}.formula-flow>b{color:var(--ink-muted);font-size:18px}.formula-flow .formula-result{border-color:#cda33d;background:#fff8e5}@media(max-width:1050px){.finance-summary{grid-template-columns:repeat(2,1fr)}.bonus-form-row{grid-template-columns:1fr 1fr}.bonus-form-row .project-field{grid-column:1/-1}.formula-flow{grid-template-columns:1fr 1fr}.formula-flow>b{display:none}}@media(max-width:680px){.finance-heading{align-items:flex-start}.finance-form-row,.bonus-form-row{grid-template-columns:1fr}.bonus-form-row .project-field{grid-column:auto}.finance-submit{width:100%}.finance-summary{grid-template-columns:1fr}.finance-detail-header{align-items:flex-start}.finance-actions{width:100%}.finance-actions form,.finance-actions .btn{width:100%}.formula-flow{grid-template-columns:1fr}}

/* ==========================================================================
   SALARY RULES WARNING PANEL
   ========================================================================== */
.salary-rules {
    margin-bottom: 20px;
    padding: 18px 22px;
    background-color: #fff8e5;
    border: 1px solid var(--warning-border);
    border-left-width: 4px;
    border-left-color: var(--warning);
    border-radius: var(--radius-panel);
}

.salary-rules h3 {
    margin: 0 0 10px;
    color: var(--warning);
    font-size: 15px;
}

.salary-rules ul {
    margin: 0;
    padding-left: 20px;
}

.salary-rules li {
    margin-bottom: 6px;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
}

.salary-rules li strong {
    color: var(--warning);
}

/* ==========================================================================
   KPI CONFIG FORM
   ========================================================================== */
.kpi-group-panel {
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    overflow: hidden;
}

.kpi-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background-color: var(--surface-soft);
    border-bottom: 1px solid var(--line);
}

.kpi-group-header h3 {
    margin: 0;
    font-size: 15px;
}

.kpi-group-weight {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    background-color: var(--accent-soft);
    color: var(--accent-dark);
    border: 1px solid var(--accent-border);
}

.kpi-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background-color: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    margin-top: 12px;
}

.kpi-total-bar.kpi-valid {
    border-color: var(--success-border);
    background-color: var(--success-soft);
}

.kpi-total-bar.kpi-invalid {
    border-color: var(--danger-border);
    background-color: var(--danger-soft);
}

/* ==========================================================================
   GRID UTILITIES
   ========================================================================== */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 900px) {
    .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   CENTERED MODAL OVERLAY (Pure CSS / HTML5 details/summary)
   ========================================================================== */
.modal-expand {
    display: inline-block;
}

.modal-expand > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.modal-expand > summary::-webkit-details-marker {
    display: none;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 21, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-overlay:target {
    display: flex;
}

details[open] > .modal-overlay {
    display: flex;
}

.modal-backdrop-exit {
    position: fixed;
    inset: 0;
    background: transparent;
    cursor: default;
    z-index: 1;
}

.modal-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--line);
    width: min(680px, 96vw);
    max-height: 88vh;
    overflow-y: auto;
    padding: 28px;
    text-align: left;
    position: relative;
    z-index: 2;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.modal-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--ink-soft);
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.modal-close-btn:hover {
    background: var(--line);
    color: var(--ink);
}

/* ==========================================================================
   MOCKUP-INSPIRED TASTE-SKILL STYLING (Lương tháng KPI & Thưởng dự án)
   ========================================================================== */
.page-title-group {
    margin-bottom: 24px;
}

.page-main-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent-dark, #8d6812);
    margin: 0 0 4px;
    letter-spacing: -.02em;
}

.page-sub-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    color: var(--ink-soft);
    text-transform: uppercase;
    margin: 0;
}

/* Two-column layout */
.two-col-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 980px) {
    .two-col-layout {
        grid-template-columns: 1fr;
    }
}

/* Left sidebar cards */
.side-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.side-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 14px;
}

.month-picker-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface-soft);
    font-weight: 700;
    font-size: 15px;
}

.month-picker-bar a {
    color: var(--ink-soft);
    font-size: 16px;
    padding: 2px 8px;
    border-radius: 4px;
    text-decoration: none;
}

.month-picker-bar a:hover {
    background: var(--line);
    color: var(--ink);
}

/* Blue Salary Rule Card */
.rule-card-blue {
    background: #f4f8fd;
    border: 1px solid #d0e3f8;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
}

.rule-card-blue h4 {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rule-card-blue ul {
    margin: 0;
    padding-left: 18px;
}

.rule-card-blue li {
    font-size: 13px;
    line-height: 1.55;
    color: #1e293b;
    margin-bottom: 6px;
}

/* Pink Penalty Rule Card */
.rule-card-pink {
    background: #fdf5f5;
    border: 1px solid #fed7d7;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
}

.rule-card-pink h4 {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #c53030;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rule-card-pink ul {
    margin: 0;
    padding-left: 18px;
}

.rule-card-pink li {
    font-size: 13px;
    line-height: 1.55;
    color: #742a2a;
    margin-bottom: 6px;
}

/* 4 Metrics Cards for Thưởng Dự án */
.bonus-top-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 900px) {
    .bonus-top-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .bonus-top-metrics {
        grid-template-columns: 1fr;
    }
}

.b-metric-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.b-metric-card span {
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 6px;
}

.b-metric-card strong {
    display: block;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--ink);
}

.b-metric-red {
    background: #fff5f5;
    border-color: #feb2b2;
}

.b-metric-red span {
    color: #c53030;
}

.b-metric-red strong {
    color: #c53030;
}

.b-metric-orange {
    background: #fffaf0;
    border-color: #feebc8;
}

.b-metric-orange span {
    color: #c05621;
}

.b-metric-orange strong {
    color: #c05621;
}

.b-metric-green {
    background: #f0fff4;
    border-color: #9ae6b4;
}

.b-metric-green span {
    color: #276749;
}

.b-metric-green strong {
    color: #22543d;
}

/* Highlighted Table Headers */
.th-real-salary {
    background: #ebf5ff !important;
    color: #1e40af !important;
    font-weight: 800 !important;
}

.th-bonus {
    background: #f0fdf4 !important;
    color: #166534 !important;
    font-weight: 800 !important;
}

.th-total-income {
    background: #f8fafc !important;
    color: #0f172a !important;
    font-weight: 800 !important;
}

.page-footer-copy {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--ink-muted);
    text-transform: uppercase;
}

.history-list {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.history-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.history-list-item:first-child {
    padding-top: 0;
}

.history-list-item > div:first-child span {
    display: block;
    margin-top: 3px;
    color: var(--ink-soft);
    font-size: 12px;
}

.history-list-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.form-section-title {
    margin: 0 0 12px;
    font-size: 15px;
}

.report-work-row {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--line);
}

.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.attachment-item {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
}

.attachment-item img {
    display: block;
    width: 100%;
    height: 130px;
    object-fit: cover;
    background: var(--surface-muted);
}

.attachment-item > div {
    display: grid;
    gap: 5px;
    padding: 10px;
    font-size: 12px;
}

.attachment-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.material-inline-form {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) auto;
    align-items: end;
    gap: 8px;
    min-width: 340px;
}

.material-inline-form label > span {
    display: block;
    margin-bottom: 4px;
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
}

.material-inline-form .form-control {
    min-height: 34px;
    padding: 6px 8px;
}

.danger-zone {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.danger-zone .panel-header {
    background: color-mix(in srgb, var(--danger) 5%, var(--surface));
}

.report-notes {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.report-notes p {
    margin: 6px 0 0;
    line-height: 1.65;
}

@media (max-width: 600px) {
    .history-list-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-list-actions {
        justify-content: flex-start;
    }
}
