:root {
  --sidebar-bg: #1f2430;
  --sidebar-text: #aeb6c6;
  --sidebar-active: #2d7cf6;
  --content-bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #23272e;
  --text-muted: #7a8291;
  --border: #e6e8ec;
  --green: #2ecc71;
  --yellow: #f5b041;
  --red: #e74c3c;
  --gray: #95a5a6;
  --purple: #9b59b6;
  --blue: #3498db;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--content-bg); color: var(--text); }
a { text-decoration: none; color: inherit; }

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

/* sidebar */
.sidebar { width: 220px; background: var(--sidebar-bg); color: var(--sidebar-text); flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 20px 16px; font-size: 16px; font-weight: 600; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 11px 18px; font-size: 14px; color: var(--sidebar-text); transition: .15s; }
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar nav a.active { color: #fff; background: var(--sidebar-active); }
.sidebar .footer { padding: 14px 18px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .footer button { background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 12px; }

/* main */
.main { flex: 1; padding: 24px 28px; overflow: auto; }
.page-title { font-size: 22px; font-weight: 600; margin-bottom: 20px; }

/* stat cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.card .label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.card .value { font-size: 26px; font-weight: 700; }
.card .sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* status colors */
.c-green { color: var(--green); } .c-yellow { color: var(--yellow); } .c-red { color: var(--red); }
.c-gray { color: var(--gray); } .c-purple { color: var(--purple); } .c-blue { color: var(--blue); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.b-green { background: #e8f8ef; color: #1e9e58; }
.b-yellow { background: #fef5e7; color: #d68910; }
.b-red { background: #fdecea; color: #c0392b; }
.b-gray { background: #eef0f2; color: #6c757d; }
.b-purple { background: #f4ecf7; color: #8e44ad; }
.b-blue { background: #eaf2fb; color: #2471a3; }

/* table */
.table-wrap { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #fafbfc; color: var(--text-muted); font-weight: 600; position: sticky; top: 0; }
tr:hover td { background: #fafbfc; }
.order-id { font-family: "SF Mono", Menlo, monospace; font-size: 12px; }

/* buttons & inputs */
button.btn { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; transition: .15s; }
button.btn-primary { background: var(--sidebar-active); color: #fff; }
button.btn-primary:hover { opacity: .9; }
button.btn-ghost { background: #eef0f2; color: var(--text); }
button.btn-danger { background: var(--red); color: #fff; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
input:focus, select:focus { outline: none; border-color: var(--sidebar-active); }

/* toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

/* steps form */
.steps { display: flex; gap: 8px; margin-bottom: 20px; }
.step { padding: 8px 16px; border-radius: 20px; background: #eef0f2; color: var(--text-muted); font-size: 13px; }
.step.active { background: var(--sidebar-active); color: #fff; }

/* login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--sidebar-bg); }
.login-card { background: #fff; border-radius: 12px; padding: 36px; width: 360px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.login-card h1 { font-size: 20px; margin-bottom: 24px; text-align: center; }
.login-card input { width: 100%; margin-bottom: 14px; }
.login-card button { width: 100%; }
.login-err { color: var(--red); font-size: 13px; margin-bottom: 12px; text-align: center; }

/* toast */
.toast { position: fixed; top: 20px; right: 20px; background: #23272e; color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 14px; z-index: 999; opacity: 0; transform: translateY(-10px); transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }

/* panel */
.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.panel .row { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }

/* ---------- mobile / H5 (<=820px) ---------- */
.nav-toggle { display: none; }
@media (max-width: 820px) {
  .layout { flex-direction: column; min-height: 100dvh; }

  /* sidebar becomes a sticky top bar with a hamburger menu */
  .sidebar { width: 100%; position: sticky; top: 0; z-index: 60; }
  .sidebar .brand { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: none; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: none; border-radius: 8px; background: rgba(255,255,255,.12); color: #fff; font-size: 19px; line-height: 1; cursor: pointer; }
  .sidebar nav { display: none; padding: 0 0 6px; }
  .sidebar.open nav { display: block; }
  .sidebar nav a { padding: 12px 18px; font-size: 15px; }
  .sidebar .footer { display: none; padding: 12px 18px; }
  .sidebar.open .footer { display: block; }

  .main { padding: 14px 14px 32px; }
  .page-title { font-size: 18px; margin-bottom: 14px; }

  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px; }
  .card .value { font-size: 20px; }

  /* step pills scroll horizontally instead of wrapping */
  .steps { overflow-x: auto; flex-wrap: nowrap; gap: 6px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .step { flex-shrink: 0; font-size: 12px; padding: 6px 12px; }

  /* form rows stack vertically; inputs fill the width (16px avoids iOS zoom) */
  .panel { padding: 14px; }
  .panel .row { flex-direction: column; align-items: stretch; gap: 10px; }
  .panel .row > label { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
  .panel .row input, .panel .row select { width: 100% !important; min-width: 0 !important; font-size: 16px; }
  .panel .row > div { width: 100%; }

  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { flex: 1 1 100%; min-width: 0; }

  /* wide tables scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 680px; }

  .login-card { width: calc(100% - 32px); padding: 24px; }
  .login-card input { font-size: 16px; }

  .toast { top: 10px; left: 12px; right: 12px; text-align: center; }
}

/* ---------- edit dialog (tickets) ---------- */
#editDialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 24px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
#editDialog::backdrop { background: #0008; }
#editDialog .dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
#editDialog .dialog-heading h2 { font-size: 18px; }
#editDialogBody { max-height: calc(100dvh - 160px); overflow: auto; }
#editDialogBody .row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
#editDialogBody .row input, #editDialogBody .row select { padding: 8px 10px; }
@media (max-width: 800px) { #editDialog { padding: 16px; } }
