/* Admin UI. Tokens, form controls and buttons come from /static/shared/tokens.css */

/* ---------- Checkout look: white, flat, bordered boxes, royal-blue actions, bold uppercase headings ---------- */
:root {
  --font: "Inter", "Segoe UI", Roboto, ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --sunken: #f3f4f7;
  --line: #e5e7eb;
  --line-strong: #d3d7df;
  --text: #0f172a;
  --text-2: #374151;
  --text-3: #6b7280;
  --brand: #0a47d6;
  --brand-2: #0a47d6;
  --brand-soft: #eef3ff;
  --brand-ring: rgba(10, 71, 214, 0.22);
  --grad: var(--brand);
  --ok: #0f8a4f;
  --ok-soft: #e6f5ec;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 8px;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-brand: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --grad: var(--brand); --shadow-sm: none; --shadow-md: none; --shadow-brand: none; }
}
:root[data-theme="dark"] { --grad: var(--brand); --shadow-sm: none; --shadow-md: none; --shadow-brand: none; }
h1, h2, h3 { letter-spacing: 0; }
h1, .card h2, .drawer-head h2, .empty b { text-transform: uppercase; font-weight: 800; letter-spacing: 0.02em; }
.card h2 { font-size: 14px; letter-spacing: 0.09em; }
button.primary { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; border-radius: var(--r-sm); }
button.primary:hover { background: #083bb0; filter: none; transform: none; }
input, select, textarea { border-radius: var(--r-md); }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px var(--brand-ring); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 16px; background: var(--surface); border-right: 1px solid var(--line); z-index: 40; overflow-y: auto; }
.content { min-width: 0; }
main { max-width: 1240px; margin: 0 auto; padding: 6px 32px 56px; }

