/* ============================================================
   style.css — Construction IMS
   Design language: professional, clean, construction-sector
   Compatible: modern browsers, mobile-first responsive
   ============================================================ */

/* ----------------------------------------------------------
   CSS Custom Properties (Design Tokens)
   ---------------------------------------------------------- */
:root {
    --color-primary:       #1a1a2e;   /* Deep navy — header, sidebar    */
    --color-primary-light: #16213e;   /* Slightly lighter navy           */
    --color-accent:        #e8a020;   /* Construction amber              */
    --color-accent-hover:  #d4911a;   /* Darker amber for hover states   */
    --color-success:       #2e7d32;
    --color-error:         #c62828;
    --color-warning:       #e65100;
    --color-info:          #01579b;
    --color-bg:            #f4f6f9;   /* Page background                 */
    --color-surface:       #ffffff;   /* Card / panel background         */
    --color-border:        #dde1e7;
    --color-text:          #1c1c1e;
    --color-text-muted:    #6b7280;
    --color-text-light:    #9ca3af;

    --font-base:    'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:    'Consolas', 'Courier New', monospace;

    --radius-sm:    4px;
    --radius-md:    8px;
    --radius-lg:    12px;

    --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
    --shadow-md:    0 4px 12px rgba(0,0,0,.10);
    --shadow-lg:    0 8px 24px rgba(0,0,0,.12);

    --navbar-height: 60px;
    --sidebar-width: 240px;
    --transition:    0.2s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family:      var(--font-base);
    background-color: var(--color-bg);
    color:            var(--color-text);
    line-height:      1.6;
    min-height:       100vh;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); text-decoration: underline; }

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

/* ----------------------------------------------------------
   Layout — Auth Pages
   ---------------------------------------------------------- */
.auth-page {
    display:         flex;
    align-items:     center;
    justify-content: center;
    min-height:      100vh;
    padding:         1.5rem;
    background:      linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
}

.auth-container {
    display:               grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
    align-items:           stretch;
    gap:                   1.25rem;
    width:                 100%;
    max-width:             980px;
}

.auth-brand-panel,
.auth-card {
    border-radius: var(--radius-lg);
    box-shadow:    var(--shadow-lg);
}

