/* ============================================================
   DOCK OFFICE — MANAGEMENT CONSOLE
   Professional back-office theme (UniFi/Portainer-inspired):
   dark slate sidebar, light workspace, bordered cards, dense
   tables, inline SVG icons. Phones get the same theme with a
   bottom nav.
   ============================================================ */

:root {
  --accent: #1f7a54;            /* ISP spruce, corporate cut */
  --accent-hover: #22885e;
  --accent-press: #1a6848;
  --accent-soft: rgba(31, 122, 84, .09);

  --side-bg: #1b2430;           /* sidebar slate */
  --side-text: #9aa7b4;
  --side-text-active: #ffffff;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(31, 122, 84, .28);

  --bg: #f4f5f7;                /* workspace */
  --card: #ffffff;
  --border: #e2e6ea;
  --border-strong: #d3d9df;

  --text: #1f2933;
  --text-2: #5c6b7a;
  --text-3: #8a98a6;

  --danger: #c9403a;
  --danger-soft: rgba(201, 64, 58, .08);

  --radius: 8px;
  --sidebar-w: 224px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .05);
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-size: 14px;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

input:focus-visible, button:focus-visible, textarea:focus-visible {
  outline: 2px solid rgba(31, 122, 84, .5);
  outline-offset: 1px;
  border-radius: 4px;
}

.icon { width: 18px; height: 18px; flex: none; }

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(16, 24, 32, .08);
  padding: 40px 36px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-logo {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.login-logo .icon { width: 28px; height: 28px; }

.login-card h1 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.login-sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 22px; }

.login-fields { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.login-fields input {
  display: block;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  padding: 11px 14px;
  font-size: 15px;
  background: #fbfcfd;
  transition: border-color .12s ease;
}
.login-fields input:focus { border-color: var(--accent); background: #fff; }

.login-error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }

.btn-primary {
  width: 100%;
  max-width: 380px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 14.5px;
  font-weight: 600;
  transition: background .12s ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { opacity: .5; }

/* ---------------- app frame ---------------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 28px 0;
  max-width: 1060px;
  margin: 0 auto;
}

.app-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--text-3);
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-top: 2px;
}

.btn-save-top { display: none; }

.btn-quiet {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background .12s ease, border-color .12s ease;
}
.btn-quiet:hover { background: #f6f8f9; border-color: #bfc8d0; }

.content {
  max-width: 1060px;
  margin: 0 auto;
  padding: 4px 28px calc(140px + env(safe-area-inset-bottom));
}

/* ---------------- sidebar / bottom nav ---------------- */
.side-nav .brand, .side-nav .nav-user { display: none; }

.tab-buttons {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  gap: 0;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: var(--side-bg);
  border-top: 1px solid rgba(255, 255, 255, .07);
  z-index: 10;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  max-width: 84px;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 8px;
  color: var(--side-text);
  font-size: 10px;
  font-weight: 600;
}
.tab-btn .icon { width: 19px; height: 19px; }
.tab-btn.active { color: #fff; }

@media (max-width: 919px) {
  .side-nav .nav-user {
    display: flex;
    position: fixed;
    top: 14px;
    right: 20px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-2);
    z-index: 11;
  }
  .side-nav .nav-user .btn-quiet { padding: 4px 10px; }
  .app-header { padding-top: 18px; }
}

@media (min-width: 920px) {
  .side-nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--side-bg);
    display: flex;
    flex-direction: column;
    padding: 20px 12px 16px;
    z-index: 10;
  }

  .side-nav .brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 2px 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 14px;
  }
  .brand-mark {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
  }
  .brand-mark .icon { width: 20px; height: 20px; }
  .brand-name { font-weight: 700; font-size: 14.5px; color: #fff; letter-spacing: -.01em; }
  .brand-sub { font-size: 11.5px; color: var(--side-text); margin-top: 1px; }

  .tab-buttons {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    background: none;
    border: none;
    overflow: visible;
  }

  .tab-btn {
    max-width: none;
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    font-size: 13.5px;
    font-weight: 500;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--side-text);
    position: relative;
  }
  .tab-btn:hover { background: var(--side-hover); color: #dbe2e8; }
  .tab-btn.active {
    background: var(--side-active);
    color: var(--side-text-active);
    font-weight: 600;
  }
  .tab-btn.active::before {
    content: "";
    position: absolute;
    left: -12px; top: 7px; bottom: 7px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--accent);
  }

  .side-nav .nav-user {
    display: flex;
    margin-top: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: 12.5px;
    color: var(--side-text);
  }
  .side-nav .nav-user .btn-quiet {
    background: none;
    border: 1px solid rgba(255, 255, 255, .18);
    color: #cfd7de;
    padding: 5px 12px;
    font-size: 12.5px;
  }
  .side-nav .nav-user .btn-quiet:hover { background: var(--side-hover); }

  .main-col { margin-left: var(--sidebar-w); }
  .content { padding-bottom: 80px; }

  .btn-save-top {
    display: block;
    width: auto;
    max-width: none;
    padding: 9px 20px;
    font-size: 13.5px;
    border-radius: 7px;
  }
  .save-bar { display: none !important; }
}

