*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f5f6fa;
    color: #1a1a2e;
    min-height: 100vh;
}

/* ─── Layout ─────────────────────────────────────────────── */
.app-layout {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

.page-content {
    flex: 1;
    min-width: 0;
    padding: 2rem 1.5rem;
    overflow-x: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    min-height: 100vh;
    background: #7D1A1A;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width .25s ease;
    overflow: hidden;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
}

.sidebar.collapsed {
    width: 64px;
}

/* Header burger */
.sidebar-header {
    background: var(--sidebar-header);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 56px;
    flex-shrink: 0;
}

.burger {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 4px;
    transition: background .15s;
}

.burger:hover { background: rgba(255,255,255,.15); }

/* Nav items */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: .5rem 0;
}

.sidebar-footer {
    padding: .5rem 0 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-size: .95rem;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
}

.nav-label {
    transition: opacity .2s, width .2s;
    opacity: 1;
}

.sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.nav-logout { color: rgba(255,255,255,.7); }
.nav-logout:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ─── Dashboard ───────────────────────────────────────────── */
.dashboard h1 { margin-bottom: 1.5rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.card {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card h3 { margin-bottom: .5rem; font-size: 1rem; }

/* ─── Login ───────────────────────────────────────────────── */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f5f6fa;
}
.login-box {
    background: #fff;
    padding: 2.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    width: 100%;
    max-width: 380px;
}
.login-box h1 { font-size: 1.1rem; color: #718096; margin-bottom: .25rem; }
.login-box h2 { margin-bottom: 1.5rem; }

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-group input {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    transition: border-color .2s;
}
.form-group input:focus { border-color: #7D1A1A; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn { padding: .65rem 1.25rem; border: none; border-radius: 6px; cursor: pointer; font-size: .95rem; font-weight: 500; }
.btn-primary { background: #7D1A1A; color: #fff; width: 100%; margin-top: .5rem; }
.btn-primary:hover { background: #A52828; }

/* ─── Alerts ──────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* ─── Catalogue ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-header h1 { font-size: 1.5rem; }
.last-sync { font-size: .8rem; color: #718096; display: block; margin-top: .2rem; }

.btn-sync {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #7D1A1A;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: .6rem 1.1rem;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}
.btn-sync:hover { background: #A52828; }
.btn-sync:disabled { background: #b0b0b0; cursor: not-allowed; }

.sync-progress {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}
.sync-bar-wrap {
    background: #e2e8f0;
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
    margin-bottom: .4rem;
}
.sync-bar {
    height: 100%;
    width: 0%;
    background: #7D1A1A;
    border-radius: 99px;
    transition: width .3s ease;
}
.sync-label { font-size: .82rem; color: #718096; }

.search-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.search-bar input {
    flex: 1;
    min-width: 200px;
    padding: .55rem .85rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .95rem;
    outline: none;
}
.search-bar input:focus { border-color: #7D1A1A; }
.btn-search { background: #7D1A1A; color: #fff; border: none; border-radius: 6px; padding: .55rem 1rem; font-size: .9rem; cursor: pointer; }
.btn-search:hover { background: #A52828; }
.btn-reset { background: #e2e8f0; color: #4a5568; border: none; border-radius: 6px; padding: .55rem 1rem; font-size: .9rem; cursor: pointer; text-decoration: none; }
.result-count { font-size: .85rem; color: #718096; margin-left: .25rem; }

.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
    font-size: .9rem;
}
.data-table thead { background: #f7f8fa; }
.data-table th {
    text-align: left;
    padding: .75rem 1rem;
    font-size: .78rem;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid #e2e8f0;
}
.data-table td {
    padding: .65rem 1rem;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbff; }

.td-id { color: #a0aec0; font-size: .82rem; }
.td-sku { color: #718096; font-size: .85rem; font-family: monospace; }
.td-supplier { font-size: .85rem; color: #4a5568; }
.td-price { white-space: nowrap; }
.td-readonly { color: #4a5568; font-size: .9rem; }

.price-display {
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: 4px;
    display: inline-block;
    min-width: 60px;
    transition: background .15s;
}
.price-display:hover { background: #eef2ff; color: #4f46e5; }
.price-display.editing { display: none; }

.price-input {
    width: 90px;
    padding: .25rem .4rem;
    border: 1.5px solid #7D1A1A;
    border-radius: 4px;
    font-size: .9rem;
    outline: none;
}
.price-input.saving { border-color: #a0aec0; background: #f7f8fa; }

.td-price.saved .price-display { color: #38a169; }

.pagination {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: 1.25rem;
    justify-content: center;
}
.pg-btn {
    padding: .45rem .9rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #4a5568;
    text-decoration: none;
    font-size: .88rem;
    transition: background .15s;
}
.pg-btn:hover { background: #f7f8fa; }
.pg-info { font-size: .88rem; color: #718096; }

.empty-state {
    background: #fff;
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    color: #718096;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #1a202c;
    color: #fff;
    padding: .65rem 1.25rem;
    border-radius: 8px;
    font-size: .9rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
    z-index: 9999;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #276749; }
.toast.error   { background: #9b2c2c; }
