/* SWAN Admin — colors follow app/src/main/java/ru/hud/market/ui/theme/Theme.kt */
:root {
  color-scheme: light;
  --bg: #f5fbf8;
  --surface: #ffffff;
  --surface-2: #e5f4ee;
  --text: #17342d;
  --text-2: #52746a;
  --outline: #c9ddd5;
  --brand: #168b72;
  /* Darker than --brand so white button text and links reach 4.5:1. */
  --primary: #0f735e;
  --on-primary: #ffffff;
  --primary-soft: #dcf1e9;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --focus: #0f735e;
  --shadow: 0 1px 2px rgba(16, 52, 45, .06), 0 4px 16px rgba(16, 52, 45, .06);

  --st-created-bg: #fff2cc; --st-created: #7a4b00;
  --st-assembling-bg: #e3edff; --st-assembling: #1e4fa8;
  --st-ready-bg: #d9f2e9; --st-ready: #0f6b57;
  --st-completed-bg: #e9eeec; --st-completed: #44524e;
  --st-cancelled-bg: #fde8e6; --st-cancelled: #a12a2a;

  --radius: 16px;
  --radius-sm: 10px;
  --dur: 180ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --nav-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101e1b;
  --surface: #172a25;
  --surface-2: #203832;
  --text: #eaf7f2;
  --text-2: #b5d2c8;
  --outline: #2f4c44;
  --brand: #80d8bf;
  --primary: #80d8bf;
  --on-primary: #0d2d27;
  --primary-soft: #1f4038;
  --danger: #f59a90;
  --danger-soft: #3d1f1c;
  --focus: #a7e3d3;
  --shadow: none;

  --st-created-bg: #3a2e12; --st-created: #f5d48a;
  --st-assembling-bg: #1b2a44; --st-assembling: #a9c6ff;
  --st-ready-bg: #173a31; --st-ready: #8fe0c6;
  --st-completed-bg: #26302d; --st-completed: #c3cfcb;
  --st-cancelled-bg: #3d1d1d; --st-cancelled: #f3aaaa;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 15px; letter-spacing: .02em; }
.muted { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--primary); color: var(--on-primary); border-radius: 8px; }
.skip-link:focus { top: 8px; }

/* ---------- Layout ---------- */
.app { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--outline);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand-name { font-weight: 700; letter-spacing: .08em; }
.brand-sub { font-size: 13px; color: var(--text-2); display: block; line-height: 1.2; letter-spacing: 0; font-weight: 500; }

main { padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); max-width: 1100px; margin: 0 auto; }
.page-title { font-size: 26px; line-height: 1.25; font-weight: 700; margin: 4px 0 16px; }
/* Headings receive focus only so screen readers announce the new screen; no visible ring needed. */
[tabindex="-1"]:focus { outline: none; }
.section-title { font-size: 18px; font-weight: 600; margin: 24px 0 12px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--outline);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); padding: 6px 4px;
  color: var(--text-2); text-decoration: none; font-size: 12px; font-weight: 500;
  position: relative;
}
.nav-item[aria-current="page"] { color: var(--primary); font-weight: 600; }
.nav-item[aria-current="page"] .nav-pill { background: var(--primary-soft); }
.nav-pill { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; transition: background var(--dur) var(--ease); }

@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .bottom-nav {
    position: sticky; top: 64px; align-self: start;
    display: flex; flex-direction: column; gap: 4px;
    height: calc(100dvh - 64px); padding: 16px 12px;
    border-top: 0; border-right: 1px solid var(--outline); background: var(--bg);
  }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 12px; font-size: 15px; }
  .nav-item[aria-current="page"] { background: var(--primary-soft); }
  .nav-pill { width: auto; height: auto; background: none !important; }
  main { padding: 24px 32px 48px; width: 100%; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 14px;
  background: var(--primary); color: var(--on-primary);
  font-weight: 600; font-size: 16px;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--outline); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--outline)); }
