:root {
  --ink: #2B2620;
  --ink-soft: #6B6255;
  --cream: #FBF7F0;
  --paper: #FFFFFF;
  --line: #E7DFD1;
  --forest: #1F4D3D;
  --forest-dark: #163828;
  --forest-tint: #E7EFEA;
  --gold: #C98A2C;
  --gold-tint: #F7EAD2;
  --terracotta: #B84C3C;
  --terracotta-tint: #F7E4E0;
  --blue: #2B5C8A;
  --blue-tint: #E4EDF6;
  --amber: #B8781E;
  --amber-tint: #FBEED9;
  --green-ok: #2C7A4B;
  --green-tint: #E3F1E8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43,38,32,0.06), 0 4px 16px rgba(43,38,32,0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.font-display { font-family: 'Fraunces', Georgia, serif; }

.app-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--forest);
  color: #F3EFE6;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 14px;
}
.sidebar .brand .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-weight: 700; color: var(--forest-dark); font-size: 17px;
}
.sidebar .brand .name { font-family: 'Fraunces', serif; font-size: 15px; line-height: 1.25; font-weight: 600; }
.sidebar .brand .sub { font-size: 10.5px; color: #C9D9CE; letter-spacing: .04em; text-transform: uppercase; }
.sidebar .closeSidebarBtn { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 10px; border-radius: 8px; margin-bottom: 2px;
  color: #DCE6DF; font-size: 13.5px; font-weight: 500; cursor: pointer;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--gold); color: var(--forest-dark); font-weight: 600; }
.nav-item .icon { width: 16px; text-align: center; opacity: .9; }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.12); }
.role-pill {
  font-size: 10.5px; letter-spacing: .03em; text-transform: uppercase;
  background: rgba(255,255,255,0.1); color: #E7EFEA; padding: 3px 8px; border-radius: 999px; display: inline-block;
}

.sidebar-backdrop { display: none; }
.hamburgerBtn { display: none; }

/* ===== Topbar + Main ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px; background: var(--paper); border-bottom: 1px solid var(--line);
  gap: 10px;
}
.topbar .title {
  font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.content { padding: 22px 26px; flex: 1; overflow-y: auto; overflow-x: hidden; }

/* ===== Cards / KPI ===== */
.kpi-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-bottom: 6px; }
.kpi-value { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; color: var(--forest-dark); }
.kpi-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-x: auto;
}

/* ===== Layout helpers (classes instead of inline grid-template-columns so
   the media queries below can actually override them) ===== */
