/* ===================================================================
   TktCube ERP — Design System
   To switch themes: comment one :root block and uncomment the other
   =================================================================== */

/* ----- DARK MODE (active) ----- */
:root {
    /* Fonts */
    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'DM Mono', monospace;

    /* Background */
    --bg-base: #0d1117;
    --bg-raised: #131c27;
    --bg-overlay: #1a2638;
    --bg-hover: #1f2e42;
    --bg-active: #243347;

    /* Primary — Saffron */
    --saf: #f0a500;
    --saf-dim: rgba(240, 165, 0, 0.15);
    --saf-glow: rgba(240, 165, 0, 0.25);

    /* Accent Colors */
    --grn: #3fb950;
    --grn-dim: rgba(63, 185, 80, 0.15);
    --red: #f85149;
    --red-dim: rgba(248, 81, 73, 0.15);
    --blu: #58a6ff;
    --blu-dim: rgba(88, 166, 255, 0.15);
    --tea: #39c5bb;
    --tea-dim: rgba(57, 197, 187, 0.15);
    --pur: #bc8cff;
    --pur-dim: rgba(188, 140, 255, 0.15);

    /* Text */
    --tx-1: #e6edf3;
    --tx-2: #8b9eb0;
    --tx-3: #4a6179;

    /* Borders */
    --border: #1e2d3d;
    --border-light: #2a3a4e;

    /* Radius */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Layout */
    --sidebar-w: 260px;
    --topbar-h: 56px;
}

/* ----- LIGHT MODE (uncomment this block and comment the dark block above) -----
:root {
    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'DM Mono', monospace;

    --bg-base: #f5f6f8;
    --bg-raised: #ffffff;
    --bg-overlay: #f0f1f4;
    --bg-hover: #e8e9ed;
    --bg-active: #dfe0e5;

    --saf: #d99200;
    --saf-dim: rgba(217, 146, 0, 0.12);
    --saf-glow: rgba(217, 146, 0, 0.20);

    --grn: #1a7f37;
    --grn-dim: rgba(26, 127, 55, 0.10);
    --red: #cf222e;
    --red-dim: rgba(207, 34, 46, 0.10);
    --blu: #0969da;
    --blu-dim: rgba(9, 105, 218, 0.10);
    --tea: #1b9e95;
    --tea-dim: rgba(27, 158, 149, 0.10);
    --pur: #8250df;
    --pur-dim: rgba(130, 80, 223, 0.10);

    --tx-1: #1f2328;
    --tx-2: #59636e;
    --tx-3: #8b949e;

    --border: #d1d9e0;
    --border-light: #e1e4e8;

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    --sidebar-w: 260px;
    --topbar-h: 56px;
}
----- */

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--tx-1);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-head);
    font-weight: 700;
    line-height: 1.2;
    color: var(--tx-1);
}

a {
    color: var(--saf);
    text-decoration: none;
}

a:hover {
    color: #ffba2e;
}

::selection {
    background: var(--saf-dim);
    color: var(--tx-1);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--tx-3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--tx-2);
}

/* ----- Layout Shell ----- */
.erp-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar content";
    height: 100vh;
    overflow: hidden;
}

.erp-sidebar {
    grid-area: sidebar;
    background: var(--bg-raised);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.25rem 0;
    display: flex;
    flex-direction: column;
}

.erp-topbar {
    grid-area: topbar;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--bd);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 52px;
}
.erp-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.erp-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Live pulsing dot */
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--grn);
    box-shadow: 0 0 6px var(--grn), 0 0 12px rgba(63,185,80,0.3);
    animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--grn), 0 0 12px rgba(63,185,80,0.3); }
    50% { opacity: 0.5; box-shadow: 0 0 2px var(--grn), 0 0 4px rgba(63,185,80,0.1); }
}
.live-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--grn);
}

