:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #d9e2ef;
  --blue: #2457e8;
  --blue-soft: #e8efff;
  --green: #087f5b;
  --amber: #b45309;
  --red: #dc2626;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", Arial, sans-serif;
}

button, input, select { font: inherit; }

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.login-view {
  min-height: calc(100vh - 36px);
  display: grid;
  align-content: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand.compact { gap: 10px; }

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #0f172a;
  color: white;
  font-weight: 900;
  font-size: 28px;
}

.compact .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  font-size: 22px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: 0; }
h2 { font-size: clamp(28px, 7vw, 44px); letter-spacing: 0; }
h3 { font-size: 17px; }

.brand p,
.hero p,
.card span,
.muted {
  color: var(--muted);
}

.panel,
.card,
.hero,
.list,
.alert {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

button {
  border: 0;
  border-radius: 6px;
  min-height: 46px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  background: var(--blue);
  color: white;
}

.primary.small {
  min-height: 40px;
  white-space: nowrap;
}

.ghost {
  background: #fee2e2;
  color: #991b1b;
}

.secondary {
  background: #e8eef6;
  color: #0f172a;
}

.error {
  color: var(--red);
  font-weight: 700;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar h1 { font-size: 24px; }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ffffff 0%, #eef4ff 100%);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
  color: var(--blue);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}

.tab {
  min-height: 40px;
  background: #e8eef6;
  color: #1e293b;
  white-space: nowrap;
}

.tab.active {
  background: #0f172a;
  color: white;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  margin-bottom: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.card {
  padding: 15px;
  min-height: 104px;
}

.card strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
  line-height: 1;
  letter-spacing: 0;
}

.card.good strong { color: var(--green); }
.card.warn strong { color: var(--amber); }
.card.bad strong { color: var(--red); }

.section-title {
  margin: 20px 0 10px;
  font-size: 20px;
}

.alert {
  display: grid;
  gap: 4px;
  padding: 13px;
  margin-bottom: 8px;
  border-left: 5px solid var(--blue);
}

.alert.warning { border-left-color: var(--amber); }
.alert.danger { border-left-color: var(--red); }

.notice-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notice-top span {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.list {
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
}

.row:last-child { border-bottom: 0; }

.row-title {
  font-weight: 850;
  overflow-wrap: anywhere;
}

.row-meta {
  color: var(--muted);
  font-size: 13px;
}

.amount {
  text-align: right;
  font-weight: 900;
  white-space: nowrap;
}

.amount small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.amount.negative { color: var(--red); }
.amount.positive { color: var(--green); }

.branch-card {
  display: grid;
  gap: 11px;
}

.stock-panel {
  margin-top: 18px;
}

.stock-head {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 420px);
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.compact-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini {
  padding: 10px;
  border-radius: 6px;
  background: #f1f5f9;
}

.mini span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.stock-row,
.shift-row,
.cashier-row {
  align-items: start;
}

.product-detail-open {
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.product-detail-open:hover {
  border-color: #9bb7f3;
  background: #f8fbff;
  transform: translateY(-1px);
}

.product-detail {
  margin-top: 14px;
}

.detail-panel {
  padding: 16px;
  display: grid;
  gap: 14px;
  border-color: #b9cced;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.detail-head h3 {
  margin-top: 3px;
  font-size: 22px;
}

.transfer-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.transfer-form p {
  grid-column: 1 / -1;
}

.shift-mini {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

.system-panel {
  padding: 16px;
  margin-top: 14px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.health-grid div {
  min-width: 0;
  padding: 10px;
  border-radius: 6px;
  background: #f1f5f9;
}

.health-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.health-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.password-form,
.telegram-form {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.backup-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(160px, .6fr);
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.backup-form .form-actions,
.backup-form .status-message {
  grid-column: 1 / -1;
}

.backup-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.event-row {
  border-left: 5px solid #94a3b8;
}

.event-row.success {
  border-left-color: var(--green);
}

.event-row.warning {
  border-left-color: var(--amber);
}

.event-row.danger {
  border-left-color: var(--red);
}

.event-row.info {
  border-left-color: var(--blue);
}

.event-details {
  margin-top: 8px;
  color: #334155;
  overflow-wrap: anywhere;
}

.check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-message {
  min-height: 22px;
}

@media (max-width: 760px) {
  .shell { padding: 14px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stock-head { grid-template-columns: 1fr; }
  .transfer-form { grid-template-columns: 1fr 1fr; }
  .transfer-form .primary { grid-column: 1 / -1; }
  .backup-form { grid-template-columns: 1fr; }
  .check-list { grid-template-columns: 1fr; }
  .shift-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { align-items: flex-start; }
}

@media (max-width: 430px) {
  .shell { padding: 12px; }
  .brand-mark { width: 48px; height: 48px; }
  h1 { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .compact-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .hero { display: grid; }
  .row { grid-template-columns: 1fr; }
  .detail-head { display: grid; }
  .transfer-form { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  .amount { text-align: left; }
}
