/* ====== Root Variables ====== */
:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --secondary: #2c3e50;
    --secondary-dark: #1a252f;
    --accent: #e67e22;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --white: #fff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --sidebar-width: 240px;
    --font: 'Cairo', sans-serif;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ====== Login Screen ====== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 20px;
}

.login-container {
    background: var(--white);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo-img {
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
    object-fit: contain;
    border-radius: 12px;
}

.login-logo i {
    font-size: 52px;
    color: var(--primary);
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--secondary);
}

.login-logo p {
    color: var(--gray-600);
    font-size: 15px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
}

.form-group label i {
    margin-left: 6px;
    color: var(--primary);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-300);
    border-radius: 10px;
    font-size: 15px;
    font-family: var(--font);
    transition: var(--transition);
    background: var(--gray-100);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.form-hint {
    background: var(--gray-100);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.error-msg {
    background: #fdecea;
    color: var(--danger);
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
}

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #219a52; }

.btn-warning { background: var(--warning); color: var(--white); }
.btn-warning:hover { background: #e08e0b; }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: var(--primary-dark); }

.btn-info { background: var(--info); color: var(--white); }
.btn-info:hover { background: #2980b9; }

.btn-outline {
    background: transparent;
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-200);
    color: var(--gray-700);
    font-size: 14px;
}

.btn-icon:hover { background: var(--gray-300); }

/* ====== App Layout ====== */
.app {
    display: flex;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ====== Sidebar Toggle Button ====== */
.sidebar-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--secondary);
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--primary);
    transform: scale(1.05);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* ====== Sidebar ====== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--secondary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.sidebar-open .sidebar {
    transform: translateX(0);
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #fff;
    padding: 2px;
    object-fit: contain;
}

.sidebar-header i {
    font-size: 28px;
    color: var(--primary);
}

.sidebar-brand {
    font-size: 24px;
    font-weight: 800;
}

.nav-menu {
    list-style: none;
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 16px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
    border-radius: 10px;
    margin: 2px 10px;
}

.nav-link:hover { background: rgba(255,255,255,0.08); color: var(--white); }

.nav-link.active {
    background: var(--primary);
    color: var(--white);
}

.nav-link i { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info > i { font-size: 28px; color: var(--primary); }

.user-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
}

.user-role {
    display: block;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.btn-logout {
    background: rgba(231, 76, 60, 0.2);
    color: var(--primary);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}

.btn-logout:hover { background: var(--primary); color: var(--white); }

.btn-printer-settings {
    background: rgba(52, 152, 219, 0.2);
    color: var(--info);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}

.btn-printer-settings:hover { background: var(--info); color: var(--white); }

.btn-install-app {
    background: rgba(40, 167, 69, 0.2);
    color: var(--success);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
    animation: pulse-install 2s infinite;
}

.btn-install-app:hover { background: var(--success); color: var(--white); }

@keyframes pulse-install {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ====== Printer Settings ====== */
.printer-settings-form .form-divider {
    border-top: 1px solid var(--gray-200);
    margin: 16px 0;
}

.printer-settings-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.printer-settings-form .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.bt-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--gray-100);
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--gray-600);
}

.bt-status i { font-size: 20px; }

.bt-status.connected {
    background: #e8f8f0;
    color: var(--success);
}

/* ====== Main Content ====== */
.main-content {
    flex: 1;
    margin-right: 0;
    padding: 24px;
    padding-top: 70px;
    min-height: 100vh;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--secondary);
}

/* ====== Stats Grid ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-blue .stat-icon { background: #e8f4fd; color: var(--info); }
.stat-green .stat-icon { background: #e8f8f0; color: var(--success); }
.stat-orange .stat-icon { background: #fef5e7; color: var(--accent); }
.stat-red .stat-icon { background: #fdecea; color: var(--danger); }

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--secondary);
}

.stat-label {
    font-size: 13px;
    color: var(--gray-600);
    font-weight: 600;
}

/* ====== Cards ====== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--secondary);
}

.card-body {
    padding: 20px;
}

/* ====== Tables Grid ====== */
.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.table-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    border: 3px solid transparent;
    position: relative;
}

.table-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.table-card.available { border-color: var(--success); }
.table-card.occupied { border-color: var(--danger); }
.table-card.reserved { border-color: var(--warning); }
.table-card.maintenance { border-color: var(--gray-400); }

.table-card .table-number {
    font-size: 36px;
    font-weight: 800;
    color: var(--secondary);
}

.table-card .table-info {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: 4px;
}

