:root {
    /* Brand colors */
    --clr-green-400: #4ade80;
    --clr-green-500: #22c55e;
    --clr-green-600: #16a34a;
    --clr-green-700: #15803d;
    --clr-green-900: #14532d;

    /* Dark theme (default) */
    --clr-bg:         #0b0f0c;
    --clr-surface:    #111914;
    --clr-elevated:   #182117;
    --clr-border:     #1e2d1f;
    --clr-border-soft:#233226;

    --clr-text:       #e8f0e9;
    --clr-text-secondary: #8fa98f;
    --clr-text-muted: #4d664d;

    /* Spacing & radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Fonts */
    --font-heading: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;

    /* Transitions */
    --trans-fast: 0.15s ease;
    --trans-mid: 0.3s ease;
}

[data-theme="light"] {
    --clr-bg:         #f4f7f4;
    --clr-surface:    #ffffff;
    --clr-elevated:   #edf3ed;
    --clr-border:     #d1e4d1;
    --clr-border-soft:#e2eee2;

    --clr-text:       #141e14;
    --clr-text-secondary: #3d5c3d;
    --clr-text-muted: #7a9a7a;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--clr-bg); color: var(--clr-text); font-family: var(--font-body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--clr-bg); }
::-webkit-scrollbar-thumb { background: var(--clr-border-soft); border-radius: var(--radius-sm); }
::-webkit-scrollbar-thumb:hover { background: var(--clr-text-muted); }

/* Typography */
h1, h2, h3, h4, h5, h6, .font-heading { font-family: var(--font-heading); font-weight: 700; color: var(--clr-text); }
a { color: var(--clr-green-500); text-decoration: none; transition: color var(--trans-fast); }
a:hover { color: var(--clr-green-400); }
code { font-family: monospace; background: var(--clr-elevated); padding: 0.2rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.9em; }

/* Layout */
.dashboard { display: flex; min-height: 100vh; overflow: hidden; position: relative; }

/* Sidebar */
.sidebar { width: 240px; background: var(--clr-elevated); border-right: 1px solid var(--clr-border); display: flex; flex-direction: column; transition: width var(--trans-mid), transform var(--trans-mid); flex-shrink: 0; z-index: 40; }
.sidebar-header { height: 72px; padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--clr-border); }
.sidebar-logo { font-size: 1.5rem; color: var(--clr-green-500); white-space: nowrap; overflow: hidden; }
.sidebar-toggle { background: transparent; border: none; color: var(--clr-text-secondary); cursor: pointer; font-size: 1.2rem; }
.sidebar-nav { padding: 1.5rem 0; flex-grow: 1; overflow-y: auto; overflow-x: hidden; }
.nav-item { display: flex; align-items: center; padding: 0.75rem 1.5rem; color: var(--clr-text-secondary); transition: all var(--trans-fast); position: relative; white-space: nowrap; }
.nav-item i { width: 24px; font-size: 1.1rem; text-align: center; margin-right: 12px; flex-shrink: 0; }
.nav-item:hover { color: var(--clr-text); background: var(--clr-surface); }
.nav-item.active { color: var(--clr-green-500); background: rgba(34, 197, 94, 0.05); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--clr-green-500); }
.nav-divider { height: 1px; background: var(--clr-border); margin: 1rem 1.5rem; }
.sidebar-footer { padding: 1.5rem; border-top: 1px solid var(--clr-border); }
.theme-toggle { background: var(--clr-surface); border: 1px solid var(--clr-border); color: var(--clr-text); width: 100%; padding: 0.75rem; border-radius: var(--radius-sm); cursor: pointer; display: flex; justify-content: center; transition: all var(--trans-fast); }
.theme-toggle:hover { border-color: var(--clr-green-500); color: var(--clr-green-500); }

/* Sidebar Collapsed State */
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .sidebar-logo, .sidebar.collapsed .nav-item span { opacity: 0; display: none; }
.sidebar.collapsed .sidebar-header { padding: 0; justify-content: center; }
.sidebar.collapsed .nav-item { padding: 0.75rem; justify-content: center; }
.sidebar.collapsed .nav-item i { margin-right: 0; }
.sidebar.collapsed .nav-divider { margin: 1rem 0.75rem; }
.sidebar.collapsed .sidebar-footer { padding: 0.75rem; }
.sidebar.collapsed .theme-toggle { padding: 0.75rem 0.5rem; }