.two-col-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.pos-shell { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.order-detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: filter .12s ease;
  min-height: 38px;
}
.btn:active { filter: brightness(0.92); }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--forest-dark); }
.btn-gold { background: var(--gold); color: var(--forest-dark); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--forest); }
.btn-danger { background: var(--terracotta); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; min-height: 32px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { min-height: 38px; min-width: 38px; padding: 6px; }

/* ===== Status badges ===== */
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; display: inline-block; letter-spacing: .01em; }
.badge-forest { background: var(--forest-tint); color: var(--forest-dark); }
.badge-gold { background: var(--gold-tint); color: #8A5C15; }
.badge-blue { background: var(--blue-tint); color: var(--blue); }
.badge-amber { background: var(--amber-tint); color: var(--amber); }
.badge-green { background: var(--green-tint); color: var(--green-ok); }
.badge-red { background: var(--terracotta-tint); color: var(--terracotta); }
.badge-gray { background: #EFEBE2; color: var(--ink-soft); }

/* ===== Table status tiles ===== */
.table-tile {
  border-radius: 10px; padding: 14px 10px; text-align: center; cursor: pointer;
  border: 1px solid var(--line); transition: transform .1s ease;
}
.table-tile:hover { transform: translateY(-1px); }
.table-tile .name { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 700; }
.table-tile .cap { font-size: 10.5px; opacity: .75; margin-top: 2px; }
.tile-available { background: var(--green-tint); color: var(--green-ok); border-color: #C9E6D3; }
.tile-occupied { background: var(--terracotta-tint); color: var(--terracotta); border-color: #EFC9C1; }
.tile-reserved { background: var(--gold-tint); color: #8A5C15; border-color: #EFD9A9; }
.tile-cleaning { background: var(--blue-tint); color: var(--blue); border-color: #C7D9EA; }
.tile-blocked { background: #EFEBE2; color: var(--ink-soft); border-color: var(--line); }

/* ===== Menu item picker ===== */
.menu-tile {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--paper);
  transition: border-color .1s ease, transform .1s ease;
}
.menu-tile:hover { border-color: var(--gold); transform: translateY(-1px); }
.menu-tile .name { font-weight: 600; font-size: 13.5px; }
.menu-tile .price { color: var(--forest-dark); font-weight: 700; font-size: 13px; margin-top: 4px; }

/* ===== KOT ticket ===== */
.kot-ticket {
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow);
}
.kot-head { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed var(--line); }
.kot-body { padding: 10px 14px; }
.kot-item { display: flex; justify-content: space-between; font-size: 13.5px; padding: 4px 0; }
.kot-footer { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.ticket-new { border-left: 4px solid var(--blue); }
.ticket-accepted { border-left: 4px solid var(--gold); }
.ticket-preparing { border-left: 4px solid var(--amber); }
.ticket-ready { border-left: 4px solid var(--green-ok); }

/* ===== Forms ===== */
input, select, textarea {
  font-family: inherit; font-size: 16px; padding: 9px 10px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); width: 100%;
  min-height: 40px;
}
/* 16px input font-size prevents iOS Safari auto-zoom on focus; scaled back
   down on wider screens where zoom isn't a concern */
@media (min-width: 640px) {
  input, select, textarea { font-size: 13.5px; min-height: 36px; }
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
label { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; display: block; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; overflow-x: auto; }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.data tr:hover td { background: #FAF6EE; }

.toast {
  position: fixed; bottom: 20px; right: 20px; left: 20px; background: var(--forest-dark); color: #fff;
  padding: 12px 18px; border-radius: 9px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 300;
  animation: slideIn .18s ease; text-align: center;
}
@media (min-width: 640px) { .toast { left: auto; max-width: 360px; } }
.toast.error { background: var(--terracotta); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--forest) 0%, var(--forest-dark) 60%);
  padding: 20px;
}
.login-card {
  background: var(--cream); border-radius: 16px; padding: 36px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.leaf-motif {
  width: 46px; height: 46px; border-radius: 12px; background: var(--gold);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  margin-bottom: 16px;
}

.scroll-x { overflow-x: auto; }
.muted { color: var(--ink-soft); }
.grid-cols-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }

/* ===================== RESPONSIVE: TABLET & MOBILE ===================== */
@media (max-width: 900px) {
  .hamburgerBtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--paper); font-size: 18px; cursor: pointer; flex-shrink: 0;
  }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 210;
    width: 260px; max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .closeSidebarBtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 7px; border: none; background: rgba(255,255,255,.1);
    color: #fff; font-size: 16px; cursor: pointer; margin-left: auto;
  }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(20,16,10,.45); z-index: 200;
  }
  .sidebar-backdrop.open { display: block; }
  .topbar { padding: 12px 14px; }
  .topbar .title { font-size: 16px; }
  .hide-on-mobile { display: none; }
  .content { padding: 14px; }

  .two-col-grid { grid-template-columns: 1fr; }
  .pos-shell { grid-template-columns: 1fr; }
  .pos-shell .order-list-panel { max-height: 200px; overflow-y: auto; }
  .order-detail-grid { grid-template-columns: 1fr; }

  table.data { font-size: 12.5px; }
  table.data th, table.data td { padding: 7px 8px; }

  .grid-cols-auto { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
}

@media (max-width: 640px) {
  .modal-card { max-width: 100% !important; width: 100% !important; margin: 0 8px; max-height: 92vh; }
  .login-card { padding: 26px 22px; }
}

/* ===================== PRINT (receipts / KOT tickets) ===================== */
#printArea { display: none; }
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { display: block; position: absolute; top: 0; left: 0; width: 100%; padding: 0; margin: 0; }
  @page { margin: 6mm; }
}
.receipt { width: 100%; max-width: 300px; font-family: 'Courier New', monospace; font-size: 12px; color: #000; }
.receipt .center { text-align: center; }
.receipt .bold { font-weight: 700; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
.receipt .row { display: flex; justify-content: space-between; gap: 8px; }
.receipt .big { font-size: 15px; }
