/* ==========================================================================
   NR1 SaaS — Design System CSS
   Dark-mode by default, sem Tailwind, sem build step
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Google Fonts
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

html { scroll-behavior: smooth; }

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

button, input, select, textarea {
    font: inherit;
    border: none;
    outline: none;
    background: none;
}

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

ul, ol { list-style: none; }

/* --------------------------------------------------------------------------
   3. CSS Custom Properties — Design Tokens
   -------------------------------------------------------------------------- */
:root {
    /* Backgrounds */
    --bg-base:      #0D1B2A;
    --bg-surface:   #132236;
    --bg-surface-2: #1A2E47;
    --bg-surface-3: #213558;

    /* Brand */
    --brand-primary:   #7C3AED;
    --brand-primary-h: #6D28D9;
    --brand-light:     #8B5CF6;
    --brand-accent:    #10B981;
    --brand-accent-h:  #059669;

    /* Risk levels */
    --risk-low:      #22C55E;
    --risk-medium:   #EAB308;
    --risk-high:     #EF4444;
    --risk-critical: #3B82F6;

    /* Text */
    --text-primary:   #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted:     #64748B;

    /* Borders */
    --border-subtle:  #1E3A5F;
    --border-default: #2D4A6E;
    --border-strong:  #3D5A7E;

    /* States */
    --state-success: #10B981;
    --state-warning: #F59E0B;
    --state-error:   #EF4444;
    --state-info:    #3B82F6;

    /* Shadows */
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.3);
    --shadow-md:    0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg:    0 10px 30px rgba(0,0,0,0.4);
    --shadow-brand: 0 4px 20px rgba(124,58,237,0.35);

    /* Border radius */
    --r-sm:   6px;
    --r-md:   10px;
    --r-lg:   14px;
    --r-xl:   20px;
    --r-2xl:  28px;
    --r-full: 9999px;

    /* Spacing */
    --sp-1:  4px;
    --sp-2:  8px;
    --sp-3:  12px;
    --sp-4:  16px;
    --sp-5:  20px;
    --sp-6:  24px;
    --sp-8:  32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;

    /* Duration */
    --dur-fast: 100ms;
    --dur-base: 200ms;
    --dur-slow: 350ms;

    /* Layout */
    --sidebar-w:       220px;
    --sidebar-w-sm:    60px;
    --header-h:        64px;
}

/* --------------------------------------------------------------------------
   4. Base Typography
   -------------------------------------------------------------------------- */
body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.mono, code, pre, .score, .protocol {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 1rem;     font-weight: 600; }
h5 { font-size: 0.875rem; font-weight: 600; }
h6 { font-size: 0.8125rem; font-weight: 500; }

p { color: var(--text-secondary); }

strong { font-weight: 600; color: var(--text-primary); }

.text-primary   { color: var(--text-primary)   !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted)     !important; }
.text-brand     { color: var(--brand-primary)  !important; }
.text-accent    { color: var(--brand-accent)   !important; }
.text-success   { color: var(--state-success)  !important; }
.text-warning   { color: var(--state-warning)  !important; }
.text-error     { color: var(--state-error)    !important; }
.text-info      { color: var(--state-info)     !important; }

.text-sm   { font-size: 0.75rem; }
.text-base { font-size: 0.875rem; }
.text-lg   { font-size: 1rem; }
.text-xl   { font-size: 1.125rem; }
.text-2xl  { font-size: 1.375rem; }
.text-3xl  { font-size: 1.75rem; }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semi    { font-weight: 600; }
.font-bold    { font-weight: 700; }

.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* --------------------------------------------------------------------------
   5. Layout — App Shell
   -------------------------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: width var(--dur-slow) ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: var(--r-full); }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--header-h);
    flex-shrink: 0;
}

.sidebar-logo-mark {
    width: 32px;
    height: 32px;
    background: var(--brand-primary);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.875rem;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-brand);
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-logo-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-section {
    padding: var(--sp-4) 0;
    flex: 1;
}