/* Sidebar Backdrop (Mobile) */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 30; opacity: 1; transition: opacity var(--trans-mid); }

/* Main Content */
.main-content { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; position: relative; height: 100vh; }
.main-content-inner { padding: 2rem; width: 100%; max-width: 1400px; margin: 0 auto; flex-grow: 1; }
.main-content.narrow .main-content-inner { max-width: 900px; }

/* Top Bar */
.topbar { height: 64px; padding: 0 2rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--clr-border); background: var(--clr-surface); flex-shrink: 0; }
.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.topbar-title { font-family: var(--font-heading); font-size: 1.25rem; font-weight: 700; color: var(--clr-text); }
.topbar-admin { font-size: 0.875rem; color: var(--clr-text-secondary); }
.mobile-menu-btn { display: none; background: transparent; border: 1px solid var(--clr-border); color: var(--clr-text-secondary); width: 38px; height: 38px; border-radius: var(--radius-sm); cursor: pointer; font-size: 1.1rem; align-items: center; justify-content: center; transition: all var(--trans-fast); flex-shrink: 0; }
.mobile-menu-btn:hover { border-color: var(--clr-green-500); color: var(--clr-green-500); }


/* Page Section */
.page-section { padding: 2rem; width: 100%; max-width: 1400px; margin: 0 auto; flex-grow: 1; }

/* Panel */
.panel { background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-md); padding: 1.5rem; margin-bottom: 2rem; }
.panel-title { font-size: 1.125rem; margin-bottom: 1rem; }

/* Page Header */
.page-header { margin-bottom: 2rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.page-title { font-size: 2rem; margin: 0; line-height: 1.2; }
.header-actions { display: flex; gap: 0.75rem; }

/* Quick Actions */
.quick-actions { display: flex; gap: 1rem; margin-bottom: 2rem; overflow-x: auto; padding-bottom: 0.5rem; }
.quick-actions-panel { margin-bottom: 2rem; }
.quick-actions-grid { display: flex; gap: 1rem; flex-wrap: wrap; }
.quick-action-btn { background: var(--clr-surface); border: 1px solid var(--clr-border); color: var(--clr-text); padding: 0.75rem 1.25rem; border-radius: var(--radius-md); display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; transition: border-color var(--trans-fast); }
.quick-action-btn:hover { border-color: var(--clr-green-500); color: var(--clr-green-500); }

/* KPI Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.kpi-card { background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-md); padding: 1.5rem; display: flex; align-items: flex-start; gap: 1rem; transition: transform var(--trans-fast), box-shadow var(--trans-fast); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); border-color: var(--clr-border-soft); }
.kpi-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); background: rgba(34, 197, 94, 0.1); color: var(--clr-green-500); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.kpi-content { flex-grow: 1; }
.kpi-label { color: var(--clr-text-secondary); font-size: 0.875rem; margin-bottom: 0.25rem; font-weight: 500; }
.kpi-number, .kpi-value { font-size: 1.75rem; font-family: var(--font-heading); font-weight: 700; color: var(--clr-text); line-height: 1; margin-bottom: 0.5rem; }
.kpi-trend { font-size: 0.875rem; display: flex; align-items: center; gap: 0.25rem; }
.trend-up { color: var(--clr-green-500); }
.trend-down { color: #ef4444; }

/* Forms */
.form-card, .form-panel { background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-md); padding: 2rem; margin-bottom: 2rem; }
.form-card-title { font-size: 1.25rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--clr-border); }
.dashboard-form { width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.form-group-full { grid-column: 1 / -1; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; color: var(--clr-text); font-weight: 500; margin-bottom: 0.5rem; font-size: 0.95rem; }
.form-label { display: block; color: var(--clr-text); font-weight: 500; margin-bottom: 0.5rem; font-size: 0.95rem; }
.form-control,
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea { width: 100%; background: var(--clr-bg); border: 1px solid var(--clr-border); color: var(--clr-text); padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 1rem; transition: border-color var(--trans-fast), box-shadow var(--trans-fast); }
.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--clr-green-500); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1); }
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238fa98f'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1rem; padding-right: 2.5rem; }
.form-text { display: block; margin-top: 0.5rem; font-size: 0.85rem; color: var(--clr-text-secondary); }
.form-actions { display: flex; justify-content: flex-end; gap: 1rem; padding-top: 1.5rem; border-top: 1px solid var(--clr-border); position: sticky; bottom: 0; background: var(--clr-surface); padding-bottom: 1rem; z-index: 10; }