/* Topbar user info */
.topbar-user {
    text-align: right;
    line-height: 1.2;
}
.topbar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--tx-1);
}
.topbar-user-role {
    font-size: 0.68rem;
    color: var(--tx-3);
}
.topbar-logout {
    background: none;
    border: 1px solid var(--bd);
    border-radius: 6px;
    cursor: pointer;
    color: var(--tx-3);
    padding: 0.35rem;
    transition: all 0.15s;
    display: flex;
    align-items: center;
}
.topbar-logout:hover {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(248, 81, 73, 0.3);
}

.erp-main {
    grid-area: content;
    overflow-y: auto;
}

.erp-content {
    padding: 1.5rem;
    max-width: 1400px;
}

/* ----- Sidebar ----- */
.sb-section {
    margin-bottom: 0.5rem;
}

.sb-section-lbl {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tx-3);
    padding: 0.75rem 1.25rem 0.35rem;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    color: var(--tx-2);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.sb-item:hover {
    background: var(--bg-overlay);
    color: var(--tx-1);
}

.sb-item.active {
    background: var(--saf-dim);
    color: var(--saf);
    border-left-color: var(--saf);
}

.sb-badge {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    background: var(--bg-overlay);
    color: var(--tx-2);
}

.sb-badge-red {
    background: var(--red-dim);
    color: var(--red);
}

/* ----- Page Header ----- */
.pg-hdr {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.pg-hdr-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pg-title {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--tx-1);
}

.pg-sub {
    font-size: 0.85rem;
    color: var(--tx-2);
}

.pg-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

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

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

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-family: var(--font-head);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--tx-1);
}

.card-sub {
    font-size: 0.8rem;
    color: var(--tx-2);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.card-accent-saf { border-top: 3px solid var(--saf); }
.card-accent-tea { border-top: 3px solid var(--tea); }
.card-accent-blu { border-top: 3px solid var(--blu); }
.card-accent-grn { border-top: 3px solid var(--grn); }
.card-accent-red { border-top: 3px solid var(--red); }

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

.stat-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sc-saf { border-top: 3px solid var(--saf); }
.sc-tea { border-top: 3px solid var(--tea); }
.sc-blu { border-top: 3px solid var(--blu); }
.sc-grn { border-top: 3px solid var(--grn); }
.sc-red { border-top: 3px solid var(--red); }

.sc-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sc-icon {
    font-size: 1.5rem;
    opacity: 0.8;
}

.sc-val {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--tx-1);
    line-height: 1;
}

.sc-label {
    font-size: 0.8rem;
    color: var(--tx-2);
    font-weight: 500;
}

.sc-meta {
    font-size: 0.75rem;
    color: var(--tx-3);
}

.sc-trend {
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.sc-up { color: var(--grn); }
.sc-down { color: var(--red); }

/* ----- Quick Stats ----- */
.qstat-strip {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 0;
    flex-wrap: wrap;
}

.qstat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.qstat-val {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--tx-1);
}

