:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #f59e0b;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

/* ============ LOGIN ============ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 55%, #d97706 140%);
    padding: 20px;
}
.login-card {
    background: var(--surface);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-brand { font-size: 52px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.login-card .login-sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-card .form-group { text-align: left; margin-bottom: 16px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.login-hint {
    margin-top: 18px; font-size: 12px; color: var(--muted); background: var(--bg);
    border-radius: 8px; padding: 10px; line-height: 1.6;
}
.quick-login {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--muted);
}
.quick-login b { width: 100%; }

/* ============ LAYOUT ============ */
.app-wrapper { display: flex; min-height: 100vh; }
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.page-content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

.sidebar {
    width: 250px; background: var(--sidebar-bg); color: var(--sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0;
    z-index: 100;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { font-size: 30px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #94a3b8; }
.sidebar-menu { list-style: none; padding: 10px 0; flex: 1; overflow-y: auto; }
.sidebar-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 16px 6px; font-weight: 700; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 11px; padding: 9px 16px; color: var(--sidebar-text);
    text-decoration: none; font-size: 13.5px; border-left: 3px solid transparent; transition: .15s;
}
.sidebar-menu a i { width: 18px; text-align: center; font-size: 14px; }
.sidebar-menu a .side-icon { width: 18px; text-align: center; font-size: 14px; line-height: 1; }
.sidebar-menu a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-menu a.active { background: rgba(245,158,11,.12); color: var(--sidebar-active); border-left-color: var(--sidebar-active); font-weight: 600; }
.sidebar-footer { padding: 14px 16px; font-size: 11.5px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

.topbar {
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px;
    display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 90;
}
.topbar-toggle { display: none; background: none; border: none; font-size: 18px; color: var(--muted); cursor: pointer; }
.topbar h2 { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-clock { color: var(--muted); font-size: 13px; }
.topbar-user { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; }
.topbar-user .avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.btn-logout {
    background: none; border: 1px solid var(--border); color: var(--muted); padding: 7px 12px;
    border-radius: 8px; cursor: pointer; font-size: 12.5px; transition: .15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: .2s; }
    .sidebar.show { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .topbar-toggle { display: block; }
    .page-content { padding: 16px; }
}

/* ============ CARDS / GRID ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14.5px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 800px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; display: flex; align-items: center; gap: 14px;
}
.stat-icon {
    width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex-shrink: 0;
}
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-value { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--muted); }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left; padding: 11px 14px; background: #f8fafc; color: var(--muted);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions button { margin-left: 4px; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text); transition: .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; display: none; }
.form-group.invalid input { border-color: var(--danger); }
.form-group.invalid .form-error { display: block; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 8px;
    border: 1px solid transparent; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: .15s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ ALERTS / TOASTS ============ */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert .close { margin-left: auto; cursor: pointer; background: none; border: none; color: inherit; font-size: 14px; }

.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 11px 16px; border-radius: 10px; color: #fff; font-size: 13.5px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; align-items: center; gap: 9px; animation: slideIn .25s;
    max-width: 340px;
}
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.warning { background: #d97706; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ MODALS ============ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px; animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh;
    display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.3); animation: popIn .18s;
}
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 15px; }
.modal-close { background: none; border: none; font-size: 17px; color: var(--muted); cursor: pointer; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ BADGES ============ */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ============ TPV ============ */
.tpv-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .tpv-layout { grid-template-columns: 1fr; } }
.tpv-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.tpv-toolbar input { max-width: 280px; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: 66vh; overflow-y: auto; padding: 2px; }
.prod-card {
    border: 1px solid var(--border); border-radius: 12px; padding: 13px; cursor: pointer; background: #fff;
    transition: .15s; text-align: center; user-select: none;
}
.prod-card:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(245,158,11,.18); transform: translateY(-2px); }
.prod-card .p-emoji { font-size: 30px; }
.prod-card .p-name { font-weight: 700; font-size: 12.5px; margin-top: 6px; min-height: 32px; }
.prod-card .p-price { color: var(--primary-dark); font-weight: 800; font-size: 13.5px; }
.prod-card .p-stock { font-size: 11px; color: var(--muted); }
.prod-card.disabled { opacity: .45; pointer-events: none; }
.cart-card { position: sticky; top: 78px; }
.cart-items { max-height: 42vh; overflow-y: auto; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.cart-item .ci-name { flex: 1; font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.cart-item .ci-price { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cart-qty { display: flex; align-items: center; gap: 6px; }
.cart-qty button {
    width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: #fff;
    cursor: pointer; font-weight: 700; line-height: 1;
}
.cart-qty button:hover { border-color: var(--primary); color: var(--primary-dark); }
.cart-qty .qty { width: 26px; text-align: center; font-weight: 700; }
.cart-summary { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.sum-line { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--muted); }
.sum-line.total { font-size: 18px; font-weight: 800; color: var(--text); border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }

/* ============ TICKET PRINT ============ */
.ticket-print { font-family: 'Courier New', monospace; font-size: 12px; line-height: 1.45; white-space: pre-wrap; }
.ticket-print .tp-head { text-align: center; font-weight: 700; font-size: 14px; }
.ticket-print .tp-thin { width: 100%; border-bottom: 1px dashed #000; margin: 6px 0; }
.ticket-print .tp-row { display: flex; justify-content: space-between; }
.ticket-print .tp-total { text-align: center; font-weight: 700; font-size: 16px; margin: 10px 0; }
@media print {
    body * { visibility: hidden; }
    .ticket-print, .ticket-print * { visibility: visible; }
    .ticket-print { position: fixed; left: 0; top: 0; width: 80mm; }
}

/* ============ MISC ============ */
.page-title { font-size: 19px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.page-emoji { font-size: 16px; line-height: 1; }
.url-bar { margin-bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.tab-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 9px 16px; border: 1px solid var(--border); border-bottom: none; border-radius: 10px 10px 0 0; cursor: pointer; font-weight: 600; font-size: 13px; background: #fff; color: var(--muted); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.empty-state { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13.5px; }
.empty-state i, .empty-state .page-emoji { font-size: 34px; margin-bottom: 8px; opacity: .4; }
.search-input { max-width: 300px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-success { color: #16a34a; }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary-dark); }
.fw-700 { font-weight: 700; }
.small { font-size: 12px; }