/* Upload Zone */
.upload-zone { border: 2px dashed var(--clr-border-soft); border-radius: var(--radius-md); padding: 2rem; text-align: center; cursor: pointer; transition: all var(--trans-fast); background: var(--clr-bg); position: relative; overflow: hidden; }
.upload-zone:hover, .upload-zone.dragover, .upload-zone.drag-over { border-color: var(--clr-green-500); background: rgba(34, 197, 94, 0.02); }
.upload-icon { font-size: 2.5rem; color: var(--clr-text-muted); margin-bottom: 1rem; }
.upload-text { color: var(--clr-text); margin-bottom: 0.5rem; font-weight: 500; }
.upload-subtext { color: var(--clr-text-secondary); font-size: 0.875rem; }
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-preview { margin-top: 1rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.preview-item { width: 80px; height: 80px; border-radius: var(--radius-sm); border: 1px solid var(--clr-border); object-fit: cover; }

/* Dropzone (form file upload) */
.dropzone { border: 2px dashed var(--clr-border-soft); border-radius: var(--radius-md); padding: 2rem; text-align: center; cursor: pointer; transition: all var(--trans-fast); background: var(--clr-bg); position: relative; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--clr-green-500); background: rgba(34, 197, 94, 0.02); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone-text { color: var(--clr-text-secondary); font-size: 0.875rem; margin: 0; }

/* Image Preview */
.image-preview-wrap { margin-top: 1rem; }
.image-preview { max-width: 200px; max-height: 150px; border-radius: var(--radius-sm); border: 1px solid var(--clr-border); object-fit: cover; }

/* Input with Preview (icon preview) */
.input-with-preview { display: flex; align-items: center; gap: 0.75rem; }
.input-with-preview input { flex-grow: 1; }
.icon-preview { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: var(--clr-bg); border: 1px solid var(--clr-border); border-radius: var(--radius-sm); font-size: 1.25rem; color: var(--clr-text); flex-shrink: 0; }

/* Order Controls */
.order-controls { display: flex; gap: 0.25rem; }

/* Table Utility Classes */
.table-panel { padding: 0; }
.table-panel .table-wrapper { margin: 0; }
.table-wrapper { width: 100%; overflow-x: auto; }
.table-loading, .table-error { text-align: center; padding: 2rem; color: var(--clr-text-secondary); }
.table-error { color: #ef4444; }
.thumb-48 { width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; background: var(--clr-elevated); border: 1px solid var(--clr-border); }
.text-muted { color: var(--clr-text-muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border-radius: var(--radius-sm); font-family: var(--font-body); font-weight: 500; font-size: 1rem; cursor: pointer; border: 1px solid transparent; transition: all var(--trans-fast); text-decoration: none; line-height: 1; white-space: nowrap; }
.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--clr-green-600); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--clr-green-500); }
.btn-secondary { background: transparent; border-color: var(--clr-border); color: var(--clr-text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--clr-text-secondary); color: var(--clr-text); background: var(--clr-elevated); }
.btn-danger { background: transparent; border-color: #ef4444; color: #ef4444; }
.btn-danger:hover:not(:disabled) { background: #ef4444; color: white; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid transparent; color: var(--clr-text-secondary); transition: all var(--trans-fast); cursor: pointer; }
.btn-icon:hover { background: var(--clr-elevated); color: var(--clr-text); }
.btn-icon.danger:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

/* Data Tables */
.data-table-wrapper { width: 100%; overflow-x: auto; background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-md); margin-bottom: 2rem; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--clr-border); white-space: nowrap; }
.data-table th { background: var(--clr-elevated); color: var(--clr-text-secondary); font-weight: 500; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--clr-border); }
.data-table tbody tr { transition: background var(--trans-fast); }
.data-table tbody tr:hover { background: var(--clr-bg); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-thumbnail { width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; background: var(--clr-elevated); border: 1px solid var(--clr-border); }
.table-actions { display: flex; gap: 0.25rem; }
.badge { padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; display: inline-block; }
.badge-success { background: rgba(34, 197, 94, 0.1); color: var(--clr-green-500); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 2rem; }
.page-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--clr-border); background: var(--clr-surface); color: var(--clr-text); font-weight: 500; cursor: pointer; transition: all var(--trans-fast); text-decoration: none; }
.page-btn:hover:not(:disabled) { border-color: var(--clr-green-500); color: var(--clr-green-500); }
.page-btn.active { background: var(--clr-green-600); border-color: var(--clr-green-600); color: white; }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Empty States */
.empty-state { padding: 4rem 2rem; text-align: center; background: var(--clr-surface); border: 1px dashed var(--clr-border-soft); border-radius: var(--radius-md); margin-bottom: 2rem; }
.empty-state-icon { font-size: 3rem; color: var(--clr-text-muted); margin-bottom: 1rem; }
.empty-state-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--clr-text); }
.empty-state-text { color: var(--clr-text-secondary); margin-bottom: 1.5rem; max-width: 400px; margin-left: auto; margin-right: auto; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; visibility: hidden; transition: all var(--trans-mid); }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal { background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-lg); width: 100%; max-width: 500px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4); transform: translateY(20px) scale(0.95); transition: transform var(--trans-mid); display: flex; flex-direction: column; max-height: 90vh; }
.modal-overlay.show .modal { transform: translateY(0) scale(1); }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--clr-border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.25rem; margin: 0; }
.modal-close { background: transparent; border: none; color: var(--clr-text-secondary); cursor: pointer; padding: 0.5rem; margin: -0.5rem; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; transition: all var(--trans-fast); }
.modal-close:hover { color: var(--clr-text); background: var(--clr-elevated); }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer { padding: 1.5rem; border-top: 1px solid var(--clr-border); display: flex; justify-content: flex-end; gap: 1rem; }