.sidebar-section-label {
    padding: var(--sp-2) var(--sp-5);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--sp-3);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--dur-base) ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav a:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: rgba(124, 58, 237, 0.15);
    color: var(--brand-light);
}

.sidebar-nav a.active svg { color: var(--brand-primary); }

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: color var(--dur-base) ease;
}

.sidebar-nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav .badge-count {
    margin-left: auto;
    background: var(--brand-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--r-full);
    flex-shrink: 0;
}

.sidebar-footer {
    padding: var(--sp-4) var(--sp-3);
    border-top: 1px solid var(--border-subtle);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: 0.8125rem;
    transition: all var(--dur-base) ease;
}

.sidebar-footer a:hover {
    background: rgba(239,68,68,0.1);
    color: var(--state-error);
}

/* Admin badge in sidebar */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    background: rgba(239,68,68,0.15);
    color: var(--state-error);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: var(--r-full);
    margin-left: auto;
    border: 1px solid rgba(239,68,68,0.3);
    flex-shrink: 0;
}

/* Header */
.header {
    grid-area: header;
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--header-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-6);
    gap: var(--sp-4);
    z-index: 90;
    transition: left var(--dur-slow) ease;
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex: 1;
    min-width: 0;
}

.header-breadcrumb a,
.header-breadcrumb span {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.header-breadcrumb a:hover { color: var(--text-secondary); }

.header-breadcrumb .breadcrumb-sep {
    color: var(--border-strong);
    font-size: 0.75rem;
}

.header-breadcrumb .breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--dur-base) ease;
    position: relative;
}

.header-icon-btn:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.header-icon-btn .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    background: var(--state-error);
    border-radius: var(--r-full);
    border: 2px solid var(--bg-surface);
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: var(--brand-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity var(--dur-base) ease;
    flex-shrink: 0;
}

.header-avatar:hover { opacity: 0.85; }

/* Main content */
.main-content {
    grid-column: 2;
    grid-row: 2;
    margin-top: var(--header-h);
    margin-left: var(--sidebar-w);
    padding: var(--sp-6);
    min-height: calc(100vh - var(--header-h));
    transition: margin-left var(--dur-slow) ease;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
    gap: var(--sp-4);
}

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: var(--sp-1);
}

/* --------------------------------------------------------------------------
   6. Guest Layout (public pages)
   -------------------------------------------------------------------------- */
.guest-shell {
    min-height: 100vh;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
}

.guest-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-8);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.guest-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8) var(--sp-4);
}

/* --------------------------------------------------------------------------
   7. Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-base) ease;
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.5;
}

.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

.btn-sm {
    padding: calc(var(--sp-1) + 2px) var(--sp-3);
    font-size: 0.8125rem;
}

.btn-lg {
    padding: var(--sp-3) var(--sp-6);
    font-size: 1rem;
    border-radius: var(--r-lg);
}

.btn-xl {
    padding: var(--sp-4) var(--sp-8);
    font-size: 1.0625rem;
    border-radius: var(--r-lg);
}

.btn-block { width: 100%; }

/* Variants */
.btn-primary {
    background: var(--brand-primary);
    color: white;
    box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--brand-primary-h); }

.btn-accent {
    background: var(--brand-accent);
    color: white;
}
.btn-accent:hover { background: var(--brand-accent-h); }

.btn-secondary {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-surface-3); border-color: var(--border-strong); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--state-error);
    border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover { background: var(--state-error); color: white; }

.btn-outline {
    background: transparent;
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}
.btn-outline:hover { background: var(--brand-primary); color: white; }

/* Loading state */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}
.btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* --------------------------------------------------------------------------
   8. Cards
   -------------------------------------------------------------------------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.card-sm { border-radius: var(--r-md); }
.card-xl { border-radius: var(--r-xl); }

.card-hover {
    transition: border-color var(--dur-base), box-shadow var(--dur-base), transform var(--dur-base);
    cursor: pointer;
}
.card-hover:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

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

.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: var(--sp-5); }
.card-body-lg { padding: var(--sp-6) var(--sp-8); }

