/* ============================================================
   Kasir Toko POS — Design System
   Professional business software aesthetic.
   No gradients, no glassmorphism, no decorative animations.
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    /* Brand: Elegant Royal Blue */
    --brand:          #2563eb;
    --brand-dark:     #1d4ed8;
    --brand-light:    #eff6ff;
    --brand-muted:    #dbeafe;

    /* Semantic: Harmonious & Softer on the Eyes */
    --success:        #059669;
    --success-bg:     #ecfdf5;
    --success-border: #a7f3d0;
    --danger:         #dc2626;
    --danger-bg:      #fef2f2;
    --danger-border:  #fecaca;
    --warning:        #d97706;
    --warning-bg:     #fffbeb;
    --warning-border: #fde68a;
    --info:           #2563eb;
    --info-bg:        #eff6ff;
    --info-border:    #dbeafe;

    /* Neutrals: Clean Slate */
    --gray-0:   #ffffff;
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-150: #e2e8f0;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Typography */
    --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;

    --text-xs:   0.75rem;    /* 12px */
    --text-sm:   0.8125rem;  /* 13px */
    --text-base: 0.9375rem;  /* 15px */
    --text-lg:   1.0625rem;  /* 17px */
    --text-xl:   1.25rem;    /* 20px */
    --text-2xl:  1.5rem;     /* 24px */
    --text-3xl:  1.875rem;   /* 30px */

    /* Spacing scale (4px base) */
    --sp-1:  0.25rem;   /* 4px  */
    --sp-2:  0.5rem;    /* 8px  */
    --sp-3:  0.75rem;   /* 12px */
    --sp-4:  1rem;      /* 16px */
    --sp-5:  1.25rem;   /* 20px */
    --sp-6:  1.5rem;    /* 24px */
    --sp-8:  2rem;      /* 32px */
    --sp-10: 2.5rem;    /* 40px */
    --sp-12: 3rem;      /* 48px */

    /* Radius */
    --radius-sm: 0.25rem;
    --radius:    0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.03);
    --shadow:    0 2px 6px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.04);

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

    /* Transitions */
    --t-fast: 120ms ease;
    --t-base: 200ms ease;
    --t-slow: 320ms ease;

    /* Z-index */
    --z-sidebar:  200;
    --z-overlay:  190;
    --z-modal:    300;
    --z-toast:    400;
    --z-dropdown: 150;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--sp-3);
    font-weight: 600;
    line-height: 1.3;
    color: var(--gray-900);
}

p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-sm); }

img, svg { display: block; max-width: 100%; }

/* ── Skip Link ──────────────────────────────────────────────── */
.skip-link {
    position: absolute;
    top: -9999px;
    left: var(--sp-4);
    background: var(--brand);
    color: #fff;
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    z-index: 999;
}
.skip-link:focus { top: var(--sp-2); }

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar (Soft Slate & Elegant Gray) ───────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: #f8fafc;
    color: #475569;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform var(--t-slow);
    flex-shrink: 0;
    z-index: var(--z-sidebar);
}

.app-shell.sidebar-collapsed .sidebar {
    margin-left: calc(-1 * var(--sidebar-w));
}

