:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f7faff;
  --line: #dbe5f4;
  --text: #071326;
  --muted: #637089;
  --blue: #1f64c8;
  --blue-dark: #0a2d64;
  --navy: #061936;
  --gold: #d7a33c;
  --gold-soft: #fff4d8;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 22px 60px rgba(6, 25, 54, 0.10);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(31, 100, 200, 0.10), transparent 28%),
    linear-gradient(135deg, #f8fbff 0%, #eef4fc 100%);
  color: var(--text);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(480px, 100%);
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-block, .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-block img, .sidebar-brand img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px;
}
.brand-block h1, .brand-block p { margin: 0; }
.brand-block h1 { font-size: 28px; color: var(--navy); }
.brand-block p { color: var(--muted); margin-top: 6px; }
.login-form { margin-top: 30px; display: grid; gap: 16px; }
label { display: grid; gap: 8px; color: var(--muted); font-weight: 800; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  transition: 0.2s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(31, 100, 200, 0.55);
  box-shadow: 0 0 0 4px rgba(31, 100, 200, 0.10);
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 900;
  color: var(--navy);
  background: #eef4ff;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; transform: none; }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 12px 26px rgba(31,100,200,.25); }
.btn.gold { color: var(--navy); background: linear-gradient(135deg, #ffe7a5, var(--gold)); }
.btn.ghost { background: #f2f6fd; color: var(--blue-dark); border: 1px solid var(--line); }
.btn.danger { color: var(--red); background: var(--red-soft); }
.full { width: 100%; }
.form-error { color: var(--red); margin: 4px 0 0; min-height: 22px; font-weight: 800; }

.app-shell { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(255,255,255,0.95);
  border-left: 1px solid var(--line);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand strong { display: block; color: var(--navy); font-size: 20px; }
.sidebar-brand span { color: var(--muted); font-size: 13px; }
.side-nav { display: grid; gap: 12px; }
.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  text-align: right;
  padding: 15px 18px;
  border-radius: 18px;
}
.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  box-shadow: 0 12px 26px rgba(31,100,200,.23);
}
.sidebar-status {
  margin-top: auto;
  display: grid;
  gap: 10px;
}
.sidebar-status div {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}
.sidebar-status span { display: block; color: var(--muted); font-size: 13px; }
.sidebar-status strong { display: block; margin-top: 4px; color: var(--navy); }

.content-area { min-width: 0; }
.topbar {
  min-height: 96px;
  background: rgba(255,255,255,0.80);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 30px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-copy { min-width: 240px; }
.topbar h2 { margin: 0; color: var(--navy); font-size: 30px; }
.topbar p { margin: 6px 0 0; color: var(--muted); line-height: 1.6; }
.icon-btn {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 16px;
  color: var(--navy);
  font-size: 24px;
}
.top-actions {
  margin-right: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.top-actions input { width: min(410px, 34vw); background: #fff; }

.global-warning {
  margin: 18px 30px 0;
  border: 1px solid #ffd99a;
  background: var(--gold-soft);
  color: #6f4700;
  border-radius: 20px;
  padding: 16px 18px;
  font-weight: 900;
}
.page-view { padding-bottom: 34px; }

.quick-metrics, .stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  padding: 24px 30px 10px;
}
.quick-card, .stat-card {
  background: rgba(255,255,255,.90);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 12px 35px rgba(6,25,54,.06);
}
.quick-card span, .stat-card span { color: var(--muted); font-weight: 900; }
.quick-card strong, .stat-card strong { display: block; margin-top: 10px; font-size: 34px; color: var(--blue-dark); }
.quick-card.accent strong, .stat-card.accent strong { color: #8a5e00; }
.stat-card.large { grid-column: span 2; }
.stat-card small { display:block; color: var(--muted); margin-top: 8px; line-height: 1.6; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 30px 4px;
}
.filter-chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  color: var(--blue-dark);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 900;
}
.filter-chip.active {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  border-color: transparent;
}

.orders-section, .stats-panel {
  margin: 20px 30px 0;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}
.section-head.compact { padding: 18px 20px; }
.section-head h3 { margin: 0; color: var(--navy); }
.section-head p { margin: 6px 0 0; color: var(--muted); }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue-dark);
  font-weight: 900;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.gold { background: var(--gold-soft); color: #704a00; border-color: #f4d18a; }
.chip.red { background: var(--red-soft); color: var(--red); border-color: #ffd1ca; }

.orders-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 16px;
}
.order-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 24px;
  padding: 18px;
  transition: .18s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.order-card:hover { border-color: rgba(31,100,200,.45); box-shadow: 0 12px 26px rgba(6,25,54,.06); }
.order-card-head { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
.order-number { font-weight: 900; color: var(--navy); font-size: 19px; }
.order-meta { color: var(--muted); margin-top: 8px; font-size: 13px; display:grid; gap:4px; line-height: 1.5; }
.order-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 15px;
}
.order-total-row span { color: var(--muted); font-weight: 900; }
.order-total-row strong { color: var(--navy); font-size: 18px; }
.products-list { display: grid; gap: 10px; }
.product-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.3fr) minmax(110px, .9fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: #fff;
}
.product-main strong { display:block; color: var(--navy); margin-bottom: 5px; }
.product-main span, .product-stock span { display:block; color: var(--muted); font-size: 12px; line-height: 1.6; font-weight: 800; }
.muted-row { color: var(--muted); font-weight: 900; }
.issue-box, .ok-box {
  display: grid;
  gap: 8px;
  border-radius: 18px;
  padding: 12px;
  font-weight: 900;
  line-height: 1.7;
}
.issue-box { color: var(--red); background: var(--red-soft); border: 1px solid #ffd1ca; }
.ok-box { color: var(--blue-dark); background: #eef4ff; border: 1px solid #cfe0ff; }
.notes-block {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 13px;
  background: #fbfdff;
}
.notes-block span { color: var(--muted); font-size: 12px; font-weight: 900; }
.notes-block p { margin: 6px 0 0; line-height: 1.8; color: var(--text); white-space: pre-wrap; }
.order-actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:auto; }
.order-actions .btn { flex: 1; min-width: 140px; }
.empty-state {
  padding: 44px 20px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
  grid-column: 1 / -1;
}
.empty-state.small { padding: 24px; }

.stats-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 10px 30px 30px;
}
.stats-panel { margin: 0; }
.mini-list { padding: 14px; display: grid; gap: 10px; }
.mini-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  padding: 13px;
}
.mini-item strong { display:block; color: var(--navy); margin-bottom: 5px; }
.mini-item span { display:block; color: var(--muted); font-size: 13px; line-height: 1.6; font-weight: 800; }

.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 60;
  background: var(--navy);
  color: #fff;
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  max-width: 380px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events:none;
  transition: .2s ease;
  font-weight: 900;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.toast.gold { color: var(--navy); background: var(--gold); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6,25,54,.45);
  z-index: 50;
  display:grid;
  place-items:center;
  padding: 20px;
}
.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 26px;
  padding: 24px;
  box-shadow: var(--shadow);
  border:1px solid var(--line);
}
.modal-card h3 { margin:0; color:var(--navy); }
.modal-card p { color: var(--muted); line-height: 1.8; }
.modal-actions { display:flex; justify-content:flex-start; gap:10px; margin-top:18px; }

.sidebar-collapsed .app-shell { grid-template-columns: 0 1fr; }
.sidebar-collapsed .sidebar { transform: translateX(100%); width: 0; padding: 0; overflow: hidden; border: 0; }

@media (max-width: 1180px) {
  .orders-grid { grid-template-columns: 1fr; }
  .stats-panels { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: 0; z-index: 30; width: 300px; transform: translateX(0); transition:.2s ease; }
  body.sidebar-collapsed .sidebar { transform: translateX(105%); width: 300px; padding: 28px 20px; border-left:1px solid var(--line); }
  .quick-metrics, .stats-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .stat-card.large { grid-column: span 2; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 14px; }
  .top-actions { width:100%; margin-right:0; }
  .top-actions input { width:100%; }
  .quick-metrics, .stats-grid { grid-template-columns: 1fr; padding: 16px; }
  .stat-card.large { grid-column: auto; }
  .filter-bar { padding: 8px 16px; }
  .orders-section, .stats-panel { margin: 16px; }
  .stats-panels { padding: 0 16px 20px; }
  .orders-grid { padding: 14px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .product-row { grid-template-columns: 1fr; }
}

.orders-only-section {
  margin-top: 28px;
}

.stats-note {
  margin: 24px 30px 4px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: 0 12px 35px rgba(6,25,54,.06);
}
.stats-note strong {
  display: block;
  color: var(--navy);
  font-size: 20px;
  margin-bottom: 6px;
}
.stats-note span {
  display: inline-flex;
  color: #704a00;
  background: var(--gold-soft);
  border: 1px solid #f4d18a;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 900;
  margin-bottom: 10px;
}
.stats-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  font-weight: 800;
}

@media (max-width: 720px) {
  .stats-note { margin: 16px; }
  .orders-only-section { margin-top: 16px; }
}

.clickable-stat {
  text-align: right;
  border: 1px solid var(--line);
  appearance: none;
  cursor: pointer;
}
.clickable-stat:hover {
  border-color: rgba(31, 100, 200, 0.55);
  box-shadow: 0 16px 38px rgba(31,100,200,.10);
  transform: translateY(-2px);
}
.clickable-stat small {
  color: var(--muted);
  font-weight: 800;
}
.detail-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.panel-action-body {
  padding: 18px;
  display: grid;
  gap: 14px;
}
.panel-action-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  font-weight: 800;
}
.customers-grid {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}
.customer-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 24px;
  padding: 18px;
  display: grid;
  gap: 14px;
}
.customer-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.customer-card-head strong {
  display: block;
  color: var(--navy);
  font-size: 18px;
}
.customer-card-head span:not(.chip) {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
}
.customer-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}
.customer-info-grid div {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 16px;
  padding: 12px;
}
.customer-info-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 5px;
}
.customer-info-grid strong {
  display: block;
  color: var(--navy);
  overflow-wrap: anywhere;
}
@media (max-width: 720px) {
  .customers-grid, .customer-info-grid { grid-template-columns: 1fr; }
  .detail-head-actions { width: 100%; }
  .detail-head-actions .btn, .detail-head-actions .chip { width: 100%; }
}