.card-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
}

/* KPI Cards */
.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    transition: border-color var(--dur-base), box-shadow var(--dur-base);
}

.kpi-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.kpi-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.kpi-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-card-icon svg { width: 20px; height: 20px; }

.kpi-card-icon.icon-brand  { background: rgba(124,58,237,0.15); color: var(--brand-light); }
.kpi-card-icon.icon-accent { background: rgba(16,185,129,0.15); color: var(--brand-accent); }
.kpi-card-icon.icon-info   { background: rgba(59,130,246,0.15); color: var(--state-info); }
.kpi-card-icon.icon-warn   { background: rgba(245,158,11,0.15); color: var(--state-warning); }
.kpi-card-icon.icon-error  { background: rgba(239,68,68,0.15);  color: var(--state-error); }

.kpi-card-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.kpi-card-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-card-change {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: 0.75rem;
    font-weight: 500;
}

.kpi-change-up   { color: var(--state-success); }
.kpi-change-down { color: var(--state-error); }
.kpi-change-flat { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   9. Forms & Inputs
   -------------------------------------------------------------------------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-label.required::after {
    content: ' *';
    color: var(--state-error);
}

.form-control {
    width: 100%;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color var(--dur-base), box-shadow var(--dur-base);
}

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

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
    background: var(--bg-surface-3);
}

.form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-control.is-invalid { border-color: var(--state-error); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }

.form-error {
    font-size: 0.75rem;
    color: var(--state-error);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

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

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748B' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-4) center;
    padding-right: var(--sp-10);
}

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

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-radius: 0;
    flex: 1;
}

.input-group .form-control:first-child {
    border-radius: var(--r-md) 0 0 var(--r-md);
}

.input-group .form-control:last-child {
    border-radius: 0 var(--r-md) var(--r-md) 0;
}

.input-group .btn:first-child {
    border-radius: var(--r-md) 0 0 var(--r-md);
}

.input-group .btn:last-child {
    border-radius: 0 var(--r-md) var(--r-md) 0;
}

.input-prefix, .input-suffix {
    display: flex;
    align-items: center;
    padding: 0 var(--sp-3);
    background: var(--bg-surface-3);
    border: 1px solid var(--border-default);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.input-prefix { border-right: none; border-radius: var(--r-md) 0 0 var(--r-md); }
.input-suffix { border-left: none; border-radius: 0 var(--r-md) var(--r-md) 0; }

.form-check {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-primary);
    cursor: pointer;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   10. Tables
   -------------------------------------------------------------------------- */
.table-container {
    overflow-x: auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--border-subtle);
}

table.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
}

.table thead th {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    background: var(--bg-surface-2);
}

.table tbody td {
    padding: var(--sp-3) var(--sp-4);
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

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

.table tbody tr {
    transition: background var(--dur-fast) ease;
}

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

.table td strong, .table td .text-primary { color: var(--text-primary); }

.table-sm thead th,
.table-sm tbody td {
    padding: var(--sp-2) var(--sp-3);
    font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   11. Badges & Pills
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 3px var(--sp-2);
    border-radius: var(--r-full);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge svg { width: 10px; height: 10px; }

/* Risk badges */
.badge-low      { background: rgba(34,197,94,0.15);  color: var(--risk-low);      border: 1px solid rgba(34,197,94,0.3); }
.badge-medium   { background: rgba(234,179,8,0.15);  color: var(--risk-medium);   border: 1px solid rgba(234,179,8,0.3); }
.badge-high     { background: rgba(239,68,68,0.15);  color: var(--risk-high);     border: 1px solid rgba(239,68,68,0.3); }
.badge-critical { background: rgba(59,130,246,0.15); color: var(--risk-critical); border: 1px solid rgba(59,130,246,0.3); }

/* Status badges */
.badge-success { background: rgba(16,185,129,0.15); color: var(--state-success); border: 1px solid rgba(16,185,129,0.3); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--state-warning); border: 1px solid rgba(245,158,11,0.3); }
.badge-error   { background: rgba(239,68,68,0.15);  color: var(--state-error);   border: 1px solid rgba(239,68,68,0.3); }
.badge-info    { background: rgba(59,130,246,0.15); color: var(--state-info);    border: 1px solid rgba(59,130,246,0.3); }
.badge-neutral { background: rgba(100,116,139,0.15); color: var(--text-muted);   border: 1px solid rgba(100,116,139,0.3); }
.badge-brand   { background: rgba(124,58,237,0.15); color: var(--brand-light);   border: 1px solid rgba(124,58,237,0.3); }

/* Pill (larger badge variant) */
.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--r-full);
    font-size: 0.8125rem;
    font-weight: 500;
}