.btn-block { width: 100%; }
.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--outline); background: var(--surface); color: var(--text);
}
.icon-btn:active { transform: scale(.94); }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards & lists ---------- */
.card { background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.list { display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start;
  width: 100%; padding: 14px 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius);
  color: inherit; text-decoration: none;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
a.row:active, button.row:active { transform: scale(.985); }
a.row:hover, button.row:hover { border-color: var(--brand); }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-meta { font-size: 14px; color: var(--text-2); overflow-wrap: anywhere; }
.row-side { text-align: right; display: grid; gap: 6px; justify-items: end; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 16px; display: grid; gap: 4px; }
.stat-label { font-size: 14px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 13px; color: var(--text-2); }
.stat-accent .stat-value { color: var(--primary); }

.event { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; }
.event-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.event-icon.warn { background: var(--st-created-bg); color: var(--st-created); }

/* ---------- Status chips ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap; line-height: 22px;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-created { background: var(--st-created-bg); color: var(--st-created); }
.status-assembling { background: var(--st-assembling-bg); color: var(--st-assembling); }
.status-ready { background: var(--st-ready-bg); color: var(--st-ready); }
.status-completed { background: var(--st-completed-bg); color: var(--st-completed); }
.status-cancelled { background: var(--st-cancelled-bg); color: var(--st-cancelled); }
.tag-missing { background: var(--danger-soft); color: var(--danger); }

/* ---------- Filters ---------- */
.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 768px) { .toolbar { grid-template-columns: 1fr auto; align-items: center; } }
.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); pointer-events: none; }
.input, .select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--outline); border-radius: 14px;
  background: var(--surface); color: var(--text); font-size: 16px;
}
.search .input { padding-left: 46px; }
.input:focus, .select:focus { outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent); border-color: var(--focus); }
.select { width: auto; padding-right: 36px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--outline); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.result-count { font-size: 14px; color: var(--text-2); margin: 0 0 10px; }

/* ---------- States ---------- */
.state { text-align: center; padding: 40px 16px; color: var(--text-2); display: grid; gap: 12px; justify-items: center; }
.state .icon { width: 36px; height: 36px; color: var(--brand); }
.state-title { color: var(--text); font-weight: 600; font-size: 17px; }
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.load-more { margin-top: 14px; }

/* ---------- Order detail ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px 0 0; color: var(--primary); text-decoration: none; font-weight: 600; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 16px; }
.detail-head .page-title { margin: 0; }
.detail-grid { display: grid; gap: 12px; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.kv { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--outline); }
.kv:last-child { border-bottom: 0; }
.kv dt { font-size: 13px; color: var(--text-2); font-weight: 500; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.items { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: 13px; font-weight: 500; color: var(--text-2); padding: 0 0 8px; }
.items td { padding: 10px 0; border-top: 1px solid var(--outline); vertical-align: top; }
.items .r { text-align: right; white-space: nowrap; padding-left: 12px; }
.total-row td { font-weight: 700; font-size: 18px; }
.status-actions { display: grid; gap: 8px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.history li { font-size: 14px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 400px; padding: 28px 24px; }
.login-logo { width: 72px; height: 72px; border-radius: 20px; display: block; margin: 0 auto 12px; }
.login h1 { text-align: center; font-size: 24px; margin: 0 0 4px; }
.login p.lead { text-align: center; margin: 0 0 24px; color: var(--text-2); }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 15px; }
.pw { position: relative; }
.pw .input { padding-right: 52px; }
.pw .icon-btn { position: absolute; right: 2px; top: 2px; border: 0; background: transparent; }
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 16px; border-radius: 12px;
  background: var(--danger-soft); color: var(--danger); font-size: 15px;
}

/* ---------- Dialog & toast ---------- */
dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 20px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(5, 20, 17, .55); }
.dialog-body { padding: 22px 20px 12px; }
.dialog-body h2 { margin: 0 0 6px; font-size: 20px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 8px 20px 20px; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0;
  padding: 12px 18px; border-radius: 12px; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); font-weight: 500;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1024px) { .toast { bottom: 24px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