.sidebar-brand {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    max-height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-4);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar-brand-icon {
    width: 34px;
    height: 34px;
    background: #0f172a;
    color: #ffffff;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.sidebar-brand-icon svg { width: 18px; height: 18px; stroke: #ffffff; color: #ffffff; fill: none; }

.sidebar-brand-name {
    font-size: var(--text-sm);
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -.01em;
    line-height: 1.2;
}

.sidebar-brand-name small {
    display: block;
    font-size: var(--text-xs);
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0;
}

.sidebar-nav {
    flex: 1;
    padding: var(--sp-3) 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #94a3b8;
    padding: var(--sp-4) var(--sp-5) var(--sp-2);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 8px 12px;
    margin: 2px 10px;
    color: #475569;
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    transition: color var(--t-fast), background var(--t-fast);
    line-height: 1.5;
    min-height: 38px;
}

.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; stroke: currentColor; }
.nav-link:hover { color: #0f172a; background: #e2e8f0; text-decoration: none; }
.nav-link.active {
    color: #0f172a;
    background: #e2e8f0;
    font-weight: 700;
    box-shadow: none;
}
.nav-link.active svg { opacity: 1; stroke: #0f172a; }
.nav-link:focus-visible { outline: 2px solid #cbd5e1; outline-offset: -2px; }

.sidebar-footer {
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    background: #f8fafc;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--text-xs);
    font-weight: 700;
    color: #fff;
    letter-spacing: .02em;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role { font-size: var(--text-xs); color: #64748b; }

.sidebar-logout {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    border-radius: var(--radius-sm);
    transition: color var(--t-fast), background var(--t-fast);
    flex-shrink: 0;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
}
.sidebar-logout:hover { color: #0f172a; background: #e2e8f0; }
.sidebar-logout svg { width: 16px; height: 16px; }

/* ── Main Content Area ──────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    max-height: var(--topbar-h);
    background: var(--gray-0);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-6);
    gap: var(--sp-4);
    flex-shrink: 0;
    box-sizing: border-box;
}

.topbar-toggle {
    display: flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--gray-600);
    flex-shrink: 0;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.topbar-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-900);
    border-color: var(--gray-300);
}
.topbar-toggle svg { width: 18px; height: 18px; }

.topbar-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--gray-900);
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
}

.topbar-meta {
    font-size: var(--text-xs);
    color: var(--gray-600);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    box-sizing: border-box;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    padding: 0 12px;
    border-radius: var(--radius);
    font-weight: 500;
    line-height: 1;
}

/* ── Content Area & Smooth Refresh Animation ────────────────── */
@keyframes appPageFadeIn {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: var(--sp-6);
    -webkit-overflow-scrolling: touch;
    animation: appPageFadeIn 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.content-body {
    flex: 1 0 auto;
    width: 100%;
}

.app-page-footer {
    margin-top: auto !important;
    padding: 32px 0 16px;
    text-align: center;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-500);
    font-size: var(--text-xs);
    flex-shrink: 0;
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .content-area, .login-wrap, .card {
        animation: none !important;
    }
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
}

.page-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    line-height: 1.3;
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--gray-500);
    margin: var(--sp-1) 0 0;
}

.page-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

/* ── Alerts (Flash Messages) ────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    margin-bottom: var(--sp-4);
    font-size: var(--text-sm);
    border: 1px solid transparent;
    line-height: 1.5;
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-bg); color: #065f46; border-color: var(--success-border); }
.alert-error   { background: var(--danger-bg);  color: #9f1239; border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: #78350f; border-color: var(--warning-border); }
.alert-info    { background: var(--info-bg);    color: #1e3a8a; border-color: var(--info-border); }

.alert-dismiss {
    margin-left: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: .6;
    padding: 0;
    color: inherit;
    line-height: 1;
    flex-shrink: 0;
}
.alert-dismiss:hover { opacity: 1; }
.alert-dismiss svg { width: 14px; height: 14px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 500;
    font-family: var(--font);
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast),
                color var(--t-fast), box-shadow var(--t-fast),
                opacity var(--t-fast);
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

.btn:focus { outline: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[disabled], .btn.disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Sizes */
.btn-xs  { padding: 5px 7px; font-size: var(--text-xs); min-width: 28px; min-height: 28px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm  { padding: var(--sp-1) var(--sp-3); font-size: var(--text-sm); }
.btn-lg  { padding: var(--sp-3) var(--sp-6); font-size: var(--text-base); }
.btn-xl  { padding: var(--sp-4) var(--sp-8); font-size: var(--text-lg); font-weight: 600; }
.btn-block { width: 100%; }
.btn-icon  { width: 38px; height: 38px; min-width: 38px; min-height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); flex-shrink: 0; box-sizing: border-box; }
.btn-icon svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Variants */
.btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-secondary {
    background: var(--gray-0);
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:hover { background: #0d6b4f; border-color: #0d6b4f; }

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

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-outline-primary {
    background: transparent;
    color: var(--brand);
    border-color: var(--brand);
}
.btn-outline-primary:hover { background: var(--brand-light); }

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger-border);
}
.btn-outline-danger:hover { background: var(--danger-bg); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--gray-0);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.card-body { padding: var(--sp-5); }
.card-header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
}
.card-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.card-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

/* ── Stat Cards (Dashboard) ──────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.stat-card {
    background: var(--gray-0);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    box-shadow: var(--shadow-xs);
}

.stat-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-500);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -.02em;
    line-height: 1.2;
}

.stat-trend {
    font-size: var(--text-xs);
    color: var(--gray-400);
}

.stat-icon-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-3);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon svg { width: 20px; height: 20px; }

.stat-icon-blue   { background: #eff4ff; color: var(--brand); }
.stat-icon-green  { background: var(--success-bg); color: var(--success); }
.stat-icon-orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon-red    { background: var(--danger-bg); color: var(--danger); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-4); }

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--sp-1);
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    display: block;
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    font-family: var(--font);
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-0);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    appearance: none;
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(200,16,46,.10);
}

.form-control:disabled, .form-control[readonly] {
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: not-allowed;
}

.form-control::placeholder { color: var(--gray-400); }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 20px;
    padding-right: 2.25rem;
}

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

.invalid-feedback {
    display: block;
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--sp-1);
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--gray-500);
    margin-top: var(--sp-1);
}

/* Input group */
.input-group { display: flex; }
.input-group .form-control { flex: 1; border-radius: var(--radius) 0 0 var(--radius); }
.input-group-text {
    display: flex;
    align-items: center;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-left: none;
    color: var(--gray-600);
    border-radius: 0 var(--radius) var(--radius) 0;
    white-space: nowrap;
}
.input-group-prepend .input-group-text {
    border-right: none;
    border-left: 1px solid var(--gray-300);
    border-radius: var(--radius) 0 0 var(--radius);
}
.input-group-prepend + .form-control { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group-append .form-control { border-radius: var(--radius) 0 0 var(--radius); }

/* Form row */
.form-row { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
    background: var(--gray-0);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

.table-toolbar-left, .table-toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.table-search {
    position: relative;
}
.table-search input {
    padding-left: var(--sp-8);
    width: 240px;
}
.table-search-icon {
    position: absolute;
    left: var(--sp-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}
.table-search-icon svg { width: 15px; height: 15px; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th {
    padding: var(--sp-3) var(--sp-4);
    background: var(--gray-50);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
    text-align: left;
}

.table td {
    padding: var(--sp-3) var(--sp-4);
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-150);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

.table .actions { display: flex; gap: var(--sp-1); align-items: center; }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }
.table .col-narrow { width: 1%; white-space: nowrap; }
.table .col-wide { min-width: 200px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0.125rem 0.4375rem;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.5;
    border-radius: 9999px;
    white-space: nowrap;
}

.badge-primary { background: var(--brand-light); color: var(--brand); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-neutral { background: var(--gray-100);   color: var(--gray-600); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

.pagination-meta { font-size: var(--text-sm); color: var(--gray-500); }

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--sp-2);
    font-size: var(--text-sm);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.page-link:hover { background: var(--gray-100); border-color: var(--gray-300); text-decoration: none; }
.page-link.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-link.disabled { opacity: .4; pointer-events: none; }

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-12) var(--sp-6);
    text-align: center;
    color: var(--gray-500);
}
.empty-state-icon { margin-bottom: var(--sp-4); color: var(--gray-300); }
.empty-state-icon svg { width: 48px; height: 48px; }
.empty-state h3 { font-size: var(--text-base); color: var(--gray-700); margin-bottom: var(--sp-2); }
.empty-state p { font-size: var(--text-sm); max-width: 32ch; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--t-base), visibility var(--t-base);
}
.modal-overlay.is-open { opacity: 1; visibility: visible; }

.modal {
    background: var(--gray-0);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    transform: translateY(8px);
    transition: transform var(--t-base);
}
.modal-overlay.is-open .modal { transform: translateY(0); }

.modal-header {
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}
.modal-title { font-size: var(--text-lg); font-weight: 600; margin: 0; }
.modal-close {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; cursor: pointer;
    color: var(--gray-500); border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-800); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: var(--sp-5); }
.modal-footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--sp-2);
    justify-content: flex-end;
}

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: var(--sp-4);
    right: var(--sp-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
    max-width: 360px;
    width: calc(100vw - 2rem);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    box-shadow: var(--shadow-md);
    font-size: var(--text-sm);
    pointer-events: all;
    opacity: 0;
    transform: translateX(16px);
    transition: opacity var(--t-base), transform var(--t-base);
    line-height: 1.5;
    word-break: break-word;
}
.toast.is-visible { opacity: 1; transform: translateX(0); }

.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-text { flex: 1; }

.toast-success { background: var(--success-bg); color: #065f46; border-color: var(--success-border); }
.toast-error   { background: var(--danger-bg);  color: #9f1239; border-color: var(--danger-border); }
.toast-warning { background: var(--warning-bg); color: #78350f; border-color: var(--warning-border); }
.toast-info    { background: var(--info-bg);    color: #1e3a8a; border-color: var(--info-border); }

/* ── Loading State ──────────────────────────────────────────── */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    padding: var(--sp-8);
    color: var(--gray-500);
    font-size: var(--text-sm);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: var(--sp-5) 0;
}

/* ── Section Heading ─────────────────────────────────────────── */
.section-heading {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-500);
    margin: 0 0 var(--sp-3);
}

/* ── Low Stock Indicator ─────────────────────────────────────── */
.low-stock-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--danger);
    border-radius: 50%;
    margin-right: var(--sp-1);
}

.stock-ok { color: var(--success); font-weight: 500; }
.stock-low { color: var(--danger); font-weight: 600; }
.stock-zero { color: var(--danger); font-weight: 700; }

/* ── Cashier Layout ──────────────────────────────────────────── */
.cashier-shell {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--sp-4);
    height: 100%;
    min-height: 0;
}