/* Risk dot indicator */
.risk-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.risk-dot-low      { background: var(--risk-low); }
.risk-dot-medium   { background: var(--risk-medium); }
.risk-dot-high     { background: var(--risk-high); }
.risk-dot-critical { background: var(--risk-critical); }

/* --------------------------------------------------------------------------
   12. Modals
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modal-in var(--dur-slow) cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }
.modal-sm { max-width: 380px; }

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--dur-base) ease;
}
.modal-close:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.modal-body {
    padding: var(--sp-6);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   13. Toasts
   -------------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    bottom: var(--sp-6);
    right: var(--sp-6);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    max-width: 360px;
    pointer-events: all;
    animation: toast-in var(--dur-slow) cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0)    scale(1); }
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-body { flex: 1; }

.toast-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.toast-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: color var(--dur-base);
}
.toast-close:hover { color: var(--text-primary); }

.toast-success { border-left: 3px solid var(--state-success); }
.toast-error   { border-left: 3px solid var(--state-error);   }
.toast-warning { border-left: 3px solid var(--state-warning);  }
.toast-info    { border-left: 3px solid var(--state-info);     }

.toast-success .toast-icon { color: var(--state-success); }
.toast-error   .toast-icon { color: var(--state-error);   }
.toast-warning .toast-icon { color: var(--state-warning);  }
.toast-info    .toast-icon { color: var(--state-info);     }

/* --------------------------------------------------------------------------
   14. Skeleton Loader
   -------------------------------------------------------------------------- */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-surface-2) 25%,
        var(--bg-surface-3) 50%,
        var(--bg-surface-2) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--r-sm);
}

@keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

.skeleton-text { height: 14px; border-radius: var(--r-sm); margin-bottom: var(--sp-2); }
.skeleton-text.w-3\/4 { width: 75%; }
.skeleton-text.w-1\/2 { width: 50%; }
.skeleton-text.w-1\/4 { width: 25%; }
.skeleton-heading { height: 24px; width: 60%; border-radius: var(--r-sm); margin-bottom: var(--sp-3); }
.skeleton-circle  { border-radius: 50%; }
.skeleton-btn     { height: 36px; width: 100px; border-radius: var(--r-md); }
.skeleton-card    { height: 120px; border-radius: var(--r-lg); }
.skeleton-avatar  { width: 40px; height: 40px; border-radius: var(--r-md); }

/* --------------------------------------------------------------------------
   15. Empty States
   -------------------------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-16) var(--sp-8);
    text-align: center;
    gap: var(--sp-4);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    background: var(--bg-surface-2);
    border-radius: var(--r-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: var(--sp-2);
}

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

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.empty-state-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 360px;
}

/* --------------------------------------------------------------------------
   16. Kanban Board
   -------------------------------------------------------------------------- */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
    align-items: start;
}

.kanban-col {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.kanban-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}

.kanban-col-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kanban-col-count {
    background: var(--bg-surface-3);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--r-full);
}

.kanban-col-todo    .kanban-col-header { border-top: 3px solid var(--text-muted); }
.kanban-col-doing   .kanban-col-header { border-top: 3px solid var(--state-warning); }
.kanban-col-done    .kanban-col-header { border-top: 3px solid var(--state-success); }

.kanban-tasks {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4);
    min-height: 120px;
}