.qstat-lbl {
    font-size: 0.7rem;
    color: var(--tx-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ----- Tables ----- */
.tbl-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
}

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

thead {
    background: var(--bg-overlay);
}

th {
    text-align: left;
    padding: 0.65rem 1rem;
    font-weight: 600;
    color: var(--tx-2);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

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

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

.td-primary {
    font-weight: 600;
    color: var(--tx-1);
}

.td-mono {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.td-accent {
    color: var(--saf);
    font-weight: 600;
}

/* ----- Badges ----- */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-new         { background: var(--saf-dim); color: var(--saf); }
.badge-active      { background: var(--grn-dim); color: var(--grn); }
.badge-pending     { background: var(--blu-dim); color: var(--blu); }
.badge-inactive    { background: var(--red-dim); color: var(--red); }
.badge-converted   { background: var(--tea-dim); color: var(--tea); }
.badge-called      { background: var(--pur-dim); color: var(--pur); }
.badge-visited     { background: var(--blu-dim); color: var(--blu); }
.badge-done        { background: var(--grn-dim); color: var(--grn); }
.badge-completed   { background: var(--grn-dim); color: var(--grn); }
.badge-failed      { background: var(--red-dim); color: var(--red); }
.badge-running     { background: var(--saf-dim); color: var(--saf); }
.badge-processing  { background: var(--saf-dim); color: var(--saf); }

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary {
    background: var(--saf);
    color: #000;
    border-color: var(--saf);
}

.btn-primary:hover:not(:disabled) {
    background: #ffba2e;
    border-color: #ffba2e;
}

.btn-outline {
    background: transparent;
    color: var(--tx-1);
    border-color: var(--border-light);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-overlay);
    border-color: var(--tx-3);
}

.btn-ghost {
    background: transparent;
    color: var(--tx-2);
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-overlay);
    color: var(--tx-1);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.btn-danger:hover:not(:disabled) {
    background: #ff6e67;
    border-color: #ff6e67;
}

.btn-success {
    background: var(--grn);
    color: #000;
    border-color: var(--grn);
}

.btn-success:hover:not(:disabled) {
    background: #56d364;
    border-color: #56d364;
}

.btn-sm  { font-size: 0.78rem; padding: 0.35rem 0.75rem; }
.btn-xs  { font-size: 0.7rem;  padding: 0.2rem 0.5rem; border-radius: var(--radius-sm); }
.btn-lg  { font-size: 0.95rem; padding: 0.65rem 1.5rem; }
.btn-block { width: 100%; }

/* ----- Forms ----- */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--tx-2);
}

.form-input,
.form-select,
.form-textarea {
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--tx-1);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    width: 100%;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--tx-3);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--saf);
    box-shadow: 0 0 0 3px var(--saf-glow);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b9eb0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

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

.form-error {
    font-size: 0.75rem;
    color: var(--red);
}

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

.form-row {
    display: grid;
    gap: 1rem;
}

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

/* ----- Filters ----- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-lbl {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--tx-2);
    white-space: nowrap;
}

.filter-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.filter-input,
.filter-select {
    font-family: var(--font-body);
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--tx-1);
    outline: none;
}

.filter-input:focus,
.filter-select:focus {
    border-color: var(--saf);
}

.filter-count {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--tx-3);
}

/* ----- Pagination ----- */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 1rem;
}

.pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--tx-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    padding: 0 0.5rem;
}

.pg-btn:hover {
    background: var(--bg-overlay);
    color: var(--tx-1);
}

.pg-active {
    background: var(--saf);
    color: #000;
    border-color: var(--saf);
    font-weight: 700;
}

.pg-active:hover {
    background: var(--saf);
    color: #000;
}

.pg-info {
    font-size: 0.78rem;
    color: var(--tx-3);
    margin-left: 0.75rem;
}

/* ----- Progress ----- */
.progress-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-track {
    flex: 1;
    height: 6px;
    background: var(--bg-overlay);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.pf-saf { background: var(--saf); }
.pf-blu { background: var(--blu); }
.pf-grn { background: var(--grn); }
.pf-tea { background: var(--tea); }
.pf-red { background: var(--red); }

.progress-pct {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tx-2);
    min-width: 36px;
    text-align: right;
}

/* ----- Alerts ----- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.alert-warn {
    background: var(--saf-dim);
    color: var(--saf);
    border: 1px solid rgba(240, 165, 0, 0.3);
}

.alert-err, .alert-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.alert-success {
    background: var(--grn-dim);
    color: var(--grn);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

/* ----- Breakdown Bars ----- */
.breakdown-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
}
.breakdown-label {
    font-size: 0.82rem;
    color: var(--tx-2);
    min-width: 100px;
}
.breakdown-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--bg-overlay);
    border-radius: 4px;
    overflow: hidden;
}
.breakdown-bar {
    height: 100%;
    background: var(--saf);
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 2px;
}
.breakdown-val {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--tx-1);
    min-width: 32px;
    text-align: right;
    font-family: var(--font-mono);
}