.cashier-left, .cashier-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.cashier-search-bar {
    display: flex;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
    flex-shrink: 0;
}

.cashier-search-bar .form-control { flex: 1; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--sp-3);
    overflow-y: auto;
    flex: 1;
    padding-right: var(--sp-1);
    align-content: start;
}

.product-card {
    background: var(--gray-0);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    cursor: pointer;
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-height: 90px;
    position: relative;
}
.product-card:hover {
    border-color: var(--brand);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}
.product-card:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.product-card.out-of-stock { opacity: .5; cursor: not-allowed; }

.product-card-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
    flex: 1;
}

.product-card-price {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--brand);
}

.product-card-stock {
    font-size: var(--text-xs);
    color: var(--gray-400);
}

.product-card-thumb {
    width: 100%;
    height: 85px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-100);
    margin-bottom: var(--sp-1);
    border: 1px solid var(--gray-200);
}

.product-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-card-code {
    font-size: var(--text-xs);
    color: var(--gray-400);
    font-family: var(--font-mono);
}

/* Cart Panel */
.cart-panel {
    background: var(--gray-0);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    height: 100%;
}

.cart-header {
    padding: var(--sp-4) var(--sp-4);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cart-title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.cart-count {
    background: var(--brand);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 9999px;
    min-width: 22px;
    text-align: center;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-2);
}

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    color: var(--gray-400);
    text-align: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
}
.cart-empty svg { width: 32px; height: 32px; opacity: .4; }

