:root {
  --bg: #0c1118;
  --bg2: #141b26;
  --surface: #182230;
  --line: #2c3a4d;
  --text: #eef2f7;
  --muted: #93a0b4;
  --accent: #d4b15c;
  --accent-ink: #1a160c;
  --danger: #e07272;
  --ok: #6fcf97;
  --shadow: 0 16px 40px rgba(0, 0, 0, .32);
  --radius: 14px;
  --font: "Segoe UI", system-ui, sans-serif;
  --pad: 20px;
  --control-h: 42px;
  --gap: 16px;
}
[data-theme="light"] {
  --bg: #f3efe6;
  --bg2: #fffdf8;
  --surface: #ffffff;
  --line: #e2dacb;
  --text: #1b1f27;
  --muted: #667085;
  --accent: #b0892e;
  --accent-ink: #1a160c;
  --danger: #c0392b;
  --ok: #1f8a4c;
  --shadow: 0 12px 28px rgba(40, 30, 10, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 8% -12%, rgba(212, 177, 92, .14), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.env-banner {
  display: none;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.test-banner {
  background: #2e9b4a;
  color: #fff;
}
html[data-instance="test"] .test-banner {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700;
  letter-spacing: .04em;
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-sep {
  width: 1px;
  height: 16px;
  background: color-mix(in srgb, var(--accent) 45%, var(--line));
  flex-shrink: 0;
}
.page-title {
  color: var(--accent);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: .06em;
  white-space: nowrap;
}
.page-who {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}
.tools {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}
.iconbtn, .logout-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  height: var(--control-h);
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, border-color .15s;
}
.iconbtn { width: var(--control-h); padding: 0; }
.logout-btn {
  padding: 0 14px;
  font-weight: 600;
  font-size: 13px;
}
.iconbtn:hover, .logout-btn:hover { border-color: var(--accent); }
.iconbtn:disabled { opacity: .4; cursor: not-allowed; }
.logout-ico { flex-shrink: 0; }
.lang-wrap { position: relative; }
.flag {
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12);
}
.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: none;
  box-shadow: var(--shadow);
  overflow: hidden;
  width: max-content;
  min-width: 148px;
  z-index: 40;
}
.lang-menu.open { display: block; }
.lang-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.lang-menu button:hover { background: var(--bg2); }

.wrap {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 72px;
}
.hero {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 24px;
}
.hero:empty { display: none; margin: 0; }
.hero h1 {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 650;
  margin: 0;
}
.hero p { color: var(--muted); margin: 6px 0 0; }
.role-badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
  margin: 0 0 var(--gap);
}
.card h3 {
  margin: 0 0 var(--gap);
  font-size: 1.05rem;
  font-weight: 650;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--gap);
}
.card-head h3 { margin: 0; }

.workspace { display: flex; flex-direction: column; gap: var(--gap); }
.workspace .card,
.split > .card,
.staff-cols > .card { margin: 0; }
.workspace > .grid,
.workspace > .actions { margin: 0; }
.split,
.staff-cols {
  display: grid;
  gap: var(--gap);
}
.form-grid {
  display: grid;
  gap: var(--gap);
}
.field { min-width: 0; }
.field label, .card > label, .login-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}
.field + .field { margin-top: 0; }
p + label, input + label, select + label, textarea + label { margin-top: 14px; }
input, textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background-color: var(--bg2);
}
.ss-select {
  position: relative;
  width: 100%;
  z-index: 1;
}
.ss-select.open { z-index: 20; }
.ss-select select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.ss-select-btn {
  width: 100%;
  height: var(--control-h);
  padding: 0 40px 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background-color: var(--bg2);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path fill='none' stroke='%23eef2f7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 1.5 L6 6 L10.5 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="light"] .ss-select-btn {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path fill='none' stroke='%231b1f27' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 1.5 L6 6 L10.5 1.5'/></svg>");
}
.ss-select.open .ss-select-btn { border-color: var(--accent); }
.ss-select.open .ss-select-btn {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path fill='none' stroke='%23d4b15c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 6.5 L6 1.5 L10.5 6.5'/></svg>");
}
.ss-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
  z-index: 40;
}
.ss-menu.open { display: block; }
.ss-menu button {
  width: 100%;
  display: block;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
}
.ss-menu button:hover { background: var(--bg2); }
.ss-menu button.on {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}
textarea {
  height: auto;
  min-height: 88px;
  padding: 12px 14px;
  resize: vertical;
}
input[type="file"] {
  height: auto;
  padding: 10px;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
  padding: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  height: var(--control-h);
  padding: 0 18px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--danger); color: #fff; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}
.row, .actions {
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
  margin-top: var(--gap);
}
.msg { margin-top: 12px; color: var(--muted); }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: var(--gap);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
}
.stat span { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 1.6rem; margin-top: 6px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table-wrap { overflow-x: auto; }
table.data th, table.data td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.loc-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
}
table.data td.col-active {
  padding: 12px 18px;
}
table.data td.col-impersonate {
  width: 52px;
  padding: 8px 12px;
}
table.data .iconbtn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 28px;
  padding: 0 12px;
  margin: 0 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.pill.on { background: color-mix(in srgb, var(--ok) 18%, var(--bg2)); color: var(--ok); }
.pill.off { color: var(--muted); }

.list-item {
  padding: var(--gap) 0 0;
  border-top: 1px solid var(--line);
}
.card > h3 + .list-item,
.list-item:first-child {
  padding-top: 0;
  border-top: 0;
}
.list-item .actions,
.list-item .field,
.list-item .form-grid { margin-top: var(--gap); }
.list-item pre { margin: var(--gap) 0 0; }
.hit {
  width: 100%;
  justify-content: space-between;
}
.empty { color: var(--muted); margin: 0; padding: 0; }

.login-shell {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}
.lookup-row {
  display: flex;
  gap: var(--gap);
  align-items: flex-end;
}
.lookup-row .field { flex: 1; min-width: 0; }
.guest-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.guest-head h3 { margin: 0; }
.guest-phone { color: var(--muted); margin: 6px 0 0; }
.balance-box { text-align: right; }
.balance-box span { color: var(--muted); font-size: 13px; }
.balance-lg {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}
.hist-detail { color: var(--muted); font-size: 13px; margin-top: 4px; }
.pts-plus { color: var(--ok); font-weight: 650; }
.pts-minus { color: var(--danger); font-weight: 650; }
.login-card {
  width: min(420px, 100%);
  margin: 0;
}
.login-card .form-grid { grid-template-columns: 1fr; }

.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 10, 16, .62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.modal h3 { margin: 0 0 12px; font-size: 1.1rem; }
.modal p {
  margin: 0;
  color: var(--muted);
  white-space: pre-line;
  line-height: 1.5;
}

@media (min-width: 960px) {
  .split { grid-template-columns: 1.15fr .85fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .login-card .form-grid { grid-template-columns: 1fr; }
  .staff-cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 959px) {
  .grid { grid-template-columns: 1fr; }
  .wrap { width: min(100% - 32px, 1180px); padding-top: 20px; }
  .topbar { padding: 12px 16px; }
  .logout-btn { width: var(--control-h); padding: 0; }
  .logout-btn span { display: none; }
  .page-title { font-size: 13px; }
}
