* { box-sizing: border-box; }

:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary-a: #f97316;
  --primary-b: #dc2626;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

.hidden { display: none !important; }
.view { min-height: 100dvh; }
.muted { color: var(--muted); margin: 0; }
.mini { font-size: 12px; color: var(--muted); }

.login-shell {
  width: min(420px, calc(100vw - 24px));
  margin: 6vh auto;
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.login-shell h1 { margin: 0 0 4px; font-size: 24px; }
.login-shell p { margin: 0 0 14px; color: var(--muted); }

form { display: grid; gap: 10px; }

input, select, textarea, button {
  width: 100%;
  min-height: 44px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

button {
  border: none;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(90deg, var(--primary-a), var(--primary-b));
  cursor: pointer;
}

button.secondary {
  background: #e5e7eb;
  color: #374151;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.demo { margin-top: 12px; font-size: 12px; color: var(--muted); }

#dashboard-view {
  display: grid;
  grid-template-columns: 84px 1fr;
  min-height: 100dvh;
}

aside {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 8px;
  display: grid;
  gap: 10px;
  align-content: start;
  justify-items: center;
}

.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--primary-a), var(--primary-b));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 24px;
  margin: 8px 0 6px;
}

.nav-btn {
  width: 64px;
  min-height: 64px;
  border-radius: 14px;
  background: #eef0f3;
  color: #475569;
  display: grid;
  place-items: center;
  padding: 6px;
  gap: 4px;
}

.nav-btn i {
  width: 20px;
  height: 20px;
}

