:root {
    --primary: #25D366;
    --primary-hover: #1EBE5A;
    --primary-dark: #128C7E;
    --primary-soft: #E9FDF1;
    --secondary: #0B1F17;

    --success: #12B76A;
    --warning: #F79009;
    --danger: #F04438;
    --info: #2E90FA;

    --module-stock: #12B76A;
    --module-purchase: #2E90FA;
    --module-hr: #7A5AF8;
    --module-alert: #F79009;
    --module-anomaly: #F04438;
    --module-kitchen: #06AED4;
    --module-finance: #6172F3;
    --module-event: #EE46BC;
    --module-wait: #F5C518;

    --bg: #F4F7F5;
    --bg-elevated: #F8FBFA;
    --surface: #FFFFFF;
    --surface-secondary: #F3F6F4;
    --surface-tertiary: #E8EEEA;

    --text: #12241C;
    --text-secondary: #5B6B63;
    --text-tertiary: #8A9891;
    --border: rgba(18, 36, 28, 0.08);
    --border-strong: rgba(18, 36, 28, 0.14);

    --radius-xs: 10px;
    --radius-sm: 12px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 22px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 20, 0.04), 0 1px 1px rgba(16, 24, 20, 0.03);
    --shadow-md: 0 8px 24px rgba(16, 24, 20, 0.06), 0 2px 6px rgba(16, 24, 20, 0.04);
    --shadow-lg: 0 24px 48px rgba(16, 24, 20, 0.10);

    --sidebar-width: 272px;
    --sidebar-collapsed: 84px;
    --header-height: 64px;
    --bottom-nav-height: 72px;

    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --focus: 0 0 0 4px rgba(37, 211, 102, 0.28);
    --ease: 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
    --bg: #0C1410;
    --bg-elevated: #101A15;
    --surface: #15201B;
    --surface-secondary: #1C2A24;
    --surface-tertiary: #24352D;
    --text: #EEF6F1;
    --text-secondary: #A7B8B0;
    --text-tertiary: #7E9088;
    --border: rgba(238, 246, 241, 0.08);
    --border-strong: rgba(238, 246, 241, 0.14);
    --secondary: #D7EDE3;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.35);
    --primary-soft: rgba(37, 211, 102, 0.14);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    color-scheme: light dark;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 100;
    background: var(--primary);
    color: #fff;
    padding: 0.55rem 0.9rem;
    border-radius: 10px;
    font-weight: 650;
}
.skip-link:focus {
    top: 0.75rem;
    outline: none;
    box-shadow: var(--focus);
}

.skeleton {
    display: block;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--surface-secondary) 0%, var(--surface-tertiary) 50%, var(--surface-secondary) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.1s ease-in-out infinite;
    min-height: 12px;
}
.skeleton-lg { min-height: 72px; }
@keyframes skeleton-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.sheet {
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    padding: 1.1rem 1.15rem calc(1.1rem + env(safe-area-inset-bottom));
}

.command-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-right: 0.5rem;
}
.command-head input { flex: 1; }

a:focus-visible,
.nav-link:focus-visible,
.command-item:focus-visible,
select:focus-visible {
    outline: none;
    box-shadow: var(--focus);
    border-radius: 10px;
}

table.data thead th { position: sticky; top: 0; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .btn:hover { transform: none; }
}

@media (max-width: 720px) {
    .toast-stack {
        right: 0.75rem;
        left: 0.75rem;
        bottom: calc(var(--bottom-nav-height) + 0.75rem);
    }
    .toast { max-width: none; }
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    letter-spacing: -0.011em;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3, h4 {
    margin: 0;
    letter-spacing: -0.03em;
    font-weight: 640;
    color: var(--text);
}

h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.25rem; line-height: 1.3; }
h3 { font-size: 1.05rem; line-height: 1.35; }

p { margin: 0; }

label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.body-text { font-size: 0.9375rem; color: var(--text); }
.caption { font-size: 0.75rem; color: var(--text-tertiary); }

.icon {
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0.7rem 1.05rem;
    font-weight: 620;
    letter-spacing: -0.01em;
    transition: transform var(--ease), background var(--ease), box-shadow var(--ease);
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px rgba(37, 211, 102, 0.28);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-secondary); color: var(--text); }

.btn-danger {
    background: #FEE4E2;
    color: #B42318;
}

.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.8125rem; border-radius: 10px; }
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.chip-success { background: #E7F8EF; color: #027A48; }
.chip-warning { background: #FEF4E6; color: #B54708; }
.chip-danger { background: #FEE4E2; color: #B42318; }
.chip-info { background: #E6F1FE; color: #175CD3; }
.chip-muted { background: var(--surface-secondary); color: var(--text-secondary); }
.chip-violet { background: #F4EBFF; color: #6941C6; }
.chip-kit { background: #E0F7FA; color: #0E7490; }

.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-warning:hover { filter: brightness(0.95); color: #fff; }
.btn-kit {
    background: var(--module-kitchen);
    color: #fff;
}
.btn-kit:hover { filter: brightness(0.95); color: #fff; }

[data-theme="dark"] .chip-success { background: rgba(18,183,106,.16); color: #6CE9A6; }
[data-theme="dark"] .chip-warning { background: rgba(247,144,9,.16); color: #FEC84B; }
[data-theme="dark"] .chip-danger { background: rgba(240,68,56,.16); color: #FDA29B; }
[data-theme="dark"] .chip-info { background: rgba(46,144,250,.16); color: #84CAFF; }
[data-theme="dark"] .chip-violet { background: rgba(122,90,248,.16); color: #D6BBFB; }
[data-theme="dark"] .chip-kit { background: rgba(6,174,212,.18); color: #67E8F9; }
[data-theme="dark"] .btn-danger { background: rgba(240,68,56,.16); color: #FDA29B; }
[data-theme="dark"] .btn-warning { background: rgba(247,144,9,.85); color: #fff; }
[data-theme="dark"] .btn-kit { background: rgba(6,174,212,.9); color: #fff; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.field {
    width: 100%;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    outline: none;
    transition: border var(--ease), box-shadow var(--ease);
}

.field:focus {
    border-color: var(--primary);
    box-shadow: var(--focus);
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state .icon-wrap {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 20px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    display: grid;
    place-items: center;
}

.table-wrap {
    overflow: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

table.data th,
table.data td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

table.data th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    font-weight: 700;
    background: var(--surface-secondary);
}

.toast-stack {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toast {
    min-width: 260px;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    animation: toast-in 280ms var(--ease);
}

.toast.success { border-color: rgba(18, 183, 106, 0.3); }
.toast.warning { border-color: rgba(247, 144, 9, 0.35); }
.toast.danger { border-color: rgba(240, 68, 56, 0.35); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 720px) {
    .hide-mobile { display: none !important; }
    table.data { min-width: 0; }
    .table-as-cards thead { display: none; }
    .table-as-cards,
    .table-as-cards tbody,
    .table-as-cards tr,
    .table-as-cards td {
        display: block;
        width: 100%;
    }
    .table-as-cards tr {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border);
    }
    .table-as-cards td {
        padding: 0.25rem 1rem;
        border: 0;
    }
    .table-as-cards td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.7rem;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 0.15rem;
    }
}