.kanban-task {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    cursor: grab;
    transition: all var(--dur-base) ease;
}

.kanban-task:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kanban-task:active { cursor: grabbing; }

.kanban-task-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.kanban-task-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kanban-task-topic {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface-2);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-size: 0.7rem;
}

/* --------------------------------------------------------------------------
   17. Pagination
   -------------------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-4);
}

.page-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-base);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.page-item:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.page-item.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.page-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   18. Alert / Banner
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-radius: var(--r-md);
    border: 1px solid;
    margin-bottom: var(--sp-4);
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: rgba(16,185,129,0.1);  border-color: rgba(16,185,129,0.3);  color: var(--state-success); }
.alert-error   { background: rgba(239,68,68,0.1);   border-color: rgba(239,68,68,0.3);   color: var(--state-error); }
.alert-warning { background: rgba(245,158,11,0.1);  border-color: rgba(245,158,11,0.3);  color: var(--state-warning); }
.alert-info    { background: rgba(59,130,246,0.1);  border-color: rgba(59,130,246,0.3);  color: var(--state-info); }

.alert-body { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-desc  { font-size: 0.875rem; opacity: 0.85; }

/* --------------------------------------------------------------------------
   19. Tabs
   -------------------------------------------------------------------------- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    gap: 0;
    margin-bottom: var(--sp-5);
}

.tab-item {
    padding: var(--sp-3) var(--sp-5);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--dur-base);
    white-space: nowrap;
}

.tab-item:hover { color: var(--text-secondary); }

.tab-item.active {
    color: var(--brand-light);
    border-bottom-color: var(--brand-primary);
}

/* --------------------------------------------------------------------------
   20. Progress bars
   -------------------------------------------------------------------------- */
.progress {
    height: 6px;
    background: var(--bg-surface-3);
    border-radius: var(--r-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--r-full);
    background: var(--brand-primary);
    transition: width var(--dur-slow) ease;
}

.progress-bar-success  { background: var(--state-success); }
.progress-bar-warning  { background: var(--state-warning); }
.progress-bar-error    { background: var(--state-error); }
.progress-bar-info     { background: var(--state-info); }
.progress-bar-striped  {
    background-image: linear-gradient(45deg, rgba(255,255,255,.1) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.1) 50%, rgba(255,255,255,.1) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
    animation: progress-animate 1s linear infinite;
}
@keyframes progress-animate { from { background-position: 1rem 0; } to { background-position: 0 0; } }

.progress-lg { height: 10px; }
.progress-xl { height: 14px; border-radius: var(--r-md); }

/* --------------------------------------------------------------------------
   21. Score Ring (for risk level display)
   -------------------------------------------------------------------------- */
.score-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
}

.score-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   22. HTMX States
   -------------------------------------------------------------------------- */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

/* Global loading bar */
#htmx-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--brand-primary);
    z-index: 9999;
    transition: width var(--dur-slow) ease, opacity var(--dur-base) ease;
    box-shadow: 0 0 8px rgba(124,58,237,0.6);
}

#htmx-loading-bar.htmx-request {
    width: 70%;
}

.htmx-settling { opacity: 0.7; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin var(--dur-slow) linear infinite;
}

.spinner-sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner-lg { width: 24px; height: 24px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   23. Survey (Chat Style)
   -------------------------------------------------------------------------- */
.survey-shell {
    min-height: 100vh;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
}

.survey-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--bg-surface-2);
    z-index: 50;
}

.survey-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 var(--r-full) var(--r-full) 0;
}

.survey-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    margin-top: 4px;
}

.survey-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8) var(--sp-4);
}

.survey-card {
    width: 100%;
    max-width: 640px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-2xl);
    padding: var(--sp-8);
    box-shadow: var(--shadow-lg);
}

.survey-question-num {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand-light);
    margin-bottom: var(--sp-3);
}

.survey-question-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: var(--sp-6);
}

.survey-options {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.survey-option {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-surface-2);
    border: 2px solid var(--border-subtle);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: all var(--dur-base) ease;
    user-select: none;
}

