/* ============================================================
   RC Inventory  --  Carbon Fiber / Industrial Aesthetic
   ============================================================ */

/* ---------- Custom properties: Dark theme (default) ---------- */
:root,
[data-theme="dark"] {
    --bg-base: #0e0f11;
    --bg-surface: #161719;
    --bg-elevated: #1c1d20;
    --bg-hover: #232428;
    --bg-input: #1a1b1e;

    --border: #2a2b2f;
    --border-subtle: #222326;

    --text-primary: #e8e9eb;
    --text-secondary: #9b9da3;
    --text-muted: #5f6168;

    --accent: #00d4aa;
    --accent-dim: rgba(0,212,170,0.12);
    --accent-hover: #00eabc;

    --danger: #f04e5e;
    --danger-dim: rgba(240,78,94,0.12);
    --warning: #f0a030;
    --warning-dim: rgba(240,160,48,0.12);
    --info: #4e9ef0;
    --info-dim: rgba(78,158,240,0.12);

    --status-instock: #00d4aa;
    --status-instock-bg: rgba(0,212,170,0.1);
    --status-inuse: #4e9ef0;
    --status-inuse-bg: rgba(78,158,240,0.1);
    --status-broken: #f04e5e;
    --status-broken-bg: rgba(240,78,94,0.1);
    --status-ordered: #f0a030;
    --status-ordered-bg: rgba(240,160,48,0.1);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

    --carbon-pattern: url("data:image/svg+xml,%3Csvg width='6' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='6' height='6' fill='%23161719'/%3E%3Crect width='3' height='3' fill='%23131416'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%23131416'/%3E%3C/svg%3E");

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    color-scheme: dark;
}

/* ---------- Light theme ---------- */
[data-theme="light"] {
    --bg-base: #f3f4f6;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-hover: #f0f1f3;
    --bg-input: #f7f8fa;

    --border: #dfe0e4;
    --border-subtle: #e8e9ec;

    --text-primary: #1a1c20;
    --text-secondary: #5f6168;
    --text-muted: #9b9da3;

    --accent: #009e7e;
    --accent-dim: rgba(0,158,126,0.08);
    --accent-hover: #00b892;

    --danger: #d83a4a;
    --danger-dim: rgba(216,58,74,0.08);
    --warning: #c88020;
    --warning-dim: rgba(200,128,32,0.08);
    --info: #3080d0;
    --info-dim: rgba(48,128,208,0.08);

    --status-instock: #009e7e;
    --status-instock-bg: rgba(0,158,126,0.08);
    --status-inuse: #3080d0;
    --status-inuse-bg: rgba(48,128,208,0.08);
    --status-broken: #d83a4a;
    --status-broken-bg: rgba(216,58,74,0.08);
    --status-ordered: #c88020;
    --status-ordered-bg: rgba(200,128,32,0.08);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);

    --carbon-pattern: none;

    color-scheme: light;
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-base);
    background-image: var(--carbon-pattern);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4 {
    font-family: 'Chakra Petch', 'Rajdhani', sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
}

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

::selection {
    background: var(--accent);
    color: var(--bg-base);
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.view { display: none; }
.view:not(.hidden) { display: block; }

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

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

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

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

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
}

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

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

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- Auth pages (setup / login) ---------- */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    animation: fadeUp 0.5s ease;
}

.auth-logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo-icon {
    width: 72px;
    height: 72px;
    color: var(--accent);
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px rgba(0,212,170,0.25));
}

.auth-logo h1 {
    font-size: 2rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.auth-form {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.auth-form input {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
}

.auth-form input:focus {
    border-color: var(--accent);
}

.auth-form .btn {
    margin-top: 8px;
}

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.topbar-logo {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.topbar-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.topbar-nav {
    display: flex;
    gap: 4px;
    margin-left: 32px;
}

.nav-btn {
    padding: 6px 16px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.nav-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.nav-btn.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

/* Theme toggle icons */
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

/* ---------- Pages ---------- */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 60px;
    animation: fadeUp 0.35s ease;
}

.page.hidden {
    display: none;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.5rem;
    letter-spacing: 0.04em;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    border-color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

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

.stat-value {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.info .stat-value { color: var(--info); }
.stat-card.danger .stat-value { color: var(--danger); }

.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.card-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Category bars */
.category-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cat-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cat-label {
    width: 100px;
    font-size: 0.8rem;
    text-transform: capitalize;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.cat-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
}

.cat-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.cat-bar-fill.build { background: var(--accent); }
.cat-bar-fill.part { background: var(--info); }
.cat-bar-fill.accessory { background: var(--warning); }
.cat-bar-fill.wishlist { background: #a06ef0; }

.cat-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 32px;
    text-align: right;
    flex-shrink: 0;
}

/* Low stock list */
.low-stock-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.low-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--danger-dim);
    border: 1px solid rgba(240,78,94,0.15);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.low-stock-item .ls-name {
    color: var(--text-primary);
    font-weight: 500;
}

.low-stock-item .ls-qty {
    color: var(--danger);
    font-weight: 600;
    font-family: 'Chakra Petch', sans-serif;
}

.low-stock-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 24px 0;
}

/* ---------- Tabs ---------- */
.tab-bar {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

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

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---------- Search bar ---------- */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
}

#search-input:focus {
    border-color: var(--accent);
}

/* ---------- Table ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

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

#inventory-table thead th {
    padding: 12px 14px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s;
}

#inventory-table thead th:hover {
    color: var(--text-secondary);
}

#inventory-table thead th .sort-arrow {
    font-size: 0.65rem;
    margin-left: 4px;
    opacity: 0.4;
}

#inventory-table thead th.sorted-asc .sort-arrow::after { content: '\25B2'; opacity: 1; }
#inventory-table thead th.sorted-desc .sort-arrow::after { content: '\25BC'; opacity: 1; }

.col-num { text-align: right; }
.col-link { text-align: center; width: 50px; }
.col-actions { text-align: right; width: 120px; }

#inventory-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color 0.1s;
}

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

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

#inventory-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    white-space: nowrap;
}

.td-name {
    font-weight: 500;
    color: var(--text-primary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-price {
    text-align: right;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 500;
}

.td-qty {
    text-align: right;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
}

.td-qty.low-stock {
    color: var(--danger);
}

/* Status badge */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 20px;
    white-space: nowrap;
}

.status-badge.in-stock {
    color: var(--status-instock);
    background: var(--status-instock-bg);
}
.status-badge.in-use {
    color: var(--status-inuse);
    background: var(--status-inuse-bg);
}
.status-badge.broken {
    color: var(--status-broken);
    background: var(--status-broken-bg);
}
.status-badge.ordered {
    color: var(--status-ordered);
    background: var(--status-ordered-bg);
}

/* Link icon */
.link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--text-muted);
    transition: color 0.15s;
}