/* Toast Notifications */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 200; display: flex; flex-direction: column; gap: 1rem; pointer-events: none; }
.toast { background: var(--clr-elevated); border: 1px solid var(--clr-border); border-radius: var(--radius-md); padding: 1rem 1.5rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); display: flex; align-items: flex-start; gap: 1rem; width: 320px; max-width: calc(100vw - 4rem); transform: translateX(120%); transition: transform var(--trans-mid) cubic-bezier(0.175, 0.885, 0.32, 1.275); pointer-events: auto; position: relative; overflow: hidden; }
.toast.show { transform: translateX(0); }
.toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--clr-border); }
.toast-success::before { background: var(--clr-green-500); }
.toast-error::before { background: #ef4444; }
.toast-info::before { background: #3b82f6; }
.toast-icon { font-size: 1.25rem; margin-top: 0.125rem; }
.toast-success .toast-icon { color: var(--clr-green-500); }
.toast-error .toast-icon { color: #ef4444; }
.toast-info .toast-icon { color: #3b82f6; }
.toast-content { flex-grow: 1; }
.toast-title { font-weight: 600; color: var(--clr-text); margin-bottom: 0.25rem; font-size: 0.95rem; }
.toast-message { color: var(--clr-text-secondary); font-size: 0.875rem; line-height: 1.4; }
.toast-close { background: transparent; border: none; color: var(--clr-text-muted); cursor: pointer; padding: 0.25rem; transition: color var(--trans-fast); }
.toast-close:hover { color: var(--clr-text); }

/* Responsive Media Queries */
@media (max-width: 1024px) {
    .sidebar { position: fixed; transform: translateX(-100%); bottom: 0; top: 0; }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
    .main-content { margin-left: 0; }
    .form-row, .form-grid { grid-template-columns: 1fr; gap: 1rem; }
    .mobile-menu-btn { display: flex; }
}

@media (max-width: 768px) {
    .main-content-inner { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; margin-bottom: 1.5rem; }
    .kpi-grid { grid-template-columns: 1fr; }
    .form-card { padding: 1.5rem; }
    .btn { width: 100%; justify-content: center; }
    .header-actions { width: 100%; }
    .toast-container { bottom: 1rem; right: 1rem; left: 1rem; align-items: center; }
    .toast { width: 100%; max-width: none; }
}
