:root,
html[data-theme="light"] {
  --navy: #173f5f;
  --navy-2: #23688f;
  --ink: #17212b;
  --muted: #687685;
  --line: #d7e1e8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --background: #f3f6f8;
  --input: #ffffff;
  --green: #2d8a60;
  --green-soft: #e2f2e9;
  --red: #b44747;
  --red-soft: #f8e4e4;
  --orange: #a5651b;
  --orange-soft: #fff0dd;
  --blue-soft: #e6f0f7;
  --topbar: rgba(23, 63, 95, 0.98);
  --nav-bg: rgba(255, 255, 255, 0.98);
  --shadow: 0 8px 24px rgba(23, 63, 95, 0.09);
  --radius: 18px;
  --login-bg-start: #f8fbfd;
  --login-bg-end: #dceaf3;
  --login-card: #ffffff;
  --login-card-ink: #17212b;
  --login-card-muted: #687685;
  --login-input: #ffffff;
  --login-input-border: #9fb3c0;
  --primary-action: #1e456d;
  color-scheme: light;
}

html[data-theme="dark"] {
  --navy: #1f4f78;
  --navy-2: #8ec7ee;
  --ink: #f1f5f8;
  --muted: #b2bec7;
  --line: #334854;
  --surface: #15191b;
  --surface-2: #1d2225;
  --background: #1b1f21;
  --input: #15191b;
  --green: #65d19b;
  --green-soft: #1d3b2d;
  --red: #d67878;
  --red-soft: #421d1d;
  --orange: #e2a64e;
  --orange-soft: #4c2e05;
  --blue-soft: #1e3344;
  --topbar: rgba(28, 57, 88, 0.98);
  --nav-bg: rgba(20, 23, 25, 0.98);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --login-bg-start: #173f5f;
  --login-bg-end: #0f2b43;
  --login-card: #15191b;
  --login-card-ink: #f4f7f9;
  --login-card-muted: #aeb8bf;
  --login-input: #303537;
  --login-input-border: #405764;
  --primary-action: #1e456d;
  color-scheme: dark;
}

:root {
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; color: var(--ink); background: var(--background); }
body { margin: 0; min-height: 100%; color: var(--ink); background: var(--background); }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(80, 160, 214, 0.35); outline-offset: 2px; }
[hidden] { display: none !important; }

.network-banner {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  text-align: center;
  color: #fff;
  background: #a63f3f;
  font-size: 13px;
  font-weight: 700;
}

.login-screen {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: max(42px, calc(26px + env(safe-area-inset-top))) 24px 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.14), transparent 35%),
    linear-gradient(155deg, var(--login-bg-start), var(--login-bg-end));
}
.login-card {
  width: min(100%, 430px);
  padding: 30px 28px 25px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 35%);
  border-radius: 26px;
  color: var(--login-card-ink);
  background: var(--login-card);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}