.brand-row { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.logo { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 18px; flex: none; }
.logo.big.has-img { display: block; width: auto; height: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 16px; }
.logo.big img { display: block; height: 40px; width: auto; max-width: 220px; }
.logo.big { width: 52px; height: 52px; font-size: 22px; border-radius: var(--r-lg); margin-bottom: 22px; }
.brand-text b { display: block; font-size: 16px; font-weight: 900; text-transform: uppercase; letter-spacing: 0; line-height: 1.2; }
.brand-text small { color: var(--text-3); font-size: 12px; font-weight: 550; }

/* navigation */
.nav-label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); padding: 18px 12px 8px; }
.tab { width: 100%; justify-content: flex-start; gap: 12px; border: 0; background: transparent; color: var(--text-2); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px; min-height: 42px; border-radius: var(--r-md); position: relative; text-align: left; }
.tab .t { flex: 1; }
.tab .ico { display: grid; place-items: center; font-size: 19px; color: var(--text-3); transition: color 0.15s; }
.tab:hover { background: var(--sunken); border: 0; }
.tab:hover .ico { color: var(--text); }
.tab.on { color: var(--brand); background: var(--brand-soft); }
.tab.on .ico { color: var(--brand); }
.tab.on { box-shadow: inset 0 0 0 1px var(--brand); }
.tab.on::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 2px 2px 0; background: var(--brand); }
.count { min-width: 24px; padding: 1px 8px; border-radius: 99px; background: var(--sunken); color: var(--text-2); font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.tab.on .count { background: var(--surface); color: var(--brand); }
.tab.hot .count { background: var(--warn-soft); color: var(--warn); animation: nudge 2.6s ease-in-out infinite; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
button.ghost { justify-content: flex-start; gap: 12px; border: 0; background: transparent; color: var(--text-2); padding: 9px 12px; border-radius: var(--r-md); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
button.ghost:hover { background: var(--sunken); border: 0; color: var(--text); }
button.ghost .ico { font-size: 19px; display: grid; place-items: center; }

/* page header */
.page-head { display: flex; align-items: center; gap: 14px; padding: 30px 32px 22px; max-width: 1240px; margin: 0 auto; }
.page-head { border-bottom: 1px solid var(--line); max-width: none; padding-bottom: 20px; margin-bottom: 24px; }
.page-head h1 { font-size: 24px; font-weight: 900; }
.page-head .titles p { margin-top: 4px; font-size: 14.5px; }
.menu-btn { display: none; }

/* ---------- Cards, stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card .sub { color: var(--text-3); font-size: 14px; margin-bottom: 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
h3 { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin: 24px 0 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; transition: border-color 0.15s; animation: rise 0.45s var(--ease) both; }
.stat:hover { border-color: var(--brand); }
.stat .chip-ico { width: 38px; height: 38px; border-radius: var(--r-md); border: 1px solid var(--line); display: grid; place-items: center; font-size: 19px; margin-bottom: 14px; background: var(--brand-soft); color: var(--brand); }
.stat.tone-ok .chip-ico { background: var(--ok-soft); color: var(--ok); }
.stat.tone-warn .chip-ico { background: var(--warn-soft); color: var(--warn); }
.stat.tone-danger .chip-ico { background: var(--danger-soft); color: var(--danger); }
.stat.tone-info .chip-ico { background: var(--info-soft); color: var(--info); }
.stat small { display: block; color: var(--text-3); font-size: 13px; font-weight: 600; }
.stat b { display: block; font-size: 26px; font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat i { font-style: normal; color: var(--text-3); font-size: 12.5px; display: block; margin-top: 2px; }
.stats .stat:nth-child(2) { animation-delay: 0.04s; } .stats .stat:nth-child(3) { animation-delay: 0.08s; } .stats .stat:nth-child(4) { animation-delay: 0.12s; }

/* ---------- Toolbar & tables ---------- */
.toolbar { display: flex; gap: 10px; padding: 16px 18px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box > span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); display: grid; }
.search-box input { margin: 0; padding-left: 40px; background: var(--surface-2); }
.toolbar select { width: auto; margin: 0; min-width: 160px; }
.toolbar .icon-only { min-height: 44px; }
.notice { padding: 12px 18px; font-size: 13.5px; background: #f2f6fd; border-left: 3px solid var(--brand); color: var(--text-2); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 18px; white-space: nowrap; }
th { font-size: 12px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
td { border-bottom: 1px solid var(--line); font-size: 14.5px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; transition: background 0.12s; }
tbody tr.clickable:hover { background: var(--brand-soft); }
tbody tr.clickable:hover .go { transform: translateX(3px); color: var(--brand); }
.order-no { font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.order-no small { display: block; font-weight: 500; font-size: 12.5px; color: var(--text-3); letter-spacing: 0; }
.who { display: flex; align-items: center; gap: 12px; }
.who .nm { line-height: 1.3; } .who small { display: block; color: var(--text-3); font-size: 12.5px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 13px; color: #fff; flex: none; }
.av-0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); } .av-1 { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.av-2 { background: linear-gradient(135deg, #10b981, #0ea5e9); } .av-3 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.av-4 { background: linear-gradient(135deg, #ec4899, #8b5cf6); } .av-5 { background: linear-gradient(135deg, #14b8a6, #22c55e); }
.method { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; }
.money { font-weight: 700; font-variant-numeric: tabular-nums; }
.go { color: var(--text-3); display: grid; transition: transform 0.15s var(--ease), color 0.15s; }

/* status pills */
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 9px; border-radius: var(--r-sm); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; background: var(--sunken); color: var(--text-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-pending, .b-queued, .b-skipped { background: var(--warn-soft); color: var(--warn); }
.b-paid, .b-completed, .b-sent, .b-delivered { background: var(--ok-soft); color: var(--ok); }
.b-shipped, .b-processing { background: var(--info-soft); color: var(--info); }
.b-cancelled, .b-refunded, .b-failed { background: var(--danger-soft); color: var(--danger); }

.empty { text-align: center; padding: 64px 24px; }
.empty-art { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: var(--r-lg); display: grid; place-items: center; font-size: 32px; background: var(--brand-soft); color: var(--brand); }
.empty b { display: block; font-size: 17px; margin-bottom: 4px; }
.empty-inline { padding: 28px; text-align: center; color: var(--text-3); }

/* ---------- Forms, misc ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.toolbar-range { display: flex; margin-bottom: 20px; }
.toolbar-range select { width: auto; margin: 0; min-width: 170px; }
label.inline { display: flex; gap: 12px; align-items: center; color: var(--text); font-weight: 500; font-size: 14.5px; margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
label.inline:last-of-type { border-bottom: 0; }
label.inline input:not(.switch) { margin: 0; width: auto; }
label.inline input[type=checkbox]:not(.switch) { width: 18px; height: 18px; accent-color: var(--brand); }
.msg { min-height: 1.3em; font-size: 14px; font-weight: 550; }
.msg.err { color: var(--danger); } .msg.ok { color: var(--ok); }
.callout { display: flex; gap: 14px; border-radius: var(--r-sm); padding: 16px 18px; margin: 18px 0; background: #f2f6fd; border: 1px solid #dfe6f3; border-left: 3px solid var(--brand); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout > .ci { font-size: 22px; color: var(--brand); display: grid; }
.callout.warn > .ci { color: var(--warn); }
.callout p { color: var(--text-2); font-size: 14px; }
.mono { font-family: var(--font-mono); font-size: 13px; line-height: 1.7; word-break: break-all; background: var(--sunken); padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); }
pre.mono { white-space: pre-wrap; margin: 0; }

/* ---------- Charts ---------- */
.chart { position: relative; display: flex; align-items: flex-end; gap: 4px; height: 190px; padding: 12px 0 0; border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0, transparent 46px, var(--line) 46px, var(--line) 47px); }
.chart div { position: relative; flex: 1; min-height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); opacity: 0.85; transition: opacity 0.15s, transform 0.2s var(--ease); transform-origin: bottom; animation: grow 0.6s var(--ease) both; }
.chart div:hover { opacity: 1; transform: scaleY(1.03); z-index: 2; }
.chart div::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px); white-space: nowrap; background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; }
.chart div:hover::after { opacity: 1; transform: translateX(-50%); }
.axis { display: flex; justify-content: space-between; color: var(--text-3); font-size: 12px; margin-top: 8px; font-weight: 550; }
.meter { height: 8px; background: var(--sunken); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.meter-row { margin-bottom: 14px; }
.meter-row .top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 550; }
.meter-row .top span:last-child { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- Order drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; background: rgba(15, 23, 42, 0.45); animation: fade 0.2s ease both; }
.drawer { width: min(640px, 100%); height: 100%; overflow-y: auto; background: var(--bg); padding: 0 0 40px; border-left: 1px solid var(--line); animation: slide 0.35s var(--ease) both; }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 22px 28px 18px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; }
.drawer-head .meta { color: var(--text-3); font-size: 13.5px; margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.drawer-body { padding: 22px 28px 0; display: grid; gap: 16px; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; }
.block h3 { margin: 0 0 12px; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.line:last-child { border-bottom: 0; }
.line.sum { font-weight: 750; font-size: 16px; border-top: 1px solid var(--line); border-bottom: 0; margin-top: 4px; padding-top: 12px; }
.line small { color: var(--text-3); }
.address { line-height: 1.6; color: var(--text-2); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }
.timeline li:first-child::before { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.timeline b { font-weight: 600; font-size: 14.5px; display: block; }
.timeline small { color: var(--text-3); font-size: 12.5px; }

/* ---------- Settings ---------- */
.payment-method { display: grid; grid-template-columns: auto 1fr 1.6fr 1.1fr auto; gap: 10px; align-items: center; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.payment-method input:not(.switch), .payment-method select { margin: 0; }
.secret { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.secret .mono { flex: 1; min-width: 200px; display: flex; align-items: center; }

/* ---------- Sign-in ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { position: relative; overflow: hidden; background: var(--brand); color: #fff; display: flex; align-items: flex-end; padding: 64px; }
.orb { position: absolute; border-radius: 50%; filter: blur(2px); opacity: 0.5; }
.orb.o1 { width: 420px; height: 420px; right: -120px; top: -100px; background: radial-gradient(circle at 30% 30%, #ffffff55, transparent 65%); animation: float 9s ease-in-out infinite; }
.orb.o2 { width: 320px; height: 320px; left: -80px; bottom: 30%; background: radial-gradient(circle at 60% 40%, #ffd1ff66, transparent 65%); animation: float 11s ease-in-out infinite reverse; }
.login-copy { position: relative; max-width: 420px; }
.login-copy h2 { font-size: 44px; line-height: 1.08; font-weight: 900; letter-spacing: -0.01em; margin-bottom: 16px; }
.login-copy p { font-size: 17px; opacity: 0.85; }
.login-card { align-self: center; justify-self: center; width: min(400px, calc(100% - 48px)); padding: 24px 0; }
.login-card h1 { font-size: 30px; margin-bottom: 6px; }
.login-card .muted { margin-bottom: 26px; }
.login-card .msg { margin: 0 0 12px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; }
.toast { display: flex; align-items: center; gap: 12px; min-width: 240px; max-width: 360px; padding: 13px 16px; border-radius: var(--r-md); background: var(--text); color: var(--surface); font-weight: 700; font-size: 14px; animation: toast-in 0.35s var(--ease) both; }
.toast.out { animation: toast-out 0.25s ease both; }
.toast .ti { display: grid; font-size: 20px; color: #3ddba3; }
.toast.err .ti { color: #ff7a90; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes float { 50% { transform: translateY(26px) translateX(12px); } }
@keyframes nudge { 0%, 88%, 100% { transform: none; } 92% { transform: scale(1.18); } 96% { transform: scale(0.96); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

ol.steps { margin: 18px 0 12px; padding-left: 22px; display: grid; gap: 12px; color: var(--text-2); font-size: 14px; }
ol.steps li::marker { color: var(--brand); font-weight: 700; }
ol.steps .secret { margin-top: 8px; }
.nav-link-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; align-items: center; margin-bottom: 10px; }
.nav-link-row input { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-102%); transition: transform 0.3s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(8, 10, 24, 0.5); z-index: 30; backdrop-filter: blur(2px); }
  .menu-btn { display: inline-flex; }
  .page-head, main { padding-left: 18px; padding-right: 18px; }
  .page-head { padding-top: 22px; }
  .tab.on::before { left: -14px; }
}
@media (max-width: 720px) {
  .nav-link-row { grid-template-columns: 1fr auto; }
  .nav-link-row input:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .grid2, .two { grid-template-columns: 1fr; }
  .payment-method { grid-template-columns: auto 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .drawer-head, .drawer-body { padding-left: 18px; padding-right: 18px; }
  .page-head h1 { font-size: 23px; }
}

/* sidebar logo image (when a logo URL is set in Settings → Branding) */
.logo img { display: block; height: 34px; width: auto; max-width: 100%; }
.brand-row.has-logo { flex-direction: column; align-items: flex-start; gap: 8px; }
.brand-row.has-logo .logo { width: auto; height: auto; background: #fff; border: 1px solid var(--line); padding: 6px 10px; }
.brand-row.has-logo .brand-text b { display: none; }

/* store switcher (shown when more than one store is connected) */
.store-pill { display: inline-block; padding: 2px 8px; border-radius: var(--r-sm); background: var(--sunken); color: var(--text-2); font-size: 12px; font-weight: 700; }
#view-stores .nm small, #view-stores .order-no small { display: block; }

/* per-store vs shared setting labels */
.scope { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: var(--r-sm); font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: middle; }
.scope.own { background: var(--sunken); color: var(--text-2); }
.scope.shared { background: #e6f4ea; color: #0f7a3d; }