/* ---------------- grouped panels ---------------- */
.group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin: 26px 2px 8px;
}
.group-foot {
  font-size: 12.5px;
  color: var(--text-3);
  margin: 8px 2px 0;
  line-height: 1.5;
}

.group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  min-height: 46px;
}
.row + .row { border-top: 1px solid var(--border); }

.row-label { flex: 1; font-size: 14px; font-weight: 500; }
.row-sub { display: block; font-size: 12px; color: var(--text-2); margin-top: 1px; font-weight: 400; }

.row input[type="text"],
.row input[type="password"],
.row input[type="number"],
.row select {
  border: none;
  outline: none;
  background: transparent;
  text-align: right;
  font-size: 14px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.row input::placeholder { color: var(--text-3); }

.row input[type="time"] {
  border: 1px solid var(--border);
  outline: none;
  background: #fbfcfd;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13.5px;
  color: var(--text);
}

.row textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: vertical;
  min-height: 24px;
  font-size: 14px;
}

/* item cards (users tab) */
.item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
}
.btn-remove:hover { background: var(--danger-soft); }

.btn-add {
  width: 100%;
  background: var(--card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--accent);
  font-weight: 600;
  font-size: 13.5px;
  padding: 11px;
  margin: 4px 0 12px;
  transition: border-color .12s ease, background .12s ease;
}
.btn-add:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------------- data tables ---------------- */
.sheet-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.sheet {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.sheet td input { min-width: 110px; }
.sheet td input[type="time"], .sheet td input[type="number"] { min-width: 0; }

.sheet th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-2);
  background: #f8f9fb;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sheet .th-x { width: 40px; }

.sheet td {
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.sheet tbody tr:last-child td { border-bottom: none; }
.sheet tbody tr:hover td { background: #f7f9fa; }

.sheet td input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 9px 10px;
  font-size: 13.5px;
}
.sheet td input[type="time"] { font-variant-numeric: tabular-nums; }
.sheet td input:focus { background: var(--accent-soft); }

.sheet .td-x { text-align: center; }
.btn-x {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 5px;
}
.btn-x:hover { color: var(--danger); background: var(--danger-soft); }

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
}
.sheet-foot .btn-add {
  width: auto;
  margin: 0;
  border: none;
  padding: 5px 10px;
  font-size: 13px;
}
.sheet-foot .group-foot { margin: 0; }

/* menu stock toggle */
.btn-stock { border-color: rgba(31, 122, 84, .45); color: var(--accent); }
.btn-stock.out { border-color: rgba(201, 64, 58, .5); color: var(--danger); background: var(--danger-soft); }
.btn-stock.out:hover { border-color: var(--danger); }

