/* Shared look of the operator (/admin/) and dealer (/dealer/) consoles: sidebar, top bar, cards, tables. */
:root {
  --primary: #586cb1; --primary-dark: #4a5b99; --primary-soft: rgba(88, 108, 177, .1);
  --bg: #f3f5f9; --panel: #fff; --line: #e9ecf2; --text: #333a48; --muted: #8b93a4; --soft: #f7f8fb;
  --green: #21b978; --red: #ea5455; --orange: #f4a73c; --gray: #a8aebb;
  --sidebar: 224px; --header: 56px; --radius: 6px;
  color-scheme: light; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
.muted { color: var(--muted); }

/* sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(135deg, #eef1f8 0%, #f7f8fb 60%, #e9edf7 100%); }
.login-card { width: min(380px, 100%); background: var(--panel); border-radius: 10px; box-shadow: 0 10px 40px rgba(40, 52, 90, .12); padding: 32px 30px 26px; }
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 20px; font-weight: 700; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card form { display: grid; gap: 14px; }
.login-card .btn { height: 40px; }
.login-error { min-height: 18px; color: var(--red); font-size: 13px; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; transition: transform .2s; }
.sidebar .logo { height: var(--header); display: flex; align-items: center; gap: 10px; padding: 0 20px; font-size: 17px; font-weight: 700; color: #3b4254; border-bottom: 1px solid var(--line); }
.logo-mark { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 14px; flex: none; }
.menu { list-style: none; margin: 0; padding: 10px 0; overflow: auto; flex: 1; }
.menu button { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; background: none; padding: 11px 22px; text-align: left; color: #525b6e; cursor: pointer; font-size: 14px; }
.menu button svg { width: 17px; height: 17px; flex: none; opacity: .75; }
.menu button:hover { background: var(--soft); color: var(--primary); }
.menu button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.menu .group { padding: 14px 22px 6px; font-size: 12px; color: var(--gray); }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--header); background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 10; }
.topbar .toggle { border: 0; background: none; font-size: 20px; cursor: pointer; color: #616a7d; padding: 6px; }
.user { display: flex; align-items: center; gap: 12px; }
.user .who { text-align: right; line-height: 1.25; font-size: 13px; }
.user .who small { display: block; color: var(--green); font-size: 11px; }
.user .who small::before { content: "●"; margin-right: 4px; font-size: 9px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 700; }
.content { padding: 22px 24px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 600; }
.crumb { font-size: 12px; color: var(--muted); }
.crumb b { color: var(--text); font-weight: 500; }

/* cards & grids */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(40, 52, 90, .06); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 2fr 1fr; }
.grid > * { min-width: 0; }
.grid table { min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(40, 52, 90, .06); padding: 18px 20px; border-top: 3px solid var(--primary); }
.stat.green { border-top-color: var(--green); } .stat.orange { border-top-color: var(--orange); } .stat.red { border-top-color: var(--red); }
.stat b { display: block; font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.stat span { color: var(--muted); font-size: 13px; }
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.kv li:last-child { border-bottom: 0; }
.kv li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--primary); flex: none; }
.kv .k { width: 150px; color: #5d6577; }
.kv .v { font-weight: 600; }
.kv a { margin-left: 12px; font-weight: 400; font-size: 13px; }
.big-code { font-size: 26px; font-weight: 600; word-break: break-all; margin: 6px 0 16px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--red); border-color: rgba(234, 84, 85, .35); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 0 4px; height: auto; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: grid; gap: 6px; font-size: 13px; color: #5d6577; }
.field em { color: var(--red); font-style: normal; }
.field small { color: var(--muted); font-size: 12px; }
input, select, textarea { width: 100%; height: 36px; border: 1px solid #dcdfe6; border-radius: 4px; padding: 0 10px; background: #fff; outline: none; }
textarea { height: auto; min-height: 90px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--soft); }
.filters input, .filters select { width: auto; min-width: 160px; height: 32px; }

/* tables */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
th { background: var(--soft); color: #666f82; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fafbfd; }
td .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
td > .mono { white-space: nowrap; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.empty { text-align: center; color: var(--muted); padding: 36px 0; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 18px; font-size: 13px; color: var(--muted); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 3px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.green { color: var(--green); background: rgba(33, 185, 120, .1); }
.tag.red { color: var(--red); background: rgba(234, 84, 85, .1); }
.tag.orange { color: #d88a1d; background: rgba(244, 167, 60, .14); }
.tag.gray { color: #7d8595; background: #eef0f4; }
.tag.blue { color: var(--primary); background: var(--primary-soft); }
.plus { color: var(--green); font-weight: 600; } .minus { color: var(--red); font-weight: 600; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(28, 34, 52, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-head button { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; display: grid; gap: 14px; }
.modal-body .note { margin: 0; color: #5d6577; line-height: 1.6; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--soft); border-radius: 0 0 8px 8px; }
.form-error { color: var(--red); font-size: 13px; min-height: 0; }
.codes-box { width: 100%; min-height: 160px; font: 13px/1.8 ui-monospace, Menlo, Consolas, monospace; }
.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 4px; background: #333a48; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); z-index: 60; font-size: 13px; }
.toast.error { background: var(--red); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .shell.open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .main { margin-left: 0; }
  .grid.two { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .filters input, .filters select { flex: 1 1 140px; min-width: 0; }
}