.cart-item {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-2);
    border-radius: var(--radius);
    transition: background var(--t-fast);
    border-bottom: 1px solid var(--gray-100);
}
.cart-item:last-child { border-bottom: none; }
.cart-item:hover { background: var(--gray-50); }

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-price { font-size: var(--text-xs); color: var(--gray-500); margin-top: 2px; }

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex-shrink: 0;
}

.qty-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--gray-700);
    transition: background var(--t-fast);
    flex-shrink: 0;
}
.qty-btn:hover { background: var(--gray-200); }

.qty-input {
    width: 40px;
    text-align: center;
    padding: 2px 4px;
    font-size: var(--text-sm);
    font-weight: 600;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-0);
    color: var(--gray-900);
}
.qty-input:focus { outline: none; border-color: var(--brand); }

.cart-item-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    border-radius: var(--radius-sm);
    transition: color var(--t-fast), background var(--t-fast);
    flex-shrink: 0;
}
.cart-item-remove:hover { color: var(--danger); background: var(--danger-bg); }
.cart-item-remove svg { width: 14px; height: 14px; }

.cart-subtotal {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

/* Payment Section */
.payment-section {
    border-top: 1px solid var(--gray-200);
    padding: var(--sp-4);
    flex-shrink: 0;
    background: var(--gray-50);
}

.payment-total-card {
    background: #0f172a;
    color: #ffffff;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.payment-total-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    color: #94a3b8;
}

.payment-total-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: -.02em;
}

.payment-input-group {
    margin-bottom: 10px;
}

.payment-input-label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-600);
    margin-bottom: 4px;
    display: block;
}

.payment-input {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    text-align: right;
    border-width: 2px !important;
    padding: 8px 12px !important;
}
.payment-input:focus { border-color: var(--brand) !important; }

.quick-cash-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 6px;
}

.quick-cash-btn {
    padding: 6px 4px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--gray-700);
    background: var(--gray-0);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    transition: all var(--t-fast);
}
.quick-cash-btn:hover {
    background: var(--gray-200);
    color: var(--gray-900);
    border-color: var(--gray-400);
}
.quick-cash-exact {
    background: rgba(37, 99, 235, 0.08);
    color: var(--brand);
    border-color: rgba(37, 99, 235, 0.3);
}
.quick-cash-exact:hover {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.change-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--gray-0);
    border: 1px solid var(--gray-200);
    margin-bottom: 10px;
    transition: background var(--t-fast), border-color var(--t-fast);
}
.change-card.positive {
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.change-card.positive .change-label, .change-card.positive .change-value {
    color: #059669;
}
.change-card.negative {
    background: #fef2f2;
    border-color: #fecaca;
}
.change-card.negative .change-label, .change-card.negative .change-value {
    color: #dc2626;
}

.change-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--gray-500);
}
.change-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--gray-900);
}

