:root {
  --bg: #050b16;
  --surface: #0d1526;
  --surface-soft: #111c31;
  --card: #15223b;
  --line: #283754;
  --line-strong: #33496f;
  --text: #edf2ff;
  --muted: #94a3bf;
  --brand: #17c08a;
  --brand-soft: rgba(23, 192, 138, 0.16);
  --blue: #53a2ff;
  --green: #2dd083;
  --orange: #f6ae4f;
  --rose: #f2748a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", "Noto Sans TC", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(83, 162, 255, 0.14), transparent 35%),
    radial-gradient(
      circle at 95% 8%,
      rgba(23, 192, 138, 0.14),
      transparent 30%
    ),
    var(--bg);
  overflow: hidden;
}

p,
span,
a,
button,
h1,
h2,
h3 {
  overflow-wrap: anywhere;
}

.pos-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(13, 21, 38, 0.78);
  padding: 12px 14px;
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.app-header > * {
  min-width: 0;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1fd398, #1f7dd3);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(31, 125, 211, 0.15);
}

.brand-icon svg {
  width: 19px;
  height: 19px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.quick-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 8px 10px;
}

.lang-switch {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}

.lang-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  white-space: nowrap;
}

.lang-btn.active {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--card);
}

.pill-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.pill-value {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 1.5fr minmax(240px, 0.9fr);
  gap: 12px;
}

.floor-card,
.ticket-card {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(
    160deg,
    rgba(17, 28, 49, 0.92),
    rgba(13, 21, 38, 0.92)
  );
}

.floor-card {
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.floor-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.zone-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 3px;
  flex-wrap: wrap;
}

.zone-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: normal;
  text-align: center;
}

.zone-tab.active {
  background: var(--card);
  color: var(--text);
}

.legend {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
}

.dot.free {
  background: var(--blue);
}
.dot.occupied {
  background: var(--green);
}
.dot.reserved {
  background: var(--orange);
}
.dot.cleaning {
  background: var(--rose);
}

.table-grid {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  padding-right: 2px;
}

.table-grid::-webkit-scrollbar {
  width: 6px;
}

.table-grid::-webkit-scrollbar-thumb {
  background: #2d4264;
  border-radius: 999px;
}

.table-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #14213a;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.table-card.active {
  border-color: #3ad7a4;
  box-shadow:
    0 0 0 1px rgba(58, 215, 164, 0.35),
    0 8px 20px rgba(23, 192, 138, 0.2);
}

.table-card.free {
  border-left: 3px solid var(--blue);
}
.table-card.occupied {
  border-left: 3px solid var(--green);
}
.table-card.reserved {
  border-left: 3px solid var(--orange);
}
.table-card.cleaning {
  border-left: 3px solid var(--rose);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.card-top h3 {
  font-size: 14px;
  letter-spacing: 0.2px;
}

.card-info {
  color: #ced8ee;
  font-size: 12px;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.signal {
  color: var(--brand);
  font-size: 12px;
}

.status-chip {
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
  padding: 5px 7px;
  border: 1px solid transparent;
}

.status-chip.free {
  color: var(--blue);
  background: rgba(83, 162, 255, 0.13);
}

.status-chip.occupied {
  color: var(--green);
  background: rgba(45, 208, 131, 0.13);
}

.status-chip.reserved {
  color: var(--orange);
  background: rgba(246, 174, 79, 0.16);
}

.status-chip.cleaning {
  color: var(--rose);
  background: rgba(242, 116, 138, 0.16);
}

.ticket-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 10px;
  padding: 14px;
}

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

.ticket-label {
  color: var(--muted);
  font-size: 11px;
}

.ticket-head h2 {
  margin-top: 2px;
  font-size: 24px;
}

.meta-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-row span {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface);
}

.order-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 2px;
}

.order-list::-webkit-scrollbar {
  width: 6px;
}

.order-list::-webkit-scrollbar-thumb {
  background: #2d4264;
  border-radius: 999px;
}

.order-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12px;
}

.order-item span {
  min-width: 0;
}

.order-item strong {
  font-size: 12px;
}

.summary {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  display: grid;
  gap: 4px;
}

.row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.row strong {
  color: #dbe7ff;
}

.row.total {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--line-strong);
  color: var(--text);
  font-size: 14px;
}

.row.total strong {
  color: var(--brand);
}

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

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: normal;
}

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.btn.solid {
  background: linear-gradient(130deg, #1fd398, #1799c0);
  color: #062219;
}

.mobile-nav {
  display: none;
}

@media (max-width: 980px) {
  .quick-stats {
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .ticket-card {
    grid-template-rows: auto auto auto auto auto;
  }
}

@media (max-width: 640px) {
  body {
    overflow: auto;
  }

  .pos-shell {
    height: auto;
    min-height: 100%;
    padding: 10px;
    gap: 10px;
    padding-bottom: 74px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .lang-switch {
    margin-left: 0;
  }

  .legend {
    overflow: auto;
    white-space: nowrap;
    width: 100%;
  }

  .table-grid {
    grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    text-align: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 62px;
    border-top: 1px solid var(--line);
    background: rgba(9, 15, 28, 0.9);
    backdrop-filter: blur(10px);
  }

  .mobile-nav a {
    color: #7183a8;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
  }

  .mobile-nav a.active {
    color: var(--brand);
  }
}

body.force-mobile {
  overflow: auto;
}

body.force-mobile .pos-shell {
  height: auto;
  min-height: 100%;
  padding-bottom: 74px;
}

body.force-mobile .workspace {
  grid-template-columns: 1fr;
}

body.force-mobile .ticket-card {
  display: none;
}

body.force-mobile .mobile-nav {
  display: grid;
}