.nav-btn span {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.nav-btn.active {
  background: linear-gradient(180deg, var(--primary-a), var(--primary-b));
  color: #fff;
  box-shadow: 0 8px 18px rgba(249, 115, 22, .28);
}

.nav-btn[data-tab="pending"].active {
  background: linear-gradient(180deg, #f59e0b, #d97706);
}

.nav-btn[data-tab="completed"].active {
  background: linear-gradient(180deg, #64748b, #475569);
}

.nav-btn[data-tab="menu"].active {
  background: linear-gradient(180deg, #22c55e, #16a34a);
}

.nav-btn[data-tab="stock"].active {
  background: linear-gradient(180deg, #3b82f6, #0ea5e9);
}

.nav-btn[data-tab="expenses"].active {
  background: linear-gradient(180deg, #a855f7, #ec4899);
}

.nav-btn[data-tab="reports"].active {
  background: linear-gradient(180deg, #14b8a6, #10b981);
}

.nav-btn[data-tab="users"].active {
  background: linear-gradient(180deg, #6366f1, #8b5cf6);
}

.nav-btn[data-tab="settings"].active {
  background: linear-gradient(180deg, #6b7280, #4b5563);
}

.logout-btn {
  margin-top: 8px;
}

main {
  padding: 14px;
  overflow-x: hidden;
}

header {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
}

header h1 {
  margin: 0;
  font-size: clamp(20px, 3.4vw, 28px);
}

#user-pill {
  font-size: 12px;
  color: #fff;
  background: linear-gradient(90deg, var(--primary-a), var(--primary-b));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 600;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clock-wrap {
  text-align: right;
}

.header-time {
  font-size: 30px;
  color: var(--primary-a);
  font-weight: 800;
  line-height: 1;
}

.header-date {
  font-size: 12px;
  color: var(--muted);
}

.tab { display: none; }
.tab.active { display: block; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 800;
  color: #0f2747;
}

.actions-row {
  display: flex;
  gap: 10px;
}

.action-btn {
  width: auto;
  min-width: 142px;
  min-height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
}

.action-btn i { width: 18px; height: 18px; }

.action-orange { background: linear-gradient(90deg, #ff7a00, #ff2d2d); }
.action-green { background: linear-gradient(90deg, #22c55e, #10b981); }
.action-blue { background: linear-gradient(90deg, #3b82f6, #06b6d4); }
.action-purple { background: linear-gradient(90deg, #8b5cf6, #ec4899); }
.action-indigo { background: linear-gradient(90deg, #6366f1, #8b5cf6); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 12px;
}

.pos-subtabs {
  display: inline-flex;
  background: #eef1f5;
  border: 1px solid #dbe1ea;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 10px;
}

.subtab {
  width: auto;
  min-height: 36px;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  padding: 0 12px;
  font-size: 13px;
}

.subtab.active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.panel { margin-bottom: 12px; }

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-grid label {
  display: block;
  font-size: 13px;
  color: #334155;
  margin: 8px 0 4px;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #edf0f3;
  vertical-align: middle;
}

.table th {
  color: #334155;
  font-weight: 700;
  font-size: 13px;
}

.table td .mini {
  font-size: 12px;
  color: var(--muted);
}

.qty-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  min-height: 34px;
  min-width: 34px;
  border-radius: 8px;
  padding: 0;
}

.status-ok {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-low {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.bar-line {
  margin: 10px 0;
}

.bar-line .row-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
}

.bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #a855f7, #ec4899);
}

.role-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.role-admin { background: #fee2e2; color: #991b1b; }
.role-manager { background: #dbeafe; color: #1d4ed8; }
.role-cashier { background: #dcfce7; color: #166534; }

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.report-green { color: #16a34a; }
.report-orange { color: #ea580c; }
.report-blue { color: #2563eb; }
.report-purple { color: #9333ea; }

.menu-item-card .price { font-size: 20px; }

.inline-form button {
  grid-column: span 1;
}

.menu-item { cursor: pointer; transition: border-color .2s ease, transform .2s ease; }
.menu-item:hover { border-color: #fdba74; transform: translateY(-1px); }
.menu-item h4, .order-card h4 { margin: 0 0 4px; font-size: 15px; overflow-wrap: anywhere; }
.menu-item p { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.price { color: var(--primary-a); font-weight: 700; margin: 6px 0 0; }

.menu-item {
  position: relative;
}

.menu-item::before {
  content: "🍴";
  display: grid;
  place-items: center;
  height: 82px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--primary-a), var(--primary-b));
  font-size: 34px;
  margin-bottom: 8px;
  color: #fff;
}

#cart-list .line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  background: #f9fafb;
  border-radius: 8px;
}

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

#order-fields {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

#totals {
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
}

#totals p { margin: 6px 0; font-size: 13px; }
#totals h4 { margin: 8px 0 0; font-size: 18px; }

.dialog-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.order-card p { margin: 4px 0; }

.order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 8px;
}

.badge.pending { background: #fef3c7; color: #92400e; }
.badge.ready { background: #dcfce7; color: #166534; }
.badge.paid { background: #dbeafe; color: #1d4ed8; }

.order-controls {
  margin-top: 8px;
}

.ready-note {
  font-size: 12px;
  color: #166534;
  font-weight: 700;
}

dialog {
  width: min(420px, calc(100vw - 20px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

@media (max-width: 1080px) {
  #dashboard-view { grid-template-columns: 1fr; }

  aside {
    position: sticky;
    top: 0;
    z-index: 20;
    border-right: none;
    border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    gap: 6px;
    justify-items: stretch;
  }

  .brand-badge { display: none; }
  .nav-btn {
    width: 100%;
    min-height: 48px;
    grid-template-columns: auto 1fr;
    grid-auto-flow: column;
    justify-content: center;
    gap: 6px;
    border-radius: 10px;
    font-size: 12px;
  }
  .nav-btn span { font-size: 12px; }

  .split { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .section-head h3 { font-size: 32px; }
}

@media (max-width: 720px) {
  main { padding: 10px; }
  .grid { grid-template-columns: 1fr; }

  aside {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 10px;
  }

  aside button { font-size: 13px; padding: 8px; min-height: 42px; }
  header { align-items: flex-start; flex-direction: column; }
  #user-pill { font-size: 11px; }
  .header-right { width: 100%; justify-content: space-between; }
  .header-time { font-size: 24px; }

  .dialog-actions { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .menu-item h4, .order-card h4 { font-size: 14px; }
  .table { min-width: 680px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .section-head h3 { font-size: 28px; }
  .actions-row { width: 100%; }
  .action-btn { flex: 1; min-width: 0; }
  .pos-subtabs { width: 100%; }
  .subtab { flex: 1; text-align: center; }
}