.survey-option:hover {
    border-color: var(--brand-primary);
    background: rgba(124,58,237,0.08);
}

.survey-option.selected {
    border-color: var(--brand-primary);
    background: rgba(124,58,237,0.12);
}

.survey-option input[type="radio"] { display: none; }

.survey-option-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-radius: 50%;
    flex-shrink: 0;
    transition: all var(--dur-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.survey-option.selected .survey-option-radio {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
}

.survey-option.selected .survey-option-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.survey-option-label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    flex: 1;
}

.survey-option.selected .survey-option-label {
    color: var(--text-primary);
    font-weight: 500;
}

.survey-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--sp-6);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border-subtle);
}

/* --------------------------------------------------------------------------
   24. Complaint Form
   -------------------------------------------------------------------------- */
.complaint-shell {
    min-height: 100vh;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8) var(--sp-4);
}

.complaint-card {
    width: 100%;
    max-width: 600px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-2xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.complaint-card-header {
    padding: var(--sp-8) var(--sp-8) var(--sp-6);
    text-align: center;
    border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(135deg, var(--bg-surface-2), var(--bg-surface));
}

.complaint-icon {
    width: 56px;
    height: 56px;
    background: rgba(124,58,237,0.15);
    border-radius: var(--r-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-light);
    margin: 0 auto var(--sp-4);
}

.complaint-protocol {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-light);
    letter-spacing: 0.05em;
    background: rgba(124,58,237,0.1);
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--r-lg);
    border: 1px solid rgba(124,58,237,0.25);
    display: inline-block;
}

/* --------------------------------------------------------------------------
   25. Login Page
   -------------------------------------------------------------------------- */
.login-shell {
    min-height: 100vh;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    position: relative;
    overflow: hidden;
}

.login-shell::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 60%;
    height: 100%;
    background: radial-gradient(circle, rgba(124,58,237,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.login-shell::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: -10%;
    width: 50%;
    height: 80%;
    background: radial-gradient(circle, rgba(16,185,129,0.06) 0%, transparent 60%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-2xl);
    padding: var(--sp-8);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-8);
    justify-content: center;
}