/* ----- Selected Row ----- */
.tr-selected {
    background: rgba(240, 165, 0, 0.08);
}
.tr-overdue {
    background: rgba(248, 81, 73, 0.06);
    border-left: 3px solid var(--red);
}
.tr-due {
    background: rgba(240, 165, 0, 0.06);
    border-left: 3px solid var(--saf);
}

/* ----- Notification Bell ----- */
.notif-wrap {
    position: relative;
    margin-right: 0.75rem;
}
.notif-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--tx-2);
    position: relative;
    padding: 0.35rem;
    border-radius: 6px;
    transition: background 0.15s;
}
.notif-btn:hover {
    background: var(--bg-hover);
    color: var(--tx-1);
}
.notif-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--red);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}
.notif-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
}
.notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--bg-raised);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.notif-panel-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bd);
}
.notif-panel-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--tx-1);
}
.notif-panel-body {
    overflow-y: auto;
    flex: 1;
    max-height: 360px;
}
.notif-panel-footer {
    border-top: 1px solid var(--bd);
    padding: 0.5rem;
}
.notif-item {
    display: flex;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--bd);
}
.notif-item:hover {
    background: var(--bg-hover);
}
.notif-unread {
    background: rgba(240, 165, 0, 0.04);
    border-left: 3px solid var(--saf);
}
.notif-item-icon {
    flex-shrink: 0;
    margin-top: 2px;
}
.notif-item-content {
    flex: 1;
    min-width: 0;
}
.notif-item-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--tx-1);
}
.notif-item-msg {
    font-size: 0.75rem;
    color: var(--tx-2);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-item-time {
    font-size: 0.65rem;
    color: var(--tx-3);
    margin-top: 0.2rem;
}
.notif-empty {
    padding: 2rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--tx-3);
}

/* ----- Notification Page Rows ----- */
.notif-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--bd);
    cursor: pointer;
    transition: background 0.15s;
}
.notif-row:hover {
    background: var(--bg-hover);
}
.notif-row-unread {
    background: rgba(240, 165, 0, 0.04);
    border-left: 3px solid var(--saf);
}
.notif-row-icon {
    flex-shrink: 0;
}
.notif-row-content {
    flex: 1;
    min-width: 0;
}
.notif-row-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tx-1);
}
.notif-row-msg {
    font-size: 0.8rem;
    color: var(--tx-2);
    margin-top: 0.15rem;
}
.notif-row-time {
    font-size: 0.75rem;
    color: var(--tx-3);
    white-space: nowrap;
    font-family: var(--font-mono);
}
.notif-row-type {
    flex-shrink: 0;
}

/* ----- Activity ----- */
.act-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.act-body {
    flex: 1;
    min-width: 0;
}

.act-title {
    font-size: 0.85rem;
    color: var(--tx-1);
}

.act-meta {
    font-size: 0.75rem;
    color: var(--tx-3);
    margin-top: 0.15rem;
}