.link-icon:hover {
    color: var(--accent);
}

.link-icon svg {
    width: 16px;
    height: 16px;
}

/* Row actions */
.row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.row-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.row-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border);
}

.row-actions button.del:hover {
    color: var(--danger);
    background: var(--danger-dim);
    border-color: rgba(240,78,94,0.2);
}

.row-actions button.dup:hover {
    color: var(--info);
    background: var(--info-dim);
    border-color: rgba(78,158,240,0.2);
}

.row-actions button svg {
    width: 15px;
    height: 15px;
}

/* Save & Add Similar button */
.btn-accent-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-accent-outline:hover {
    background: var(--accent-dim);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-icon {
    width: 48px;
    height: 48px;
    opacity: 0.4;
}

/* ---------- Modal ---------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
    padding: 24px;
}

.overlay.hidden {
    display: none;
}

.modal {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: scaleUp 0.2s ease;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    letter-spacing: 0.04em;
}

.modal-header .icon-btn {
    border: none;
    font-size: 1.4rem;
    line-height: 1;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: flex;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

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

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%239b9da3' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

#item-type-custom {
    margin-top: 6px;
}

/* Autocomplete dropdown */
.autocomplete-wrap {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 600;
    max-height: 160px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.autocomplete-list .ac-item {
    padding: 8px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.1s;
}

.autocomplete-list .ac-item:hover,
.autocomplete-list .ac-item.active {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.autocomplete-list .ac-item mark {
    background: none;
    color: var(--accent);
    font-weight: 600;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

/* ---------- Confirm dialog ---------- */
.confirm-dialog {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    max-width: 380px;
    text-align: center;
    animation: scaleUp 0.2s ease;
}

.confirm-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    color: var(--warning);
}

.confirm-dialog p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ---------- Toast ---------- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 12px 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.82rem;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.toast-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--accent); }
.toast.error .toast-dot { background: var(--danger); }
.toast.warning .toast-dot { background: var(--warning); }

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

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

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

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

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .topbar {
        padding: 0 14px;
        gap: 10px;
    }

    .topbar-title {
        display: none;
    }

    .topbar-nav {
        margin-left: 12px;
    }

    .nav-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .page {
        padding: 20px 14px 48px;
    }

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

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
        justify-content: center;
    }

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

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

    .form-row {
        flex-direction: column;
        gap: 14px;
    }

    .tab-bar {
        gap: 0;
    }

    .tab {
        padding: 10px 12px;
        font-size: 0.75rem;
    }

    /* Stack table into cards on mobile */
    .table-wrap {
        border: none;
        background: transparent;
    }

    #inventory-table thead {
        display: none;
    }

    #inventory-table,
    #inventory-table tbody,
    #inventory-table tr,
    #inventory-table td {
        display: block;
    }

    #inventory-table tbody tr {
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 14px;
        margin-bottom: 10px;
    }

    #inventory-table tbody td {
        padding: 3px 0;
        white-space: normal;
        text-align: left !important;
    }

    #inventory-table tbody td::before {
        content: attr(data-label);
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-muted);
        display: block;
        margin-bottom: 2px;
    }

    #inventory-table tbody td.col-actions {
        padding-top: 10px;
        border-top: 1px solid var(--border-subtle);
        margin-top: 6px;
    }

    #inventory-table tbody td.col-actions::before {
        display: none;
    }

    .row-actions {
        justify-content: flex-start;
    }
}

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

    .auth-logo h1 {
        font-size: 1.6rem;
    }

    #toast-container {
        right: 14px;
        left: 14px;
    }

    .toast {
        max-width: 100%;
    }
}