.login-logo-mark {
    width: 44px;
    height: 44px;
    background: var(--brand-primary);
    border-radius: var(--r-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.125rem;
    color: white;
    box-shadow: var(--shadow-brand);
}

.login-logo-text {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: var(--sp-6);
}

/* --------------------------------------------------------------------------
   26. Stat / Analytics Cards
   -------------------------------------------------------------------------- */
.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.stat-row:last-child { border-bottom: none; }

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   27. Grid / Flex Utilities
   -------------------------------------------------------------------------- */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-start  { align-items: flex-start; }
.items-center { align-items: center; }
.items-end    { align-items: flex-end; }
.justify-start    { justify-content: flex-start; }
.justify-center   { justify-content: center; }
.justify-end      { justify-content: flex-end; }
.justify-between  { justify-content: space-between; }
.flex-1       { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

.w-full   { width: 100%; }
.w-auto   { width: auto; }
.h-full   { height: 100%; }
.min-w-0  { min-width: 0; }
.overflow-hidden  { overflow: hidden; }
.overflow-x-auto  { overflow-x: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.relative { position: relative; }
.absolute { position: absolute; }

/* Spacing */
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-4  { padding: var(--sp-4); }
.p-5  { padding: var(--sp-5); }
.p-6  { padding: var(--sp-6); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-2 { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.py-3 { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }

/* Display */
.hidden  { display: none !important; }
.block   { display: block; }
.inline  { display: inline; }
.inline-flex { display: inline-flex; }

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: var(--sp-4) 0;
}

/* --------------------------------------------------------------------------
   28. Dropdown
   -------------------------------------------------------------------------- */
.dropdown { position: relative; display: inline-flex; }

.dropdown-menu {
    position: absolute;
    top: calc(100% + var(--sp-2));
    right: 0;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--r-lg);
    padding: var(--sp-2) 0;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    z-index: 150;
    animation: dropdown-in var(--dur-base) ease;
}

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--dur-fast);
    white-space: nowrap;
}

.dropdown-item:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.dropdown-item.danger { color: var(--state-error); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }

.dropdown-divider {
    border-top: 1px solid var(--border-subtle);
    margin: var(--sp-1) 0;
}

.dropdown-label {
    padding: var(--sp-2) var(--sp-4);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   29. Chart container
   -------------------------------------------------------------------------- */
.chart-container {
    position: relative;
    width: 100%;
}

.chart-container canvas { max-width: 100%; }

/* --------------------------------------------------------------------------
   30. Search bar
   -------------------------------------------------------------------------- */
.search-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    padding: 0 var(--sp-4);
    transition: border-color var(--dur-base), box-shadow var(--dur-base);
}

.search-bar:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.search-bar svg { color: var(--text-muted); width: 16px; height: 16px; flex-shrink: 0; }

.search-bar input {
    background: none;
    border: none;
    padding: var(--sp-3) 0;
    color: var(--text-primary);
    font-size: 0.875rem;
    flex: 1;
    min-width: 0;
}

.search-bar input::placeholder { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   31. Responsive Breakpoints
   -------------------------------------------------------------------------- */
/* Tablet: ≤ 1024px — sidebar icon-only */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-w-sm);
    }

    .sidebar-logo-text,
    .sidebar-logo-sub,
    .sidebar-section-label,
    .sidebar-nav-label,
    .sidebar-nav .badge-count,
    .admin-badge {
        display: none;
    }

    .sidebar-logo { justify-content: center; padding: var(--sp-4); }
    .sidebar-nav { padding: 0 var(--sp-2); }
    .sidebar-nav a { justify-content: center; padding: var(--sp-3); gap: 0; }
    .sidebar-footer a { justify-content: center; gap: 0; }

    .header { left: var(--sidebar-w-sm); }
    .main-content { margin-left: var(--sidebar-w-sm); }
}

/* Mobile: ≤ 768px — no sidebar, bottom nav */
@media (max-width: 768px) {
    .sidebar { display: none; }

    .header {
        left: 0;
        padding: 0 var(--sp-4);
    }

    .main-content {
        margin-left: 0;
        padding: var(--sp-4);
        padding-bottom: calc(var(--sp-16) + var(--sp-4));
    }

    .bottom-nav {
        display: flex !important;
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .kanban-board {
        grid-template-columns: 1fr;
    }

    .modal {
        margin: 0;
        border-radius: var(--r-xl) var(--r-xl) 0 0;
        max-height: 90vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }

    .modal-backdrop {
        align-items: flex-end;
    }

    .page-header { flex-direction: column; align-items: flex-start; }
}

/* Bottom navigation (mobile only) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
    padding: 0 var(--sp-4);
    justify-content: space-around;
    align-items: center;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    padding: var(--sp-2);
    border-radius: var(--r-md);
    transition: all var(--dur-base);
    text-align: center;
}

.bottom-nav a svg { width: 20px; height: 20px; }
.bottom-nav a.active { color: var(--brand-light); }

/* Large screens ≥ 1280px */
@media (min-width: 1280px) {
    .main-content { padding: var(--sp-8); }
}

/* --------------------------------------------------------------------------
   32. Animations & Transitions
   -------------------------------------------------------------------------- */
.fade-in { animation: fade-in var(--dur-slow) ease; }
.slide-up { animation: slide-up var(--dur-slow) cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------------------
   33. Miscellaneous
   -------------------------------------------------------------------------- */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: var(--brand-primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }

.separator {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin: var(--sp-4) 0;
}

.separator::before, .separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.separator-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Status indicator dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-online  { background: var(--state-success); box-shadow: 0 0 0 2px rgba(16,185,129,0.2); }
.status-offline { background: var(--text-muted); }
.status-busy    { background: var(--state-error); }

/* Scrollbar global */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Selection */
::selection { background: rgba(124,58,237,0.3); color: var(--text-primary); }
