@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f0f4f8;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #0f1929;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #1769aa;
    --primary-dark: #0f4775;
    --primary-light: #e8f1fa;
    --accent: #18a058;
    --accent-light: #e6f6ef;
    --green: #16825a;
    --red: #c0392b;
    --red-light: #fef2f2;
    --amber: #b7791f;
    --amber-light: #fffbeb;
    --shadow-sm: 0 1px 3px rgba(15,25,41,0.08), 0 1px 2px rgba(15,25,41,0.04);
    --shadow: 0 4px 16px rgba(15,25,41,0.08), 0 2px 6px rgba(15,25,41,0.04);
    --shadow-lg: 0 12px 32px rgba(15,25,41,0.12), 0 4px 12px rgba(15,25,41,0.06);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

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

/* ── Sidebar ── */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 0;
    background: linear-gradient(180deg, #0d1f30 0%, #142536 100%);
    color: #f1f5f9;
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #18a058, #0d7a44);
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.5px;
    box-shadow: 0 4px 12px rgba(24,160,88,0.35);
}

.brand strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.2;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: #64859e;
    font-size: 11px;
    font-weight: 500;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 12px;
    flex: 1;
}

.nav-label {
    padding: 8px 10px 4px;
    color: #4a6a82;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: #94b4cc;
    font-weight: 500;
    font-size: 13.5px;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

nav a .nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: transform var(--transition);
}

nav a.active,
nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}

nav a.active {
    background: rgba(23,105,170,0.25);
    color: #7ec8ff;
}

nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: #3b9ede;
    border-radius: 0 3px 3px 0;
}

nav a:hover .nav-icon {
    transform: translateX(2px);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

/* ── Main Area ── */
.main {
    min-width: 0;
    padding: 0 28px 32px;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    margin: 0 -28px 24px;
    padding: 10px 28px;
    background: rgba(240,244,248,0.92);
    border-bottom: 1px solid rgba(226,232,240,0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

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

.topbar-breadcrumb {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.topbar span {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--muted);
}

.topbar a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 32px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: #e2eaf2;
    color: #1a3a52;
    font-weight: 600;
    font-size: 13px;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.topbar a:hover,
.topbar a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(23,105,170,0.25);
}

/* ── Page Head ── */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

h1 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.3px;
    color: var(--ink);
}

h2 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
}

p {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
}

/* ── Stats Grid ── */
.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

/* ── Cards ── */
.card,
.table-wrap,
.form-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
    border-radius: var(--radius) 0 0 var(--radius);
}

.card.red::before { background: var(--red); }
.card.blue::before { background: var(--primary); }
.card.amber::before { background: var(--amber); }

.card small {
    color: var(--muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card strong {
    display: block;
    margin-top: 6px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--ink);
}

.card .card-icon {
    position: absolute;
    top: 18px;
    right: 18px;
    font-size: 22px;
    opacity: 0.12;
}

/* ── Table ── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f0f4f8;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: 0;
}

small {
    color: var(--muted);
    font-size: 12px;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 22px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.badge.in {
    background: #e6f6ef;
    color: #16825a;
    border: 1px solid #b7e4cd;
}

.badge.out {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fecaca;
}

.badge.warn {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fed7aa;
}

.badge.dori {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* ── Form Card ── */
.form-card {
    max-width: 900px;
    padding: 22px;
    border-radius: var(--radius);
}

.filter-card {
    max-width: none;
    margin-bottom: 20px;
    background: var(--panel-soft);
}

/* ── Form Grid ── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 16px;
}

/* ── Labels & Inputs ── */
label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-weight: 600;
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(23,105,170,0.13);
    background: #fff;
}

input::placeholder,
textarea::placeholder {
    color: #a0aec0;
}

input.input-danger,
input.input-danger:focus {
    border-color: var(--red);
    background: var(--red-light);
    color: var(--red);
    box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}

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

/* ── Stock Info ── */
.stock-info {
    align-self: end;
    min-height: 40px;
    padding: 10px 14px;
    border: 1.5px solid #b7e4cd;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--green);
    line-height: 1.6;
    font-size: 13px;
}