.table-card .table-seats {
    margin-top: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.table-card .table-seats i { margin-left: 4px; }

.table-status-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 12px;
}

.status-available { background: #e8f8f0; color: var(--success); }
.status-occupied { background: #fdecea; color: var(--danger); }
.status-reserved { background: #fef5e7; color: var(--warning); }
.status-maintenance { background: var(--gray-200); color: var(--gray-600); }

.table-filters, .order-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 18px;
    border: 2px solid var(--gray-300);
    background: var(--white);
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    font-size: 13px;
    transition: var(--transition);
}

.filter-btn:hover { border-color: var(--primary); color: var(--primary); }

.filter-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ====== New Order ====== */
.new-order-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    height: calc(100vh - 120px);
}

.menu-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.categories-bar {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: 2px solid var(--gray-300);
    background: var(--white);
    border-radius: 25px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    white-space: nowrap;
}

.category-btn:hover { border-color: var(--primary); color: var(--primary); }

.category-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.category-btn .emoji { font-size: 18px; }

.menu-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding: 4px;
    flex: 1;
}

.menu-item-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
}

.menu-item-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.menu-item-card.unavailable {
    opacity: 0.5;
    pointer-events: none;
}

.menu-item-emoji {
    font-size: 36px;
    text-align: center;
    margin-bottom: 8px;
}

.menu-item-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--secondary);
    text-align: center;
}

.menu-item-price {
    font-weight: 800;
    font-size: 16px;
    color: var(--primary);
    text-align: center;
    margin-top: 6px;
}

.menu-item-time {
    font-size: 12px;
    color: var(--gray-500);
    text-align: center;
    margin-top: 4px;
}

.menu-item-time i {
    margin-left: 4px;
}

/* Cart */
.cart-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--secondary);
    color: var(--white);
}

.cart-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.cart-table-select {
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-table-select label { font-weight: 700; font-size: 14px; white-space: nowrap; }

.cart-table-select select {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 14px;
}

.cart-customer {
    padding: 8px 20px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--gray-200);
}

.cart-customer input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 13px;
}

.cart-customer input:focus {
    border-color: var(--primary);
    outline: none;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px 20px;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.cart-item-info { flex: 1; }

.cart-item-name { font-weight: 600; font-size: 14px; }

.cart-item-price { font-size: 13px; color: var(--primary); font-weight: 700; }

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cart-item-qty button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--gray-300);
    background: var(--gray-100);
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: var(--transition);
}

.cart-item-qty button:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }

.cart-item-qty span { font-weight: 700; min-width: 24px; text-align: center; }

.cart-item-notes {
    width: 100%;
    margin-top: 4px;
}

.cart-item-notes input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 12px;
    color: var(--gray-600);
}

.cart-item-notes input:focus {
    border-color: var(--primary);
    outline: none;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}

.cart-totals {
    padding: 12px 20px;
    border-top: 2px solid var(--gray-200);
    background: var(--gray-50);
}

.cart-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
    color: var(--gray-700);
}

.cart-row.total {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    padding-top: 8px;
    border-top: 1px solid var(--gray-300);
    margin-top: 4px;
}

.cart-notes {
    padding: 0 20px 12px;
}

.cart-notes textarea {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 13px;
    resize: none;
    height: 50px;
}

.cart-notes textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.cart-section > .btn {
    margin: 0 20px 16px;
    width: calc(100% - 40px);
}

.cart-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.cart-empty i {
    font-size: 48px;
    margin-bottom: 12px;
    color: var(--gray-300);
}

.cart-empty p {
    font-size: 14px;
}

/* ====== Orders ====== */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    border-right: 5px solid transparent;
}