.auth-brand-panel {
    position:   relative;
    overflow:   hidden;
    display:    flex;
    min-height: 100%;
    padding:    2rem;
    color:      #fff;
    background:
        radial-gradient(circle at top left, rgba(232, 160, 32, .22), transparent 34%),
        linear-gradient(145deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
    border: 1px solid rgba(255,255,255,.14);
}

.auth-brand-panel::after {
    content: '';
    position: absolute;
    right:    -80px;
    bottom:   -80px;
    width:    190px;
    height:   190px;
    border:   28px solid rgba(232, 160, 32, .14);
    transform: rotate(18deg);
}

.auth-brand-inner {
    position:        relative;
    z-index:         1;
    display:         flex;
    flex-direction:  column;
    justify-content: center;
    gap:             1.5rem;
    width:           100%;
}

.auth-logo-frame {
    width:         min(230px, 100%);
    padding:       1rem;
    border-radius: 20px;
    background:    rgba(255,255,255,.96);
    box-shadow:    var(--shadow-md);
}

.auth-brand-logo {
    width:  100%;
    height: auto;
}

.auth-brand-copy {
    max-width: 420px;
}

.auth-brand-eyebrow {
    margin-bottom: .5rem;
    color:         var(--color-accent);
    font-size:     .78rem;
    font-weight:   700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.auth-brand-copy h1 {
    margin-bottom: .65rem;
    font-size:     clamp(1.65rem, 4vw, 2.35rem);
    line-height:   1.1;
    font-weight:   800;
    letter-spacing: .4px;
}

.auth-brand-copy p:last-child {
    max-width:   35rem;
    color:       rgba(255,255,255,.78);
    font-size:   .95rem;
    line-height: 1.7;
}

.auth-form-panel {
    display:         flex;
    flex-direction:  column;
    justify-content: center;
}

.auth-card {
    background: var(--color-surface);
    padding:    2rem;
}

.auth-card h2 {
    font-size:     1.25rem;
    margin-bottom: 1.5rem;
    color:         var(--color-primary);
}

.auth-card-note {
    margin-bottom: 1.25rem;
    font-size:     .875rem;
    color:         var(--color-text-muted);
}

.auth-form-actions {
    margin-top:  .25rem;
    padding-top: 0;
    border-top:  none;
}

.auth-link-note {
    margin-top: 1.25rem;
    font-size:  .875rem;
    text-align: center;
}

.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size:  .8rem;
    color:      rgba(255,255,255,.55);
}

/* ----------------------------------------------------------
   Layout — App Shell (authenticated pages)
   ---------------------------------------------------------- */
.app-wrapper {
    display:        flex;
    flex-direction: column;
    min-height:     100vh;
}

/* Top Navbar */
.navbar {
    position:        fixed;
    top:             0;
    left:            0;
    right:           0;
    height:          var(--navbar-height);
    background:      var(--color-primary);
    display:         flex;
    align-items:     center;
    padding:         0 1.5rem;
    z-index:         1000;
    box-shadow:      var(--shadow-md);
}

.navbar-brand {
    color:       var(--color-accent);
    font-size:   1.1rem;
    font-weight: 700;
    letter-spacing: .4px;
    flex:        1;
}

.navbar-user {
    display:     flex;
    align-items: center;
    gap:         1rem;
    color:       rgba(255,255,255,.8);
    font-size:   .875rem;
}

.navbar-user .role-badge {
    background:    rgba(255,255,255,.12);
    border-radius: var(--radius-sm);
    padding:       2px 8px;
    font-size:     .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.navbar-hamburger {
    display:    none;
    background: none;
    border:     none;
    cursor:     pointer;
    padding:    .5rem;
    color:      #fff;
    font-size:  1.25rem;
    margin-right: .75rem;
}

/* Sidebar */
.sidebar {
    position:   fixed;
    top:        var(--navbar-height);
    left:       0;
    bottom:     0;
    width:      var(--sidebar-width);
    background: var(--color-primary-light);
    overflow-y: auto;
    z-index:    900;
    transition: transform var(--transition);
}

.sidebar-nav { padding: .75rem 0; }

.sidebar-section {
    padding:     .5rem 1rem .25rem;
    font-size:   .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color:       rgba(255,255,255,.35);
    margin-top:  .5rem;
}

.sidebar-nav a {
    display:     flex;
    align-items: center;
    gap:         .625rem;
    padding:     .6rem 1.25rem;
    color:       rgba(255,255,255,.78);
    font-size:   .875rem;
    transition:  background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background:  rgba(255,255,255,.07);
    color:       #fff;
    border-left-color: var(--color-accent);
    text-decoration: none;
}

.sidebar-nav a .nav-icon { width: 18px; text-align: center; font-style: normal; }

/* Main Content Area */
.main-content {
    margin-left:  var(--sidebar-width);
    margin-top:   var(--navbar-height);
    padding:      1.75rem;
    flex:         1;
}

/* ----------------------------------------------------------
   Page Header
   ---------------------------------------------------------- */
.page-header {
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap:     wrap;
    gap:           .75rem;
}

.page-header h1 {
    font-size:   1.4rem;
    font-weight: 700;
    color:       var(--color-primary);
}

.page-header .breadcrumb {
    font-size: .8rem;
    color:     var(--color-text-muted);
    margin-top: .2rem;
}

.page-header .breadcrumb a { color: var(--color-text-muted); }
.page-header .breadcrumb a:hover { color: var(--color-accent); }

/* Right-side action button group within .page-header */
.page-header-actions {
    display:     flex;
    gap:         .5rem;
    align-items: center;
    flex-wrap:   wrap;
}

/* ----------------------------------------------------------
   Cards
   ---------------------------------------------------------- */
.card {
    background:    var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow:    var(--shadow-sm);
    border:        1px solid var(--color-border);
    overflow:      hidden;
}

.card-header {
    padding:        1rem 1.25rem;
    border-bottom:  1px solid var(--color-border);
    display:        flex;
    align-items:    center;
    justify-content: space-between;
    gap:            .75rem;
}

.card-header h2 {
    font-size:   1rem;
    font-weight: 600;
    color:       var(--color-primary);
}

.card-body { padding: 1.25rem; }

/* ----------------------------------------------------------
   Stat Cards (Dashboard)
   ---------------------------------------------------------- */
.stats-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap:                   1rem;
    margin-bottom:         1.5rem;
}

.stat-card {
    background:    var(--color-surface);
    border-radius: var(--radius-md);
    padding:       1.25rem;
    box-shadow:    var(--shadow-sm);
    border:        1px solid var(--color-border);
    border-left:   4px solid var(--color-accent);
    display:       flex;
    flex-direction: column;
    gap:           .375rem;
}

.stat-card .stat-label {
    font-size:  .8rem;
    font-weight: 500;
    color:      var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.stat-card .stat-value {
    font-size:   2rem;
    font-weight: 700;
    color:       var(--color-primary);
    line-height: 1;
}

.stat-card .stat-sub {
    font-size: .8rem;
    color:     var(--color-text-muted);
}

/* Accent variations */
.stat-card.accent-success { border-left-color: var(--color-success); }
.stat-card.accent-error   { border-left-color: var(--color-error);   }
.stat-card.accent-info    { border-left-color: var(--color-info);    }
.stat-card.accent-warning { border-left-color: var(--color-warning); }

/* ----------------------------------------------------------
   Tables
   ---------------------------------------------------------- */
.table-wrapper { overflow-x: auto; }

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

thead th {
    background:     var(--color-bg);
    padding:        .65rem 1rem;
    text-align:     left;
    font-size:      .75rem;
    font-weight:    600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color:          var(--color-text-muted);
    border-bottom:  2px solid var(--color-border);
    white-space:    nowrap;
}

tbody td {
    padding:        .75rem 1rem;
    border-bottom:  1px solid var(--color-border);
    vertical-align: middle;
}

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

tbody tr:hover { background: #fafbfc; }

.td-actions {
    display:     flex;
    gap:         .5rem;
    align-items: center;
    flex-wrap:   wrap;
}

/* Right-aligned, tabular-numeral column for stock quantities */
.col-qty {
    text-align:           right;
    font-variant-numeric: tabular-nums;
    white-space:          nowrap;
}

/* ----------------------------------------------------------
   Badges
   ---------------------------------------------------------- */
.badge {
    display:       inline-block;
    padding: 0.25rem 0.45rem;
    border-radius: 999px;
    font-size:     .64rem;
    font-weight:   600;
    text-transform: uppercase;
    letter-spacing: .4px;
	white-space: nowrap;
    word-break: normal;
}

.badge-success { background: #e8f5e9; color: var(--color-success); }
.badge-error   { background: #ffebee; color: var(--color-error);   }
.badge-warning { background: #fff3e0; color: var(--color-warning); }
.badge-info    { background: #e3f2fd; color: var(--color-info);    }
.badge-muted   { background: #f1f3f5; color: var(--color-text-muted); }
.badge-accent  { background: #fff8e1; color: var(--color-accent);  }
.badge-primary { background: #e8eaf6; color: var(--color-primary); }

/* ----------------------------------------------------------
   Forms
   Two form layout systems are used across the codebase:

   1. .field — single-column stacked layout. Used in Phase 8+
      management forms (sites, users, stock/add). Each .field
      wraps one label + one input/select/textarea.

   2. .form-group / .form-grid — older responsive grid layout.
      .form-grid creates a multi-column auto-fit grid;
      .form-group is the per-cell wrapper. Still present in
      earlier modules and add.php pre-patch. Do not remove.

   Both systems share the same base input/label/button styles.
   ---------------------------------------------------------- */

/* --- System 1: .field (single-column, Phase 8+) --- */
.field {
    display:        flex;
    flex-direction: column;
    gap:            .35rem;
    margin-bottom:  1rem;
}

/* --- System 2: .form-group / .form-grid (grid-based) --- */
.form-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap:                   1rem;
}

.form-group {
    display:        flex;
    flex-direction: column;
    gap:            .35rem;
	margin-bottom:  1rem;
}

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

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

label {
    font-size:   .825rem;
    font-weight: 600;
    color:       var(--color-text);
}

/* Child span asterisk: <label>Name <span class="required">*</span></label> */
label .required { color: var(--color-error); margin-left: 2px; }

/* Direct class on label element: <label class="required"> — appends asterisk via CSS */
label.required::after { content: ' *'; color: var(--color-error); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width:         100%;
    padding:       .55rem .75rem;
    border:        1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size:     .875rem;
    font-family:   var(--font-base);
    color:         var(--color-text);
    background:    var(--color-surface);
    transition:    border-color var(--transition), box-shadow var(--transition);
    appearance:    none;
}

input[type="date"] {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: var(--font-base);
    color: var(--color-text);
    background: var(--color-surface);
    line-height: 1.4;
    min-height: 38px;
    -webkit-appearance: none;
    appearance: none;
}

input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .8;
}

input[type="month"] {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: var(--font-base);
    color: var(--color-text);
    background: var(--color-surface);
    line-height: 1.4;
    min-height: 38px;
    -webkit-appearance: none;
    appearance: none;
}

input[type="month"]::-webkit-datetime-edit {
    text-align: left;
}

input[type="month"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .8;
}

input[type="month"]:focus {
    outline:      none;
    border-color: var(--color-accent);
    box-shadow:   0 0 0 3px rgba(232, 160, 32, .15);
}

input:focus,
select:focus,
textarea:focus {
    outline:      none;
    border-color: var(--color-accent);
    box-shadow:   0 0 0 3px rgba(232, 160, 32, .15);
}

textarea { resize: vertical; min-height: 90px; }

.form-hint {
    font-size: .775rem;
    color:     var(--color-text-muted);
}

.field-hint {
    font-size:   .775rem;
    font-weight: 400;
    color:       var(--color-text-muted);
}

/* Validation error state on an input/select/textarea */
.input-error {
    border-color: var(--color-error) !important;
    box-shadow:   0 0 0 3px rgba(198, 40, 40, .12);
}

/* Inline error message rendered below a field */
.field-error {
    font-size: .775rem;
    color:     var(--color-error);
}

.form-actions {
    display:     flex;
    gap:         .75rem;
    align-items: center;
    margin-top:  1.25rem;
    padding-top: 1rem;
    border-top:  1px solid var(--color-border);
    flex-wrap:   wrap;
}

.checkbox-row {
    display:       flex;
    align-items:   center;
    gap:           .5rem;
    margin-bottom: .5rem;
}

.inline-form {
	display: inline;
}

/* ----------------------------------------------------------
   Filter bar — used in report and stock listing pages
   ---------------------------------------------------------- */

/* Outer wrapper around a filter form inside a card */
.filter-form { margin-bottom: 0; }

/* Flex row holding all filter controls */
.filter-row {
    display:     flex;
    gap:         .75rem;
    align-items: flex-end;
    flex-wrap:   wrap;
}

/* Single label + control pair within a filter row */
.field-inline {
    display:        flex;
    flex-direction: column;
    gap:            .25rem;
}

.field-inline label {
    font-size:   .775rem;
    font-weight: 600;
    color:       var(--color-text-muted);
    white-space: nowrap;
}

.field-inline input,
.field-inline select {
    width: auto;
    min-width: 140px;
}

/* ----------------------------------------------------------
   Buttons
   ---------------------------------------------------------- */
.btn {
    display:       inline-flex;
    align-items:   center;
    gap:           .375rem;
    padding:       .5rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size:     .875rem;
    font-weight:   600;
    cursor:        pointer;
    border:        1px solid transparent;
    transition:    background var(--transition), color var(--transition),
                   border-color var(--transition), transform .1s;
    white-space:   nowrap;
    text-decoration: none;
    line-height:   1.4;
}

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

.btn-primary {
    background: var(--color-accent);
    color:      #fff;
    border-color: var(--color-accent);
}
.btn-primary:hover {
    background:   var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color:        #fff;
    text-decoration: none;
}

.btn-secondary {
    background:   var(--color-surface);
    color:        var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-bg);
    text-decoration: none;
    color: var(--color-text);
}

.btn-danger {
    background:   var(--color-error);
    color:        #fff;
    border-color: var(--color-error);
}
.btn-danger:hover {
    background: #b71c1c;
    text-decoration: none;
    color: #fff;
}

.btn-success {
    background:   var(--color-success);
    color:        #fff;
    border-color: var(--color-success);
}
.btn-success {
	text-decoration: none;
	color: #fff;
}

.btn-sm {
    padding:   .3rem .7rem;
    font-size: .8rem;
}

.btn-block { width: 100%; justify-content: center; }

/* ----------------------------------------------------------
   Alerts & Flash Messages

   Two systems exist intentionally:

   .alert / .alert-* — general-purpose inline alert components.
   Used in older modules and anywhere a contextual message is
   embedded within page content (e.g. no-data warnings).

   .form-errors / .form-success — standardised flash/validation
   message blocks rendered above forms and filter panels in all
   Phase 8+ modules. Structurally identical to .alert but
   semantically scoped to form-level feedback. Use these for
   all new modules.
   ---------------------------------------------------------- */
.alert {
    padding:       .85rem 1rem;
    border-radius: var(--radius-sm);
    font-size:     .875rem;
    border:        1px solid transparent;
    margin-bottom: 1rem;
}

.alert p { margin: 0; }
.alert p + p { margin-top: .35rem; }

.alert-success { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.alert-error   { background: #ffebee; color: #b71c1c; border-color: #ef9a9a; }
.alert-warning { background: #fff3e0; color: #bf360c; border-color: #ffcc80; }
.alert-info    { background: #e3f2fd; color: #01579b; border-color: #90caf9; }

.form-errors,
.form-success {
    padding:       .85rem 1rem;
    border-radius: var(--radius-sm);
    font-size:     .875rem;
    border:        1px solid transparent;
    margin-bottom: 1rem;
}

.form-errors p,
.form-success p { margin: 0; }

.form-errors p + p,
.form-success p + p { margin-top: .35rem; }

.form-errors  { background: #ffebee; color: #b71c1c; border-color: #ef9a9a; }
.form-success { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }

/* ----------------------------------------------------------
   Low Stock Indicator
   ---------------------------------------------------------- */
.low-stock-row td { background: #fff8e1; }
.low-stock-row:hover td { background: #fff3cd !important; }

/* ----------------------------------------------------------
   Empty State
   ---------------------------------------------------------- */
.empty-state {
    text-align:  center;
    padding:     3rem 1rem;
    color:       var(--color-text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

/* ----------------------------------------------------------
   Responsive — Auth Pages
   ---------------------------------------------------------- */
@media (max-width: 860px) {
    .auth-page {
        align-items: flex-start;
        padding:     1rem;
    }

    .auth-container {
        grid-template-columns: 1fr;
        max-width:             520px;
    }

    .auth-brand-panel {
        min-height: auto;
        padding:    1.5rem;
    }

    .auth-brand-inner {
        align-items: center;
        text-align:  center;
    }

    .auth-logo-frame {
        width: 170px;
    }

    .auth-brand-copy p:last-child {
        font-size: .9rem;
    }
}

@media (max-width: 480px) {
    .auth-page {
        padding: .75rem;
    }

    .auth-brand-panel {
        padding: 1.25rem;
    }

    .auth-logo-frame {
        width:   145px;
        padding: .75rem;
    }

    .auth-card {
        padding: 1.5rem;
    }
}

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
        padding:     1rem;
    }

    .navbar-hamburger { display: block; }

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

@media (max-width: 480px) {
    .stats-grid        { grid-template-columns: 1fr; }
    .page-header       { flex-direction: column; align-items: flex-start; }
    .form-grid         { grid-template-columns: 1fr; }
}

/* ==========================================================
   Dashboard — role-focused management workspace
   All selectors are scoped to .dashboard-page.
   ========================================================== */
.dashboard-page {
    --dashboard-critical: #b42318;
    --dashboard-critical-bg: #fff1f0;
    --dashboard-warning: #b54708;
    --dashboard-warning-bg: #fff7ed;
    --dashboard-good: #1f7a3f;
    --dashboard-good-bg: #edf9f0;
    --dashboard-neutral: #334155;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    max-width: 1500px;
    margin: 0 auto;
}

.dashboard-page a:focus-visible,
.dashboard-page button:focus-visible {
    outline: 3px solid rgba(232, 160, 32, .35);
    outline-offset: 3px;
}

.dashboard-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    border-radius: var(--radius-lg);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.dashboard-hero h1 {
    margin-top: .2rem;
    color: #fff;
    font-size: clamp(1.45rem, 2vw, 2rem);
    line-height: 1.25;
}

.dashboard-hero p {
    max-width: 720px;
    margin-top: .45rem;
    color: rgba(255,255,255,.72);
    font-size: .9rem;
}

.dashboard-eyebrow,
.dashboard-section-kicker {
    display: block;
    color: var(--color-accent);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.dashboard-hero-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.dashboard-hero-actions .btn-secondary {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-color: rgba(255,255,255,.22);
}

.dashboard-hero-actions .btn-secondary:hover {
    background: rgba(255,255,255,.16);
    color: #fff;
}

.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-section-heading h2,
.dashboard-panel-header h2 {
    margin-top: .15rem;
    color: var(--color-primary);
    font-size: 1.08rem;
    line-height: 1.3;
}

.dashboard-section-note {
    color: var(--color-text-muted);
    font-size: .78rem;
}

.dashboard-text-link {
    color: var(--color-info);
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}

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

.dashboard-metric {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 142px;
    flex-direction: column;
    gap: .4rem;
    padding: 1.15rem;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 3px solid var(--dashboard-neutral);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: var(--color-text);
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.dashboard-metric:hover {
    color: var(--color-text);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dashboard-metric.is-critical { border-top-color: var(--dashboard-critical); background: linear-gradient(180deg, var(--dashboard-critical-bg), #fff 58%); }
.dashboard-metric.is-warning  { border-top-color: var(--dashboard-warning); background: linear-gradient(180deg, var(--dashboard-warning-bg), #fff 58%); }
.dashboard-metric.is-good     { border-top-color: var(--dashboard-good); }
.dashboard-metric.is-neutral  { border-top-color: var(--color-info); }

.dashboard-metric-label {
    max-width: calc(100% - 42px);
    color: var(--color-text-muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .035em;
    line-height: 1.35;
    text-transform: uppercase;
}

.dashboard-metric strong {
    margin-top: auto;
    color: var(--color-primary);
    font-size: 2rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.dashboard-metric .dashboard-money-value {
    font-size: clamp(1.25rem, 1.7vw, 1.7rem);
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.dashboard-metric small {
    color: var(--color-text-muted);
    font-size: .76rem;
    line-height: 1.35;
}

.dashboard-metric-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--dashboard-neutral);
}

.dashboard-metric.is-critical .dashboard-metric-icon { background: #fee4e2; color: var(--dashboard-critical); }
.dashboard-metric.is-warning .dashboard-metric-icon { background: #ffead5; color: var(--dashboard-warning); }
.dashboard-metric.is-good .dashboard-metric-icon { background: #dcf3e2; color: var(--dashboard-good); }

.dashboard-attention-list {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.dashboard-attention-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: .95rem 1rem;
    border-bottom: 1px solid var(--color-border);
    border-left: 4px solid transparent;
}

.dashboard-attention-item:last-child { border-bottom: 0; }
.dashboard-attention-item.severity-critical { border-left-color: var(--dashboard-critical); }
.dashboard-attention-item.severity-high { border-left-color: var(--dashboard-warning); }
.dashboard-attention-item.severity-medium { border-left-color: var(--color-info); }

.dashboard-attention-icon,
.dashboard-activity-icon {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--dashboard-neutral);
}

.severity-critical .dashboard-attention-icon { background: #fee4e2; color: var(--dashboard-critical); }
.severity-high .dashboard-attention-icon { background: #ffead5; color: var(--dashboard-warning); }
.severity-medium .dashboard-attention-icon { background: #e3f2fd; color: var(--color-info); }

.dashboard-attention-copy { min-width: 0; }

.dashboard-attention-title-row,
.dashboard-task-title-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
}

.dashboard-attention-title-row h3,
.dashboard-task-item h3,
.dashboard-stock-item h3 {
    color: var(--color-text);
    font-size: .9rem;
    font-weight: 650;
    line-height: 1.35;
}

.dashboard-attention-copy p,
.dashboard-task-item p,
.dashboard-stock-item p,
.dashboard-activity-item p {
    margin-top: .12rem;
    color: var(--color-text-muted);
    font-size: .8rem;
    line-height: 1.4;
}

.dashboard-attention-copy small,
.dashboard-task-item small,
.dashboard-stock-item small,
.dashboard-activity-item small {
    display: block;
    margin-top: .18rem;
    color: var(--color-text-light);
    font-size: .72rem;
    line-height: 1.35;
}

.dashboard-severity-badge {
    padding: .12rem .42rem;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.severity-critical .dashboard-severity-badge { background: #fee4e2; color: var(--dashboard-critical); }
.severity-high .dashboard-severity-badge { background: #ffead5; color: var(--dashboard-warning); }
.severity-medium .dashboard-severity-badge { background: #e3f2fd; color: var(--color-info); }

.dashboard-content-grid {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 1.25rem;
    align-items: stretch;
}

.dashboard-content-grid-balanced { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.dashboard-panel {
    min-width: 0;
    margin: 0;
}

.dashboard-panel-header {
    min-height: 68px;
    padding: .9rem 1rem;
}

.dashboard-snapshot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--color-border);
}

.dashboard-snapshot-item {
    display: grid;
    grid-template-columns: 30px 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    gap: .05rem .65rem;
    padding: 1rem;
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
}

.dashboard-snapshot-item:hover { background: #fafbfc; color: var(--color-text); text-decoration: none; }
.dashboard-snapshot-item i { grid-row: 1 / 3; color: var(--color-info); font-size: 1rem; text-align: center; }
.dashboard-snapshot-item strong { color: var(--color-primary); font-size: 1.35rem; line-height: 1.1; }
.dashboard-snapshot-item span { color: var(--color-text-muted); font-size: .75rem; }

.dashboard-quick-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}

.dashboard-quick-links a {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .65rem .7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: .78rem;
    font-weight: 600;
}

.dashboard-quick-links a:hover { background: var(--color-bg); text-decoration: none; }
.dashboard-quick-links i { width: 16px; color: var(--color-info); text-align: center; }

.dashboard-activity-list,
.dashboard-task-list {
    display: flex;
    flex-direction: column;
}

.dashboard-activity-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.dashboard-activity-item:last-child { border-bottom: 0; }
.dashboard-activity-item > div { min-width: 0; }
.dashboard-activity-item strong { font-size: .83rem; }
.dashboard-activity-item time { color: var(--color-text-light); font-size: .7rem; white-space: nowrap; }

.dashboard-task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.dashboard-task-item:last-child { border-bottom: 0; }
.dashboard-task-item > div { min-width: 0; }
.dashboard-task-item.is-overdue { border-left: 4px solid var(--dashboard-critical); background: var(--dashboard-critical-bg); }
.dashboard-task-list-horizontal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-task-list-horizontal .dashboard-task-item:nth-child(odd) { border-right: 1px solid var(--color-border); }

.dashboard-stock-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: .85rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.dashboard-stock-item:last-child { border-bottom: 0; }
.dashboard-stock-item.is-out { border-left: 4px solid var(--dashboard-critical); background: var(--dashboard-critical-bg); }
.dashboard-stock-item > div { min-width: 0; }
.dashboard-stock-item > a { color: var(--color-info); font-size: 1.1rem; font-weight: 700; }

.dashboard-stock-quantity { text-align: right; }
.dashboard-stock-quantity strong { display: block; color: var(--color-primary); font-size: .86rem; font-variant-numeric: tabular-nums; }

.dashboard-table { min-width: 650px; }
.dashboard-table th,
.dashboard-table td { padding: .7rem 1rem; }

.dashboard-empty-state {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1.2rem;
    color: var(--color-text-muted);
}

.dashboard-empty-state i { color: var(--dashboard-good); font-size: 1.2rem; }
.dashboard-empty-state strong { color: var(--color-text); font-size: .85rem; }
.dashboard-empty-state p { color: var(--color-text-muted); font-size: .8rem; }
.dashboard-empty-state.compact { justify-content: center; min-height: 110px; text-align: center; }
.dashboard-empty-state.compact p { margin: 0; }
.dashboard-error-text { color: var(--color-error) !important; }

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

@media (max-width: 768px) {
    .dashboard-page { gap: 1.35rem; }
    .dashboard-hero { flex-direction: column; padding: 1.2rem; }
    .dashboard-hero-actions { width: 100%; justify-content: flex-start; }
    .dashboard-section-heading { align-items: flex-start; }
    .dashboard-section-note { display: none; }
    .dashboard-attention-item { grid-template-columns: 36px minmax(0, 1fr); gap: .75rem; }
    .dashboard-attention-item > .btn { grid-column: 2; justify-self: flex-start; }
    .dashboard-task-list-horizontal { grid-template-columns: 1fr; }
    .dashboard-task-list-horizontal .dashboard-task-item:nth-child(odd) { border-right: 0; }
}

@media (max-width: 520px) {
    .dashboard-metrics { grid-template-columns: 1fr; }
    .dashboard-metric { min-height: 128px; }
    .dashboard-hero-actions .btn { flex: 1; justify-content: center; }
    .dashboard-section-heading { flex-direction: column; gap: .35rem; }
    .dashboard-snapshot-grid,
    .dashboard-quick-links { grid-template-columns: 1fr; }
    .dashboard-task-item { align-items: flex-start; flex-direction: column; }
    .dashboard-stock-item { grid-template-columns: minmax(0, 1fr) auto; }
    .dashboard-stock-item > a { display: none; }
    .dashboard-activity-item { grid-template-columns: 34px minmax(0, 1fr); }
    .dashboard-activity-item time { grid-column: 2; }
}

/* Shared collapsible sidebar groups (moved from navbar.php). */
.sidebar-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .5rem 1rem .25rem;
    border: 0;
    background: transparent;
    color: rgba(255,255,255,.35);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    text-align: left;
}

.sidebar-group-toggle:hover {
    color: rgba(255,255,255,.6);
}

.sidebar-group-toggle .toggle-label {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.sidebar-group-toggle .toggle-icon {
    font-size: .8rem;
    line-height: 1;
    transition: transform var(--transition);
}

.sidebar-group.is-open .sidebar-group-toggle .toggle-icon {
    transform: rotate(90deg);
}

.sidebar-group-items[hidden] {
    display: none !important;
}

.flash-message-overlay {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 9999;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}