.login-logo-wrap {
  width: min(100%, 300px);
  height: 145px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  background: var(--primary-action);
  -webkit-mask: url('/assets/brand-logo.png') center / contain no-repeat;
  mask: url('/assets/brand-logo.png') center / contain no-repeat;
}
.login-logo {
  width: 100%;
  height: 100%;
  opacity: 0;
}
.login-card h1 { margin: 3px 0 8px; text-align: center; font-size: 30px; }
.login-card > .muted { text-align: center; }
.login-card .muted { color: var(--login-card-muted); }
.login-card form { margin-top: 30px; }
.login-card label { display: block; margin-bottom: 12px; font-weight: 700; }
.login-card input {
  width: 100%;
  height: 58px;
  border: 2px solid var(--login-input-border);
  border-radius: 14px;
  padding: 0 16px;
  color: var(--login-card-ink);
  background: var(--login-input);
  text-align: center;
  font-size: 26px;
  letter-spacing: 8px;
}
.login-card .button { margin-top: 16px; }
.form-error { min-height: 20px; margin: 12px 0 0; color: #ee8d8d; text-align: center; font-size: 14px; }

.app-shell { min-height: 100vh; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: calc(58px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  color: #fff;
  background: var(--topbar);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
}
.topbar-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  white-space: nowrap;
}
.topbar h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(17px, 4.5vw, 21px);
  line-height: 1.1;
}
.topbar .eyebrow { flex: 0 0 auto; color: #cfe0ec; font-size: 10px; letter-spacing: 0.08em; }
.topbar-separator { flex: 0 0 auto; color: rgba(255, 255, 255, 0.55); font-weight: 800; }
.connection-status {
  min-height: 20px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #e9f2f7;
  background: rgba(255, 255, 255, 0.08);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #7fd4a4; }
.connection-status.syncing .connection-dot { background: #efc466; animation: connection-pulse 0.9s ease-in-out infinite alternate; }
.connection-status.offline .connection-dot { background: #f08a8a; }
@keyframes connection-pulse { to { opacity: 0.3; transform: scale(0.75); } }
.profile-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}
.app-content { max-width: 860px; margin: 0 auto; padding: 18px 16px 32px; outline: none; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
}
.nav-item {
  min-height: 58px;
  padding: 2px;
  border: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
}
.nav-item span { font-size: 21px; line-height: 1; }
.nav-item.active { color: var(--navy-2); background: var(--surface-2); }

h2 { margin: 0; font-size: 20px; }
p { line-height: 1.45; }
.eyebrow { margin: 0; color: var(--navy-2); font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.muted { margin: 5px 0; color: var(--muted); }
.optional { color: var(--muted); font-size: 12px; font-weight: 400; }

.button {
  min-height: 48px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 800;
  cursor: pointer;
}
.button:disabled { opacity: 0.62; cursor: wait; }
.button.full { width: 100%; }
.button.compact { min-height: 46px; white-space: nowrap; }
.button.primary { color: #fff; background: var(--primary-action); }
.button.secondary { color: var(--ink); border-color: var(--line); background: var(--surface); }
.button.qr-primary { color: #fff; border-color: #1d5f8d; background: linear-gradient(145deg, #2878aa, #1d4f78); }
.button.filter-reset { color: #fff; border-color: #a5651b; background: #a5651b; }
.button.entry-button { color: #fff; background: #387e5a; }
.button.withdrawal-button { color: #fff; background: #a64848; }
.button.danger-outline { color: var(--red); border-color: color-mix(in srgb, var(--red), transparent 45%); background: var(--surface); }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 13px; color: var(--navy-2); background: var(--surface); font-size: 22px; }
.text-button, .back-button { border: 0; color: var(--navy-2); background: transparent; font-weight: 800; }
.back-button { padding: 8px 2px 14px; font-size: 16px; }

.welcome-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.welcome-row h2 { font-size: 24px; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.action-card {
  min-height: 150px;
  border: 0;
  border-radius: var(--radius);
  padding: 20px 15px;
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 7px;
  text-align: left;
  color: #fff;
  box-shadow: var(--shadow);
}
.action-card.withdrawal { background: linear-gradient(145deg, #b65050, #8e3434); }
.action-card.entry { background: linear-gradient(145deg, #4d936d, #2e684c); }
.action-card .action-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: rgba(255, 255, 255, 0.14); font-size: 28px; }
.action-card strong { margin-top: 3px; font-size: 18px; }
.action-card small { opacity: 0.84; }
.owner-note { display: grid; gap: 4px; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; color: var(--navy-2); background: var(--blue-soft); }
.owner-note span { font-size: 13px; }

.section-block, .scanner-card, .filter-card, .table-card, .supplier-card, .selected-article, .movement-form, .filter-panel, .movement-success {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px;
  background: var(--surface);
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.08);
}
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading span { color: var(--muted); font-size: 12px; text-align: right; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric-grid.three { grid-template-columns: repeat(3, 1fr); }
.metric-card { min-height: 92px; padding: 14px; border-radius: 14px; display: grid; align-content: center; gap: 4px; background: var(--surface-2); }
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { font-size: 27px; }
.metric-card.stock { color: var(--navy-2); background: var(--blue-soft); }
.metric-card.good { color: var(--green); background: var(--green-soft); }
.metric-card.warning { color: var(--orange); background: var(--orange-soft); }
.metric-card.danger { color: var(--red); background: var(--red-soft); }
.daily-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.daily-summary > div { padding: 12px 8px; border-radius: 12px; text-align: center; background: var(--surface-2); }
.daily-summary span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.daily-summary strong { display: block; margin-top: 5px; font-size: 22px; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.small-facts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.small-facts span { padding: 6px 9px; border-radius: 20px; color: var(--muted); background: var(--surface-2); font-size: 11px; }
.quick-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-links button { min-height: 64px; border: 1px solid var(--line); border-radius: 14px; color: var(--navy-2); background: var(--surface); font-weight: 800; }
.quick-links button:last-child:nth-child(odd) { grid-column: 1 / -1; }

.stock-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 8px 0 12px; background: var(--background); }
.stock-tools .search-box { grid-column: 1 / -1; }
.stock-tools .button { width: 100%; }
.search-box { min-height: 48px; flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--input); }
.search-box span { color: var(--muted); font-size: 22px; }
.search-box input { width: 100%; height: 44px; border: 0; outline: none; color: var(--ink); background: transparent; }
.result-count { margin: 2px 2px 10px; color: var(--muted); font-size: 12px; }
.article-list { display: grid; gap: 8px; }
.article-row, .order-row {
  width: 100%;
  min-height: 76px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
}
.article-row > div:first-child, .order-row > div:first-child { min-width: 0; display: grid; gap: 4px; }
.article-row strong, .order-row strong { overflow: hidden; text-overflow: ellipsis; }
.article-row span, .order-row span { color: var(--muted); font-size: 11px; }
.stock-badge { min-width: 57px; padding: 7px 8px; border-radius: 11px; display: grid; place-items: center; }
.stock-badge strong { font-size: 19px; }
.stock-badge span { font-size: 9px; text-transform: uppercase; }
.stock-badge.good { color: var(--green); background: var(--green-soft); }
.stock-badge.warning { color: var(--orange); background: var(--orange-soft); }
.stock-badge.danger { color: var(--red); background: var(--red-soft); }

.filter-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filter-panel label, .filter-card label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 800; }
.filter-panel select, .filter-card input, .filter-card select, .history-secondary-filters select, .movement-form select, .movement-form textarea {
  width: 100%;
  min-height: 47px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--input);
}
.check-label { grid-template-columns: auto 1fr !important; align-items: center; justify-content: start; }
.check-label input { width: 20px; height: 20px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 10px; }
.active-filters span { padding: 6px 9px; border-radius: 20px; color: var(--navy-2); background: var(--blue-soft); font-size: 11px; font-weight: 700; }

.order-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 15px; }
.order-summary > div { padding: 14px 11px; border-radius: 16px; color: #fff; background: #1d456d; box-shadow: var(--shadow); }
.order-summary span { display: block; color: #d1e0ea; font-size: 12px; }
.order-summary strong { display: block; margin-top: 5px; font-size: 25px; }
.order-copy-card { margin: 12px 0 14px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; background: var(--surface); box-shadow: var(--shadow); }
.order-copy-card div { min-width: 0; display: grid; gap: 3px; }
.order-copy-card span { color: var(--muted); font-size: 11px; line-height: 1.35; }
.order-copy-card .button { min-width: 120px; }
.supplier-groups { display: grid; gap: 13px; }
.supplier-card { padding: 0; overflow: hidden; }
.supplier-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 16px; color: #fff; background: #1d456d; }
.supplier-heading h2 { font-size: 17px; }
.supplier-heading span { font-size: 11px; }
.supplier-card .order-row { border: 0; border-radius: 0; border-bottom: 1px solid var(--line); }
.supplier-card .order-row:last-child { border-bottom: 0; }
.order-quantity { min-width: 66px; min-height: 50px; padding: 7px 9px; border-radius: 10px; display: grid; align-content: center; gap: 2px; text-align: center; color: var(--orange); background: var(--orange-soft); }
.order-quantity strong { font-size: 16px; }
.order-quantity small { color: var(--muted); font-size: 8px; font-weight: 600; line-height: 1.1; }
.order-quantity.unit-only { min-width: 66px; min-height: 50px; }
.order-quantity.unit-only strong { font-size: 16px; }

.filter-card { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filter-card .button { grid-column: 1 / -1; }
.custom-range { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart { width: 100%; height: 260px; margin-top: 18px; border-radius: 12px; background: var(--surface-2); }
.stats-tables { display: grid; gap: 14px; }
.table-card h2 { margin-bottom: 12px; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
td:last-child, th:last-child { text-align: right; }

.movement-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; padding: 5px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.movement-tabs button { min-height: 45px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 800; }
.movement-tabs button.active { color: #fff; background: #1d456d; }
.history-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.history-search-box { margin-bottom: 12px; }
.history-filter-panel { margin-bottom: 12px; }
.history-filter-panel .button { grid-column: 1 / -1; }
.localized-date-field {
  position: relative;
  min-height: 47px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 42px 10px 12px;
  display: flex;
  align-items: center;
  color: var(--ink);
  background: var(--input);
}
.localized-date-field::after { content: "▣"; position: absolute; right: 13px; color: var(--muted); font-size: 15px; }
.localized-date-field input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.localized-date-field:focus-within { outline: 3px solid rgba(80, 160, 214, 0.35); outline-offset: 2px; }
.history-list { display: grid; gap: 8px; }
.history-row { padding: 13px; border: 1px solid var(--line); border-radius: 14px; display: grid; grid-template-columns: 1fr auto; gap: 10px; background: var(--surface); }
.history-main { min-width: 0; display: grid; gap: 4px; }
.history-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-title-row strong { overflow: hidden; text-overflow: ellipsis; }
.history-title-row b { font-size: 19px; }
.history-row span, .history-row small, .history-row time { color: var(--muted); font-size: 11px; }
.history-row time { white-space: nowrap; text-align: right; }
.history-note { padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }

.scanner-card h2 { margin-bottom: 5px; }
.reader { position: relative; width: 100%; min-height: 270px; margin: 14px 0; overflow: hidden; border-radius: 14px; background: #0e1820; }
.reader video { width: 100%; min-height: 270px; object-fit: cover; display: block; border-radius: 14px; }
.scan-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(66vw, 260px);
  height: min(66vw, 260px);
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.28);
  pointer-events: none;
}
.scanner-status { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.or-divider { display: flex; align-items: center; gap: 12px; margin: 17px 0; color: var(--muted); font-size: 11px; }
.or-divider::before, .or-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.manual-results { margin-top: 8px; display: grid; gap: 5px; }
.manual-results button { min-height: 58px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; display: grid; gap: 3px; text-align: left; color: var(--ink); background: var(--surface); }
.manual-results small { color: var(--muted); }
.selected-article { position: relative; scroll-margin-top: 18px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; border-color: #49748e; background: var(--blue-soft); }
.selected-article h2 { margin: 3px 0; }
.selected-article p { margin: 2px 0; }
.selected-stock { min-width: 70px; display: grid; justify-items: center; }
.selected-stock span { color: var(--muted); font-size: 11px; }
.selected-stock strong { color: var(--navy-2); font-size: 31px; }
.selected-article .text-button { grid-column: 1 / -1; justify-self: start; padding: 5px 0; }
.movement-form { display: grid; gap: 16px; }
.movement-form label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 800; }
.quantity-control { display: grid; grid-template-columns: 52px 1fr 52px; gap: 7px; }
.quantity-control button { border: 1px solid var(--line); border-radius: 12px; color: var(--navy-2); background: var(--blue-soft); font-size: 26px; }
.quantity-control input { width: 100%; min-height: 54px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--input); text-align: center; font-size: 24px; font-weight: 800; }
.quick-quantity { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: -8px; }
.quick-quantity button { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; color: var(--navy-2); background: var(--surface); font-weight: 800; }
.movement-success { text-align: center; }
.success-icon { width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #37825d; font-size: 30px; font-weight: 800; }
.movement-success p { color: var(--muted); }
.success-article { margin-bottom: 10px; }
.success-stock-flow { width: min(100%, 420px); margin: 0 auto; border: 1px solid var(--line); border-radius: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; background: var(--surface-2); }
.success-stock-item { min-width: 0; padding: 11px 8px; display: grid; gap: 3px; align-content: center; justify-items: center; }
.success-stock-item + .success-stock-item { border-left: 1px solid var(--line); }
.success-stock-item span { color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1.15; white-space: nowrap; }
.success-stock-item strong { color: var(--ink); font-size: 25px; line-height: 1; }
.success-stock-item.movement-change.positive strong { color: var(--green); }
.success-stock-item.movement-change.negative strong { color: var(--red); }
.success-stock-item.movement-change.neutral strong { color: var(--muted); }
.success-stock-item.current-stock strong { color: var(--navy-2); }
.success-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 17px; }

.dialog { width: min(calc(100% - 28px), 520px); max-height: calc(100vh - 36px); overflow: auto; border: 1px solid var(--line); border-radius: 22px; padding: 25px 21px 21px; color: var(--ink); background: var(--surface); box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4); }
.dialog::backdrop { background: rgba(7, 18, 27, 0.68); backdrop-filter: blur(3px); }
.dialog form { margin: 0; }
.dialog-close { position: absolute; top: 10px; right: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: var(--surface-2); font-size: 25px; }
.small-dialog { width: min(calc(100% - 38px), 390px); }
.small-dialog h2 { margin: 8px 0; }
.small-dialog .button { margin-top: 10px; }
.role-pill { display: inline-block; margin: 0 0 15px; padding: 7px 10px; border-radius: 20px; color: var(--navy-2); background: var(--blue-soft); font-size: 12px; font-weight: 800; }
.theme-fieldset { margin: 2px 0 16px; padding: 0; border: 0; }
.theme-fieldset legend { margin-bottom: 8px; font-size: 12px; font-weight: 800; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 5px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.theme-options button { min-height: 41px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 800; }
.theme-options button.active { color: #fff; background: #1d456d; }
.article-stock-hero { margin: 18px 0 13px; padding: 17px; border-radius: 15px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: #1d456d; }
.article-stock-hero strong { font-size: 35px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.detail-grid div { padding: 11px; border-radius: 11px; background: var(--surface-2); }
.detail-grid dt { color: var(--muted); font-size: 11px; }
.detail-grid dd { margin: 3px 0 0; font-weight: 800; }
.state-line { color: var(--muted); font-size: 13px; }

.loading, .empty-state { min-height: 250px; display: grid; place-items: center; align-content: center; gap: 12px; text-align: center; color: var(--muted); }
.loading p, .empty-state p { margin: 0; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--navy-2); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-inline { padding: 22px; border: 1px dashed var(--line); border-radius: 14px; text-align: center; color: var(--muted); }
.empty-inline.error { color: var(--red); border-color: color-mix(in srgb, var(--red), transparent 45%); background: var(--red-soft); }
.toast { position: fixed; z-index: 1001; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); width: min(calc(100% - 32px), 460px); transform: translateX(-50%); padding: 14px 16px; border-radius: 13px; color: #fff; background: #263b4b; text-align: center; font-weight: 700; box-shadow: var(--shadow); }
.toast.error { background: #a63f3f; }

@media (min-width: 700px) {
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-grid.three { grid-template-columns: repeat(3, 1fr); }
  .stats-tables { grid-template-columns: repeat(2, 1fr); }
  .stats-tables .table-card:last-child { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .stock-tools { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 390px) {
  .app-content { padding-left: 12px; padding-right: 12px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .metric-grid.three { grid-template-columns: 1fr; }
  .metric-grid.three .metric-card { min-height: 70px; display: flex; align-items: center; justify-content: space-between; }
  .action-card { min-height: 137px; }
  .filter-card, .filter-panel { grid-template-columns: 1fr; }
  .filter-card .button, .custom-range { grid-column: auto; }
  .custom-range { grid-template-columns: 1fr; }
  .success-actions { grid-template-columns: 1fr; }
  .order-copy-card { grid-template-columns: 1fr; }
  .order-copy-card .button { width: 100%; }
  .nav-item { font-size: 9px; }
}

.history-actions .button { grid-column: auto; }