.btn-checkout {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: var(--radius);
    background: #059669;
    color: #fff;
    border: none;
    cursor: pointer;
    letter-spacing: .03em;
    transition: all var(--t-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}
.btn-checkout:hover:not(:disabled) {
    background: #047857;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35);
}
.btn-checkout:disabled {
    background: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Receipt ─────────────────────────────────────────────────── */
.receipt-page {
    background: var(--gray-100);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--sp-8) var(--sp-4);
}

.receipt-container {
    background: white;
    width: 100%;
    max-width: 320px;
    padding: var(--sp-5);
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.6;
}

.receipt-store-name { font-size: 15px; font-weight: bold; text-align: center; }
.receipt-store-address { text-align: center; color: #555; }
.receipt-divider { border: none; border-top: 1px dashed #333; margin: 8px 0; }
.receipt-meta { font-size: 11px; }
.receipt-meta-row { display: flex; justify-content: space-between; }

.receipt-items-header {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 4px;
    font-weight: bold;
    font-size: 11px;
    border-bottom: 1px dashed #333;
    padding-bottom: 4px;
    margin-bottom: 4px;
}
.receipt-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 4px;
    font-size: 11px;
    margin-bottom: 2px;
}
.receipt-item-name { grid-column: 1 / -1; margin-bottom: 0; }
.receipt-total { display: flex; justify-content: space-between; font-weight: bold; margin-top: 4px; }
.receipt-payment-row { display: flex; justify-content: space-between; }
.receipt-change { display: flex; justify-content: space-between; font-weight: bold; }
.receipt-footer { text-align: center; margin-top: 12px; font-size: 11px; color: #555; }
.receipt-actions { text-align: center; margin-top: var(--sp-4); display: flex; gap: var(--sp-2); justify-content: center; }

/* ── Utility Classes ─────────────────────────────────────────── */
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-block { display: block; }
.d-none { display: none !important; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }

.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold   { font-weight: 700; }

.text-muted   { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-brand   { color: var(--brand); }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }

.w-full { width: 100%; }
.mono { font-family: var(--font-mono); }

/* ── Responsive ──────────────────────────────────────────────── */

/* ≤ 1024px — hide sidebar, show as overlay */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: var(--z-sidebar);
    }
    .sidebar.is-open { transform: translateX(0); }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.4);
        z-index: var(--z-overlay);
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--t-base), visibility var(--t-base);
    }
    .sidebar-overlay.is-open { opacity: 1; visibility: visible; }

    .topbar-toggle { display: flex; }
    .main-content { width: 100%; }
}

/* ≤ 768px */
@media (max-width: 768px) {
    :root { --sp-6: 1rem; }

    .content-area { padding: var(--sp-4); }
    .topbar { padding: 0 var(--sp-4); }

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

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

    .table-toolbar { flex-direction: column; align-items: stretch; }
    .table-toolbar-right { justify-content: flex-start; }
    .table-search input { width: 100%; }

    .cashier-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
        overflow: visible;
    }
    .cashier-left { min-height: 320px; }
    .cashier-right { height: auto; min-height: 440px; }

    .cart-panel { height: auto; }

    .form-row { flex-direction: column; }

    .modal { max-width: 100%; margin: 0 var(--sp-2); }
}

/* ≤ 480px */
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .product-grid { grid-template-columns: 1fr 1fr; }
    .receipt-container { max-width: 100%; }
}

/* ── Print Styles ────────────────────────────────────────────── */
@media print {
    .sidebar,
    .topbar,
    .content-area > .page-header,
    .receipt-actions,
    .alert,
    .toast-container,
    .modal-overlay,
    .sidebar-overlay,
    nav,
    header {
        display: none !important;
    }

    body {
        background: white;
        font-family: 'Courier New', Courier, monospace;
        font-size: 12px;
    }

    .app-shell {
        display: block;
        height: auto;
    }

    .main-content {
        display: block;
    }

    .content-area {
        padding: 0;
        overflow: visible;
    }

    .receipt-page {
        background: none;
        padding: 0;
        display: block;
    }

    .receipt-container {
        max-width: 80mm;
        margin: 0 auto;
        box-shadow: none;
        border: none;
    }

    a[href]::after { content: ''; }
    @page { margin: 10mm; }
}