/* ----- Misc ----- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.65rem;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--tx-2);
}

.div-h {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

.div-v {
    width: 1px;
    background: var(--border);
    align-self: stretch;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    min-height: 60vh;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-title {
    font-family: var(--font-head);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--tx-1);
    margin-bottom: 0.5rem;
}

.empty-sub {
    font-size: 0.9rem;
    color: var(--tx-2);
    max-width: 400px;
}

.col-main-side {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}

.col-main-wide {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
}

/* ----- Login ----- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    background-image:
        radial-gradient(ellipse 600px 300px at 50% 100%, rgba(240, 165, 0, 0.04) 0%, transparent 70%),
        radial-gradient(circle 400px at 80% 20%, rgba(88, 166, 255, 0.03) 0%, transparent 60%);
}

.login-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 165, 0, 0.08) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: login-pulse 4s ease-in-out infinite;
}

@keyframes login-pulse {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.1); }
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow:
        var(--shadow-lg),
        0 0 80px -20px rgba(240, 165, 0, 0.1);
    position: relative;
    z-index: 1;
    animation: login-card-in 0.5s ease-out;
}

@keyframes login-card-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-icon {
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: center;
}

.login-logo {
    font-family: var(--font-head);
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--saf);
    letter-spacing: -0.02em;
    line-height: 1;
}

.login-tagline {
    font-size: 0.82rem;
    color: var(--tx-3);
    margin-top: 0.4rem;
    letter-spacing: 0.02em;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

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

.login-divider span {
    font-size: 0.75rem;
    color: var(--tx-3);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.login-input-wrap {
    position: relative;
}

.login-input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tx-3);
    pointer-events: none;
    z-index: 1;
    transition: color 0.15s ease;
}

.login-input-icon-pad {
    padding-left: 2.5rem;
}

.login-input-wrap:focus-within .login-input-icon {
    color: var(--saf);
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    margin-top: -0.25rem;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--tx-2);
    cursor: pointer;
}

.login-remember input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--saf);
    cursor: pointer;
}

.login-btn {
    font-size: 0.95rem;
    padding: 0.7rem 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: all 0.2s ease;
}

.login-btn:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(240, 165, 0, 0.35);
    transform: translateY(-1px);
}

.login-btn:active:not(:disabled) {
    transform: translateY(0);
}

.login-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: login-spin 0.6s linear infinite;
}

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

.login-form .alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.login-footer span {
    font-size: 0.72rem;
    color: var(--tx-3);
    letter-spacing: 0.04em;
}

/* ----- Under Construction ----- */
.uc-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    background-image:
        radial-gradient(ellipse 500px 250px at 50% 90%, rgba(240, 165, 0, 0.04) 0%, transparent 70%),
        radial-gradient(circle 300px at 20% 30%, rgba(57, 197, 187, 0.03) 0%, transparent 60%);
}

.uc-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240, 165, 0, 0.06) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: login-pulse 5s ease-in-out infinite;
}

.uc-card {
    text-align: center;
    max-width: 480px;
    position: relative;
    z-index: 1;
    animation: login-card-in 0.5s ease-out;
}

.uc-icon {
    margin-bottom: 1.5rem;
    animation: uc-float 3s ease-in-out infinite;
}

@keyframes uc-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.uc-title {
    font-family: var(--font-head);
    font-size: 2rem;
    font-weight: 800;
    color: var(--saf);
    margin-bottom: 0.5rem;
}

.uc-sub {
    font-size: 0.95rem;
    color: var(--tx-2);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.uc-progress {
    margin-bottom: 2.5rem;
}

.uc-progress-track {
    height: 4px;
    background: var(--bg-overlay);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.6rem;
}

.uc-progress-fill {
    height: 100%;
    width: 25%;
    background: linear-gradient(90deg, var(--saf), #ffba2e);
    border-radius: 2px;
    animation: uc-progress-move 2.5s ease-in-out infinite;
}

@keyframes uc-progress-move {
    0%   { width: 15%; margin-left: 0; }
    50%  { width: 35%; margin-left: 30%; }
    100% { width: 15%; margin-left: 85%; }
}

.uc-progress-lbl {
    font-size: 0.75rem;
    color: var(--tx-3);
    letter-spacing: 0.03em;
}

.uc-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}

.uc-feature {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--tx-2);
    font-weight: 500;
    transition: border-color 0.2s ease;
}

.uc-feature:hover {
    border-color: var(--border-light);
    color: var(--tx-1);
}

.uc-btn {
    display: inline-flex;
}

.uc-btn:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(240, 165, 0, 0.35);
    transform: translateY(-1px);
}

.uc-footer {
    position: absolute;
    bottom: 1.5rem;
    font-size: 0.72rem;
    color: var(--tx-3);
    letter-spacing: 0.04em;
}

