:root {
  --borg-red: #d62839;
  --borg-space: #121217;
  --borg-white: #f8f7f2;

  --bg: #eceae4;
  --surface: #ffffff;
  --surface-muted: #f7f4ee;
  --line: #dcd6ce;
  --line-soft: #ebe6df;

  --text: #1a1c24;
  --text-muted: #6e7077;

  --success: #178251;
  --warning: #ae7b1d;
  --danger: #b63737;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --shadow: 0 14px 30px rgba(18, 18, 23, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 88% 0%, #ffffff 0%, var(--bg) 58%, #e3dfd8 100%);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-family: 'Barlow Condensed', 'IBM Plex Sans Arabic', sans-serif;
  letter-spacing: 0.015em;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card,
.login-visual {
  padding: 34px;
}

.brand-row p {
  margin-top: 8px;
  color: var(--text-muted);
}

.login-form {
  margin-top: 24px;
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.login-visual {
  background: linear-gradient(160deg, #fff4f5 0%, #f6edea 100%);
  position: relative;
  display: grid;
  align-content: center;
  gap: 12px;
}

.login-visual p {
  color: var(--text-muted);
  line-height: 1.8;
}

.orb {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(214, 40, 57, 0.2), rgba(214, 40, 57, 0));
  top: -50px;
  left: -60px;
}

.alert {
  margin-top: 16px;
  border: 1px solid #efc6cc;
  background: #fff1f3;
  color: #9f2e3a;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 14px;
}

.dashboard-page {
  min-height: 100vh;
  padding: 16px;
}

.dashboard-shell {
  width: min(1720px, 100%);
  margin: 0 auto;
  direction: ltr;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(260px, 22vw, 300px);
  gap: 14px;
}

.workspace {
  direction: rtl;
  min-width: 0;
  display: grid;
  gap: 12px;
}

.workspace-header {
  border: 1px solid var(--line);
  border-top: 5px solid var(--borg-red);
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.kicker {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  font-family: 'Space Mono', monospace;
  margin-bottom: 6px;
}

#page-title {
  font-size: 36px;
  line-height: 1.2;
}

.subtitle {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 14px;
}

.header-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.refresh-label {
  font-size: 12px;
  color: var(--text-muted);
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel-head {
  margin-bottom: 11px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 8px;
}

.panel-head h2 {
  font-size: 21px;
}

.panel-head p {
  color: var(--text-muted);
  font-size: 13px;
}

.panel-head-compact {
  align-items: center;
}

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

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

.kpi-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 11px;
}

.monitor-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 10px;
}

.monitor-key {
  color: var(--text-muted);
  font-size: 12px;
}

.monitor-value {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 800;
  font-family: 'Space Mono', monospace;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 12px;
}

.kpi-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
  font-family: 'Space Mono', monospace;
}

.status-breakdown {
  display: grid;
  gap: 9px;
}

.progress-item {
  display: grid;
  gap: 5px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 12px;
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #ebe6df;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ea6c78, var(--borg-red));
}

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

.panel-wide {
  grid-column: span 2;
}

.daily-trend,
.top-items,
.recent-orders {
  display: grid;
  gap: 8px;
}

.trend-item {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 8px;
}

.trend-date,
.trend-count {
  color: var(--text-muted);
  font-size: 12px;
}

.trend-bar {
  height: 8px;
  border-radius: 999px;
  background: #ece7df;
  overflow: hidden;
}

.trend-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f3acb3, var(--borg-red));
}

.top-item,
.recent-item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 9px 10px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.filter-label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 180px;
}

.table-wrap {
  overflow: auto;
}

.orders-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.orders-table th,
.orders-table td {
  text-align: right;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}

.orders-table th {
  color: var(--text-muted);
  font-weight: 700;
  background: #fbf3f3;
}

.product-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 10px;
}

.product-form textarea,
.product-form button {
  grid-column: span 2;
}

.products-wrap {
  display: grid;
  gap: 8px;
}

.product-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 10px;
}

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

.product-title {
  font-size: 15px;
}

.product-meta {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.card-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.sidebar {
  direction: rtl;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 10px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.brand-card {
  border: 1px solid var(--line-soft);
  border-top: 4px solid var(--borg-red);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, #fffdfb 0%, #f7f1eb 100%);
  padding: 12px;
}

.brand-kicker {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  font-family: 'Space Mono', monospace;
  margin-bottom: 6px;
}

.brand-card h2 {
  font-size: 30px;
  line-height: 1.1;
}

.brand-copy {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 13px;
}

.admin-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 10px 12px;
  display: grid;
  gap: 3px;
}

.admin-card span {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-card strong {
  font-size: 15px;
}

.nav-menu {
  display: grid;
  gap: 7px;
}

.nav-item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
  padding: 10px 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 140ms ease;
}

.nav-item:hover {
  border-color: #e9b7be;
}

.nav-item.is-active {
  background: #fdeced;
  color: var(--borg-red);
  border-color: #efb9c0;
}

.pill {
  min-width: 34px;
  text-align: center;
  border: 1px solid #efd9dc;
  background: #ffffff;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 12px;
  font-family: 'Space Mono', monospace;
}

.side-panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 10px;
}

.side-panel-head {
  margin-bottom: 8px;
}

.side-panel-head h3 {
  font-size: 14px;
}

.order-types,
.status-list {
  display: grid;
  gap: 8px;
}

.type-card,
.status-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.type-label,
.status-item-label {
  color: var(--text-muted);
  font-size: 12px;
}

.type-value,
.status-item-count {
  font-size: 18px;
  font-weight: 800;
  font-family: 'Space Mono', monospace;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
}

.badge.pending {
  background: #fff4de;
  color: var(--warning);
}

.badge.assigned,
.badge.accepted,
.badge.preparing,
.badge.on_the_way {
  background: #e7f6ed;
  color: var(--success);
}

.badge.delivered {
  background: #f5edef;
  color: var(--borg-space);
}

.badge.canceled,
.badge.returned {
  background: #feecee;
  color: var(--danger);
}

.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.mini-btn {
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 140ms ease;
}

.btn-primary {
  background: linear-gradient(135deg, #e03547, #c81f30);
  color: #ffffff;
  padding: 10px 14px;
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 14px;
}

.btn-danger {
  background: #fff1f2;
  border: 1px solid #efc7cc;
  color: var(--danger);
  padding: 10px 14px;
}

.full-width {
  width: 100%;
}

.mini-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 6px 10px;
}

.mini-btn.danger {
  border-color: #edc1c6;
  color: var(--danger);
  background: #fff6f7;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  padding: 10px 11px;
  font-size: 14px;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #e19ea7;
  box-shadow: 0 0 0 3px rgba(214, 40, 57, 0.12);
}

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 14px;
}

@media (max-width: 1400px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 1100px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .workspace-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    justify-items: start;
  }
}

@media (max-width: 900px) {
  .reports-grid {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-column: span 1;
  }

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

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

@media (max-width: 720px) {
  .dashboard-page {
    padding: 10px;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .product-form {
    grid-template-columns: 1fr;
  }

  .product-form textarea,
  .product-form button {
    grid-column: span 1;
  }

  .monitor-grid {
    grid-template-columns: 1fr;
  }
}