.stock-info.danger {
    border-color: #fecaca;
    background: var(--red-light);
    color: var(--red);
}

/* ── Actions ── */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.1px;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(23,105,170,0.28);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn.secondary {
    background: #e8eef5;
    color: #1e3a52;
    box-shadow: none;
}

.btn.secondary:hover {
    background: #d6e3ef;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.btn.danger {
    background: #fef2f2;
    color: var(--red);
    border: 1px solid #fecaca;
}

.btn.danger:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
    box-shadow: 0 4px 12px rgba(192,57,43,0.25);
}

.btn.success {
    background: var(--accent);
    color: #fff;
}

.btn.success:hover {
    background: var(--green);
    box-shadow: 0 4px 12px rgba(24,160,88,0.28);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Alert ── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--green);
    border: 1px solid #b7e4cd;
    font-weight: 600;
    font-size: 13.5px;
}

.alert.error {
    background: var(--red-light);
    color: var(--red);
    border-color: #fecaca;
}

/* ── Auth ── */
.auth-body {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #0d1f30 0%, #1a3a52 50%, #0f4775 100%);
}

.auth-card {
    width: min(440px, 100%);
    padding: 36px;
    background: rgba(255,255,255,0.97);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    margin-bottom: 28px;
    text-align: center;
}

.auth-brand .brand-mark {
    width: 56px;
    height: 56px;
    font-size: 20px;
    margin: 0 auto 14px;
}

.auth-brand strong {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 4px;
}

.auth-brand p {
    font-size: 13px;
}

.auth-card form {
    display: grid;
    gap: 16px;
}

.auth-btn {
    width: 100%;
    min-height: 44px;
    font-size: 15px;
}

/* ── Inline form ── */
.inline-form {
    display: inline;
}

.inline-form button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition);
}

.inline-form button:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ── Footer ── */
.footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    margin-top: 32px;
    font-size: 12.5px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

/* ── Status colors ── */
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-amber { color: var(--amber); }
.text-blue  { color: var(--primary); }
.text-muted { color: var(--muted); }

.bg-green  { background: var(--accent-light); }
.bg-red    { background: var(--red-light); }
.bg-amber  { background: var(--amber-light); }

/* ── Combobox ── */
.combobox-container {
    position: relative;
    width: 100%;
}

.combobox-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    margin-top: 4px;
}

.combobox-option {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background var(--transition);
}

.combobox-option:last-child { border-bottom: none; }

.combobox-option:hover {
    background: var(--primary-light);
}

.combobox-option strong {
    display: block;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 600;
}

.combobox-option small {
    color: var(--muted);
    font-size: 12px;
}

.qty-edit-input {
    width: 88px;
    min-height: 30px;
    padding: 4px 8px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 700;
    font-family: inherit;
    font-size: 13px;
    background: #f8fafc;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.qty-edit-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23,105,170,0.13);
    outline: none;
    background: #fff;
}

/* ── Section divider ── */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    body {
        grid-template-columns: 230px minmax(0, 1fr);
    }
    .grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }
}

@media (max-width: 780px) {
    body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 0;
    }

    .brand {
        padding: 14px 16px 12px;
    }

    nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px 12px 10px;
        gap: 4px;
    }

    nav a {
        flex: 1;
        min-width: 80px;
        justify-content: center;
        min-height: 36px;
        font-size: 12px;
        padding: 7px 8px;
    }

    nav a .nav-icon {
        display: none;
    }

    .main {
        padding: 0 16px 24px;
    }

    .topbar {
        margin: 0 -16px 20px;
        padding: 10px 16px;
    }

    .grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-head {
        flex-direction: column;
        gap: 10px;
    }

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

    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }

    h1 {
        font-size: 18px;
    }
}

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

    .topbar {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .topbar span {
        width: 100%;
    }

    .actions .btn,
    .actions button {
        width: 100%;
        justify-content: center;
}
}

/* ── Modal Popup ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--panel);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 580px;
    border: 1px solid var(--line);
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

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

.modal-body {
    padding: 24px 20px;
    max-height: 80vh;
    overflow-y: auto;
}