@media (max-width: 768px) {
    .uc-card {
        max-width: 100%;
    }

    .uc-title {
        font-size: 1.5rem;
    }

    .uc-features {
        grid-template-columns: 1fr;
    }

    .uc-glow {
        width: 300px;
        height: 300px;
    }
}

/* ----- Blazor Error UI ----- */
#blazor-error-ui {
    background: var(--bg-raised);
    border-top: 2px solid var(--red);
    color: var(--tx-1);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 0.85rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

#blazor-error-ui .reload {
    color: var(--saf);
    margin-left: 0.5rem;
}

.blazor-error-boundary {
    background: var(--red-dim);
    padding: 1rem 1rem 1rem 1rem;
    color: var(--red);
    border-radius: var(--radius);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ----- Blazor Validation ----- */
.valid.modified:not([type=checkbox]) {
    outline: none;
}

.invalid {
    outline: 1px solid var(--red);
}

.validation-message {
    color: var(--red);
    font-size: 0.75rem;
}

/* ----- Hamburger (hidden on desktop) ----- */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--tx-2);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
}
.hamburger-btn:hover { color: var(--tx-1); background: var(--bg-overlay); }

/* ----- Sidebar overlay (mobile only) ----- */
.sidebar-overlay {
    display: none;
}

/* ===== Tablet (≤ 1024px) ===== */
@media (max-width: 1024px) {
    .erp-shell {
        grid-template-columns: 1fr;
        grid-template-rows: var(--topbar-h) 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }

    .erp-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-w);
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    .erp-sidebar.sidebar-open {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 190;
    }

    .hamburger-btn {
        display: flex;
    }

    .erp-content {
        padding: 1.25rem;
    }

    .col-main-side,
    .col-main-wide {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .pg-hdr {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ===== Phone (≤ 768px) ===== */
@media (max-width: 768px) {
    .erp-content {
        padding: 0.75rem;
    }

    /* Forms stack */
    .form-row-2,
    .form-row-3,
    .form-row-4 {
        grid-template-columns: 1fr;
    }

    /* Stat grid 2-col */
    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.85rem;
    }
    .sc-val {
        font-size: 1.3rem;
    }

    /* Filter bar wrap */
    .filter-bar {
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }
    .filter-input {
        width: 100%;
        order: -1;
    }
    .filter-select {
        flex: 1;
        min-width: 0;
    }

    /* Tables: make scrollable with smaller font */
    table {
        font-size: 0.78rem;
    }
    th, td {
        padding: 0.5rem 0.6rem;
        white-space: nowrap;
    }

    /* Topbar compact */
    .erp-topbar {
        padding: 0 0.75rem;
    }
    .topbar-user {
        display: none;
    }
    .live-label {
        display: none;
    }

    /* Notification panel full width */
    .notif-panel {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        right: 0;
        width: auto;
        max-height: calc(100vh - var(--topbar-h));
        border-radius: 0;
    }

    /* Page header */
    .pg-hdr {
        flex-direction: column;
        gap: 0.35rem;
    }
    .pg-title {
        font-size: 1.15rem;
    }
    .pg-sub {
        font-size: 0.75rem;
    }

    /* Cards */
    .card {
        border-radius: var(--radius);
    }

    /* Login */
    .login-card {
        padding: 1.75rem;
        max-width: 100%;
    }
    .login-logo {
        font-size: 1.75rem;
    }
    .login-glow {
        width: 300px;
        height: 300px;
    }

    /* Sidebar narrower on phone */
    .erp-sidebar {
        width: 240px;
    }
}

/* ===== Small Phone (≤ 480px) ===== */
@media (max-width: 480px) {
    .erp-content {
        padding: 0.5rem;
    }

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

    .stat-card {
        padding: 0.75rem;
    }

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

    .pg-hdr-right {
        align-self: flex-start;
    }

    .btn-xs {
        font-size: 0.68rem;
        padding: 0.25rem 0.5rem;
    }
}