.order-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.order-card.order-pending { border-right-color: var(--warning); }
.order-card.order-preparing { border-right-color: var(--info); }
.order-card.order-ready { border-right-color: var(--success); }
.order-card.order-served { border-right-color: #9b59b6; }
.order-card.order-completed { border-right-color: var(--gray-400); }
.order-card.order-cancelled { border-right-color: var(--danger); }

.order-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.order-number {
    font-weight: 800;
    font-size: 16px;
    color: var(--secondary);
}

.order-status-badge {
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge-pending { background: #fef5e7; color: var(--warning); }
.badge-preparing { background: #e8f4fd; color: var(--info); }
.badge-ready { background: #e8f8f0; color: var(--success); }
.badge-served { background: #f0e6f6; color: #9b59b6; }
.badge-completed { background: var(--gray-200); color: var(--gray-600); }
.badge-cancelled { background: #fdecea; color: var(--danger); }

.order-card-info {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: var(--gray-600);
    flex-wrap: wrap;
}

.order-card-info span i { margin-left: 4px; color: var(--gray-400); }

.order-card-total {
    font-weight: 800;
    color: var(--primary);
    font-size: 15px;
}

/* ====== Kitchen Grid ====== */
.kitchen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.kitchen-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.kitchen-card-header {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.kitchen-card.kc-pending .kitchen-card-header { background: var(--warning); color: var(--white); }
.kitchen-card.kc-preparing .kitchen-card-header { background: var(--info); color: var(--white); }
.kitchen-card.kc-ready .kitchen-card-header { background: var(--success); color: var(--white); }

.kitchen-card-header .table-num { font-size: 18px; font-weight: 800; }
.kitchen-card-header .time-elapsed {
    font-size: 13px;
    background: rgba(255,255,255,0.3);
    padding: 2px 10px;
    border-radius: 12px;
}

.kitchen-card-items { padding: 12px 18px; }

.kitchen-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.kitchen-item:last-child { border-bottom: none; }

.kitchen-item-info {
    flex: 1;
}

.kitchen-item-name { font-weight: 600; font-size: 14px; }
.kitchen-item-notes { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.kitchen-item-qty {
    font-weight: 800;
    font-size: 16px;
    background: var(--gray-100);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.kitchen-item-status {
    margin-right: 8px;
}

.kitchen-item-status button {
    padding: 4px 12px;
    border-radius: 6px;
    border: none;
    font-family: var(--font);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.kitchen-card-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ====== Menu Management ====== */
.manage-menu-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Hierarchy tree styles */
.menu-tree-group {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 4px;
}

.menu-tree-header {
    padding: 14px 20px;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.menu-tree-header:hover { background: var(--gray-50); }

.menu-tree-header .tree-toggle {
    transition: transform 0.2s;
    font-size: 12px;
    color: var(--gray-400);
    margin-left: 10px;
}

.menu-tree-header.collapsed .tree-toggle {
    transform: rotate(-90deg);
}

.menu-tree-header .tree-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-tree-header .tree-actions {
    display: flex;
    gap: 4px;
}

.menu-tree-header .tree-count {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 400;
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Level 1: Main Group */
.tree-level-1 > .menu-tree-header {
    background: var(--primary);
    color: var(--white);
    font-size: 17px;
    padding: 16px 20px;
}

.tree-level-1 > .menu-tree-header:hover { background: var(--primary-dark); }
.tree-level-1 > .menu-tree-header .tree-count { background: rgba(255,255,255,0.2); color: var(--white); }
.tree-level-1 > .menu-tree-header .tree-toggle { color: rgba(255,255,255,0.7); }
.tree-level-1 > .menu-tree-header .btn-icon { color: rgba(255,255,255,0.8); }
.tree-level-1 > .menu-tree-header .btn-icon:hover { color: var(--white); background: rgba(255,255,255,0.15); }

/* Level 2: Category */
.tree-level-2 {
    border-right: 3px solid var(--primary-light);
    margin: 0 12px 4px;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--gray-50);
}

.tree-level-2 > .menu-tree-header {
    background: transparent;
    font-size: 15px;
    padding: 12px 16px;
    color: var(--primary);
}

.tree-level-2 > .menu-tree-header:hover { background: var(--gray-100); }

/* Level 3: Sub-category */
.tree-level-3 {
    border-right: 3px solid var(--warning);
    margin: 0 12px 4px;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--white);
}

.tree-level-3 > .menu-tree-header {
    font-size: 14px;
    padding: 10px 14px;
    color: var(--gray-700);
}

.menu-tree-body {
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.menu-tree-body.collapsed {
    max-height: 0 !important;
}

.page-title-actions {
    display: flex;
    gap: 8px;
}

.manage-menu-category {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.manage-menu-category-header {
    padding: 14px 20px;
    font-weight: 700;
    font-size: 16px;
    background: var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.manage-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
    gap: 16px;
}

.manage-menu-item:last-child { border-bottom: none; }

.manage-item-info { flex: 1; }
.manage-item-name { font-weight: 600; }
.manage-item-desc { font-size: 13px; color: var(--gray-500); }

.manage-item-price {
    font-weight: 800;
    color: var(--primary);
    font-size: 16px;
    min-width: 80px;
    text-align: center;
}

.manage-item-actions {
    display: flex;
    gap: 6px;
}

/* Toggle switch for availability */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--gray-300);
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--white);
    top: 3px;
    right: 3px;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(-20px); }

/* ====== Users Table ====== */
.users-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.users-table th, .users-table td {
    padding: 14px 18px;
    text-align: right;
    font-size: 14px;
}

.users-table th {
    background: var(--secondary);
    color: var(--white);
    font-weight: 700;
}

.users-table tr:nth-child(even) { background: var(--gray-100); }
.users-table tr:hover { background: var(--gray-200); }

.role-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.role-admin { background: #fdecea; color: var(--danger); }
.role-waiter { background: #e8f4fd; color: var(--info); }
.role-kitchen { background: #fef5e7; color: var(--warning); }
.role-cashier { background: #e8f8f0; color: var(--success); }

/* ====== Order Detail ====== */
.order-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.order-detail-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.order-detail-card.full-width {
    grid-column: 1 / -1;
}

.order-detail-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gray-200);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.detail-row .label { color: var(--gray-600); }
.detail-row .value { font-weight: 700; }

.detail-items-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-items-table th, .detail-items-table td {
    padding: 10px 12px;
    text-align: right;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
}

.detail-items-table th {
    background: var(--gray-100);
    font-weight: 700;
    font-size: 13px;
    color: var(--gray-700);
}

.detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* ====== Dashboard Active Orders ====== */
.dashboard-order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

.dashboard-order-item:last-child { border-bottom: none; }

.dashboard-order-num { font-weight: 700; font-size: 14px; }
.dashboard-order-table { font-size: 13px; color: var(--gray-600); }

/* ====== Modal ====== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 18px; font-weight: 700; }

.close-btn {
    background: var(--gray-200);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}

.close-btn:hover { background: var(--danger); color: var(--white); }

.modal-body { padding: 24px; }

.modal-body .form-group { margin-bottom: 16px; }

/* ====== Toast ====== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    color: var(--white);
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }

@keyframes toastIn {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ====== Responsive ====== */
@media (max-width: 1024px) {
    .new-order-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .cart-section { max-height: 50vh; }
    .order-detail { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .main-content { padding: 16px; padding-top: 70px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .tables-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 22px; }
    .menu-items-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .kitchen-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .tables-grid { grid-template-columns: 1fr 1fr; }
    .page-title { flex-direction: column; align-items: flex-start; }
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ====== Empty State ====== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 56px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 16px;
    font-weight: 600;
}

/* ====== Receipt ====== */
.receipt {
    max-width: 340px;
    margin: 0 auto;
    font-size: 13px;
}

.receipt-header {
    text-align: center;
    border-bottom: 2px dashed var(--gray-300);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.receipt-header h2 { font-size: 20px; }

.receipt-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.receipt-divider {
    border-top: 1px dashed var(--gray-300);
    margin: 8px 0;
}

.receipt-total {
    font-weight: 800;
    font-size: 16px;
}

.receipt-item-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

/* ====== Admin Dashboard ====== */
.admin-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.admin-stats-grid {
    margin-bottom: 24px;
}

.admin-period-selector {
    display: flex;
    gap: 6px;
}

.branch-filter-select {
    padding: 6px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 600;
    background: #fff;
    color: var(--dark);
    cursor: pointer;
    min-width: 140px;
}
.branch-filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* -- Bar Chart (Pure CSS) -- */
.chart-container {
    min-height: 240px;
    position: relative;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 220px;
    padding: 0 4px 28px;
    position: relative;
    border-bottom: 2px solid var(--gray-200);
}

.bar-chart .bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 0;
}

.bar-chart .bar {
    width: 100%;
    max-width: 36px;
    border-radius: 6px 6px 0 0;
    transition: height 0.6s ease;
    position: relative;
    cursor: pointer;
    min-height: 2px;
}

.bar-chart .bar:hover {
    filter: brightness(1.1);
}

.bar-chart .bar-value {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--gray-700);
    display: none;
}

.bar-chart .bar:hover .bar-value {
    display: block;
}

.bar-chart .bar-label {
    position: absolute;
    bottom: -24px;
    font-size: 10px;
    color: var(--gray-500);
    white-space: nowrap;
}

/* -- Donut/Pie Chart (Pure CSS) -- */
.donut-chart-wrap {
    display: flex;
    align-items: center;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.donut-chart {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.donut-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 90px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: var(--secondary);
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

.donut-center small {
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 600;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.donut-legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

.donut-legend-value {
    margin-right: auto;
    margin-left: 8px;
    font-weight: 700;
    color: var(--secondary);
}

/* -- Horizontal Bars -- */
.h-bar-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.h-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.h-bar-rank {
    width: 28px;
    height: 28px;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    color: var(--gray-600);
    flex-shrink: 0;
}

.h-bar-rank.top-1 { background: #fef5e7; color: #d4a017; }
.h-bar-rank.top-2 { background: #edf2f7; color: #718096; }
.h-bar-rank.top-3 { background: #fef0e7; color: #c05621; }

.h-bar-info {
    flex: 1;
    min-width: 0;
}

.h-bar-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.h-bar-meta {
    font-size: 12px;
    color: var(--gray-500);
}

.h-bar-track {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
    min-width: 60px;
}

.h-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s ease;
}

.h-bar-value {
    font-weight: 700;
    font-size: 14px;
    color: var(--secondary);
    min-width: 80px;
    text-align: left;
}

/* Waiter performance table */
.perf-table {
    width: 100%;
    border-collapse: collapse;
}

.perf-table th, .perf-table td {
    padding: 10px 12px;
    text-align: right;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
}

.perf-table th {
    background: var(--gray-100);
    font-weight: 700;
    color: var(--gray-700);
    font-size: 12px;
}

.perf-table tr:hover {
    background: var(--gray-50);
}

.perf-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.perf-bar {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
}

.perf-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Status mini-badges for admin */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 6px;
}

.status-dot.dot-pending { background: var(--warning); }
.status-dot.dot-preparing { background: var(--info); }
.status-dot.dot-ready { background: var(--success); }
.status-dot.dot-served { background: #9b59b6; }
.status-dot.dot-completed { background: var(--gray-400); }
.status-dot.dot-cancelled { background: var(--danger); }

/* Table utilization grid */
.table-util-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.table-util-card {
    background: var(--gray-100);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    border: 2px solid transparent;
    transition: var(--transition);
}

.table-util-card.is-occupied { border-color: var(--danger); background: #fdecea; }

.table-util-card .tu-num {
    font-size: 22px;
    font-weight: 800;
    color: var(--secondary);
}

.table-util-card .tu-section {
    font-size: 11px;
    color: var(--gray-500);
}

.table-util-card .tu-orders {
    font-size: 13px;
    font-weight: 700;
    color: var(--info);
    margin-top: 4px;
}

.table-util-card .tu-revenue {
    font-size: 12px;
    color: var(--success);
    font-weight: 700;
}

/* Admin recent order mini list */
.admin-order-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: var(--transition);
}

.admin-order-mini:hover {
    background: var(--gray-50);
    padding-right: 8px;
    padding-left: 8px;
    border-radius: 8px;
}

.admin-order-mini:last-child { border-bottom: none; }

.admin-order-mini .aom-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-order-mini .aom-num {
    font-weight: 700;
    font-size: 14px;
}

.admin-order-mini .aom-table {
    font-size: 12px;
    color: var(--gray-500);
}

.admin-order-mini .aom-total {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
}

@media (max-width: 1024px) {
    .admin-grid-2 { grid-template-columns: 1fr; }
}

/* ====== Branches ====== */
.branches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.branch-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border-right: 4px solid var(--primary);
}

.branch-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.branch-card.branch-inactive {
    opacity: 0.6;
    border-right-color: var(--gray-400);
}

.branch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.branch-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.branch-badges {
    display: flex;
    gap: 6px;
}

.badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-main {
    background: rgba(255, 193, 7, 0.15);
    color: var(--warning);
}

.badge-active {
    background: rgba(40, 167, 69, 0.12);
    color: var(--success);
}

.badge-inactive {
    background: rgba(220, 53, 69, 0.12);
    color: var(--danger);
}

.branch-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.branch-detail {
    font-size: 14px;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 8px;
}

.branch-detail i {
    color: var(--primary);
    width: 18px;
    text-align: center;
}

.branch-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    border: none;
    cursor: pointer;
    border-radius: var(--radius);
    padding: 8px 16px;
    font-family: inherit;
    transition: var(--transition);
}

.btn-danger:hover {
    opacity: 0.85;
}

@media (max-width: 768px) {
    .donut-chart-wrap { flex-direction: column; }
    .donut-chart { width: 140px; height: 140px; }
    .donut-center { width: 70px; height: 70px; font-size: 14px; }
}

/* ====== Print ====== */
@media print {
    .sidebar, .page-title, .detail-actions, .modal-header .close-btn { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    .order-detail { display: block !important; }
    .order-detail-card { box-shadow: none !important; border: 1px solid #ccc; margin-bottom: 12px; }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