/* menu add-ons editor */
.btn-opts {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  padding: 4px 10px;
  white-space: nowrap;
}
.btn-opts:hover, .btn-opts.open { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.td-opts { text-align: center; }

.opts-tr td { background: #f8f9fb; }
.opt-box { padding: 10px 14px 12px; }
.opt-title { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.opt-row input[type="text"] {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  background: #fff;
}
.opt-plus { font-size: 13px; color: var(--text-2); font-weight: 600; }
.opt-row .opt-price {
  width: 90px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  background: #fff;
}
.opt-add { width: auto !important; margin: 4px 0 0 !important; border: none !important; padding: 4px 8px !important; font-size: 12.5px !important; }

/* ---------------- schedule: calendar + day ---------------- */
.sched-layout { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }

@media (max-width: 919px) {
  /* keep the calendar hand-sized on phones/tablets */
  .cal-pane { max-width: 440px; width: 100%; margin: 0 auto; }
}

@media (min-width: 920px) {
  .sched-layout { flex-direction: row; align-items: flex-start; }
  .cal-pane { flex: 0 0 320px; position: sticky; top: 18px; }
  .day-pane { flex: 1; min-width: 0; }
}

.cal-pane {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.cal-head .btn-quiet { font-size: 15px; padding: 2px 10px; border: none; background: none; color: var(--text-2); }
.cal-head .btn-quiet:hover { color: var(--text); background: #f0f2f4; }
.cal-title { flex: 1; text-align: center; font-weight: 600; font-size: 14px; }
.cal-today { font-size: 12px !important; color: var(--accent) !important; font-weight: 600; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-dow {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-3);
  padding: 4px 0;
}

.cal-cell {
  aspect-ratio: 1;
  border: none;
  background: none;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12.5px;
  color: var(--text);
}
.cal-cell:hover { background: #eef1f3; }
.cal-cell.is-today .cal-num { color: var(--accent); font-weight: 800; }
.cal-cell.is-selected { background: var(--accent); color: #fff; }
.cal-cell.is-selected .cal-num { color: #fff; }
.cal-cell.is-selected .dot { background: #fff; }

.cal-dots { display: flex; gap: 2px; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

.cal-foot {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.day-date {
  border: 1px solid var(--border-strong);
  outline: none;
  background: var(--card);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------------- AI import ---------------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--card);
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  margin-top: 8px;
}
.dropzone:hover, .dropzone.over {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.drop-svg { width: 34px; height: 34px; color: var(--text-3); margin-bottom: 10px; }
.dropzone:hover .drop-svg, .dropzone.over .drop-svg { color: var(--accent); }
.drop-title { font-weight: 600; font-size: 14.5px; }
.drop-sub { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

.import-preview { margin-top: 14px; }
.preview-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(16, 24, 32, .1);
}
.preview-pdf {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 13.5px;
}

.import-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}
.import-actions .btn-primary { width: auto; padding: 9px 20px; font-size: 13.5px; }

.import-status { margin-top: 12px; font-size: 13px; color: var(--text-2); }

.import-results { margin-top: 6px; }

.diff-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 14px;
  overflow: hidden;
}

.diff-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.diff-head input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
}

.diff-day { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.diff-day:last-child { border-bottom: none; }
.diff-day.same { opacity: .55; }
.diff-date { font-weight: 700; font-size: 12.5px; margin-bottom: 4px; }
.diff-label { font-size: 11.5px; color: var(--text-3); margin: 2px 0; }

.diff-old, .diff-new, .diff-same {
  font-size: 12.5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 2px 0 2px 8px;
  white-space: pre-wrap;
}
.diff-old { color: var(--danger); }
.diff-new { color: var(--accent); }
.diff-same { color: var(--text-2); }

.diff-json {
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 12px 16px;
  overflow-x: auto;
  max-height: 300px;
  color: var(--text);
}

/* ---------------- switches / badges ---------------- */
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0;
  background: #d5dbe0;
  border-radius: 999px;
  transition: background .15s ease;
  pointer-events: none;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(16px); }

.pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.pill.gray { background: #eef1f3; color: var(--text-2); }

/* ---------------- save bar (mobile) & toast ---------------- */
.save-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(66px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  padding: 0 20px;
  z-index: 20;
}
.save-bar .btn-primary {
  max-width: 420px;
  box-shadow: 0 10px 26px rgba(16, 24, 32, .3);
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #232f3a;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 8px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
.toast.error { background: var(--danger); }

@media (max-width: 480px) {
  .app-header h1 { font-size: 20px; }
}
