:root {
  --sidebar: #160e0b;
  --sidebar-soft: #2c2118;
  --cream: #fff8ec;
  --paper: #fffdf8;
  --line: #d8d2c8;
  --ink: #1f1712;
  --muted: #6f675f;
  --green: #3f6659;
  --green-2: #6c8d59;
  --gold: #b9853d;
  --danger: #b44d32;
  --shadow: 0 10px 26px rgba(44, 31, 20, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: var(--cream);
  font-size: 15px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; border: 0; }

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(100deg, rgba(22,14,11,.96), rgba(63,102,89,.9)),
    var(--cream);
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(460px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 22px 70px rgba(0,0,0,.25);
}
.login-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.login-title span {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #efe2ca;
  color: var(--green);
  font-size: 23px;
}
.login-title h1 { margin: 0; font-size: 28px; line-height: 1; }
.login-title p { margin: 5px 0 0; color: var(--muted); font-size: 14px; font-family: Arial, sans-serif; }
.login-card label, .crud-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
  font-family: Arial, sans-serif;
}
.login-card input, .crud-form input, .crud-form select, .crud-form textarea, .table-tools input, .table-tools select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 8px 10px;
  outline-color: var(--gold);
  font-family: Arial, sans-serif;
}
.primary-btn, .secondary-btn {
  min-height: 36px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border-radius: 4px;
  background: var(--green);
  color: white;
  font-family: Arial, sans-serif;
  font-weight: 700;
  font-size: 12px;
}
.primary-btn { width: 100%; min-height: 42px; font-size: 15px; }
.form-message { min-height: 18px; color: var(--danger); font-family: Arial, sans-serif; font-weight: 700; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 238px;
  padding: 20px 14px;
  background: var(--sidebar);
  color: #f7ead5;
  overflow: auto;
}
.admin-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 18px;
}
.admin-logo span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: #f5d9aa;
  font-size: 21px;
}
.admin-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--gold);
}
.admin-logo h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1;
  color: #fff4df;
}
.admin-logo small {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: .18em;
  color: var(--gold);
  font-family: Arial, sans-serif;
}
.divider {
  border-top: 1px solid rgba(255,255,255,.14);
  margin-bottom: 16px;
}
.sidebar nav { display: grid; gap: 10px; }
.nav-label { display: none; }
.nav-item {
  min-height: 45px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: #efe2ca;
  text-align: left;
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: 800;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.order-badge {
  margin-left: auto;
  min-width: 23px;
  height: 23px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.nav-item.active, .nav-item:hover {
  background: var(--sidebar-soft);
  color: #fff;
}
.sidebar-actions {
  margin-top: 160px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.18);
  display: grid;
  gap: 8px;
}
.login-note {
  display: grid;
  gap: 3px;
  color: #cfbeaa;
  font-family: Arial, sans-serif;
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 8px;
}
.login-note b { color: #fff4df; }
.nav-item.action { border: 1px dashed rgba(255,255,255,.25); justify-content: center; }
.nav-item.logout { color: #fff4df; justify-content: flex-start; }

.panel {
  min-height: 100vh;
  margin-left: 238px;
  padding: 24px 26px 42px;
  background: var(--cream);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 22px;
}
.panel-head h1 {
  margin: 0 0 5px;
  font-size: 38px;
  line-height: 1;
  font-weight: 700;
}
.panel-head p {
  margin: 0;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 15px;
}
.user-chip {
  background: var(--sidebar);
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 0;
}
.user-chip i { font-size: 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card, .card, .module-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.stat-card {
  min-height: 96px;
  padding: 18px 18px;
  position: relative;
  overflow: hidden;
}
.stat-card:before {
  content: "\f080";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  display: block;
  color: var(--green);
  font-size: 20px;
  margin-bottom: 11px;
}
.stat-card span {
  color: #4f4740;
  display: block;
  margin-bottom: 10px;
  font-family: Arial, sans-serif;
  font-size: 13px;
}
.stat-card strong {
  display: block;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
}
.charts-grid {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 16px;
  margin-bottom: 18px;
}
.card {
  padding: 18px;
  min-height: 315px;
}
.card h3 {
  margin: 0 0 10px;
  font-family: Arial, sans-serif;
  font-size: 16px;
}
.card canvas { max-height: 260px; }

.module-card { overflow: hidden; }
.module-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}
.module-head h2 {
  margin: 0 0 3px;
  font-size: 24px;
}
.module-head p {
  margin: 0;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 14px;
}
.module-head span {
  padding: 6px 10px;
  background: var(--green);
  color: white;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
}
.module-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.crud-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.crud-form label {
  margin: 0;
  color: #3a332e;
  font-size: 14px;
  font-weight: 800;
}
.crud-form .wide { grid-column: span 2; }
.crud-form .full { grid-column: 1 / -1; }
.crud-form input, .crud-form select, .crud-form textarea, .table-tools input {
  min-height: 42px;
  font-size: 14px;
}
.crud-form textarea {
  min-height: 92px;
  resize: vertical;
}
.modal-crud-form {
  padding: 0;
  border-bottom: 0;
}
#crudEditModal .modal-dialog {
  max-width: min(980px, calc(100vw - 32px));
}
#crudEditModal .modal-content {
  max-height: calc(100vh - 48px);
  overflow: hidden;
}
#crudEditForm {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}
#crudEditModal .modal-body {
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  scrollbar-width: thin;
}
#crudEditModal .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.modal-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.modal-header-actions .btn {
  font-family: Arial, sans-serif;
  font-weight: 800;
}
.current-image-wrap {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 4px;
}
.current-image-wrap img {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.save-inline-message {
  grid-column: 1 / -1;
  min-height: 22px;
  font-family: Arial, sans-serif;
  font-weight: 800;
  color: var(--green);
}
.form-actions {
  display: flex;
  gap: 7px;
  align-items: end;
}
.table-tools {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
}
.table-tools input { max-width: 420px; }
.table-tools select {
  max-width: 220px;
  font-family: Arial, sans-serif;
}
.table-wrap {
  overflow: auto;
  padding: 0 18px 24px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  font-family: Arial, sans-serif;
}
th, td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  color: #2e2a26;
  vertical-align: middle;
  font-size: 14px;
}
th {
  background: #f8f5ef;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #ece5d8;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}
.row-actions {
  display: flex;
  gap: 8px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 5px;
  color: var(--green);
  background: white;
  border: 1px solid var(--green);
}
.icon-btn.danger {
  color: var(--danger);
  border-color: var(--danger);
}

@media (max-width: 1100px) {
  .sidebar { position: static; width: auto; }
  .sidebar-actions { margin-top: 24px; }
  .panel { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .crud-form { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .login-card { padding: 24px; }
  .login-title { display: block; }
  .panel-head, .module-head, .table-tools { display: grid; }
  .stats-grid, .crud-form { grid-template-columns: 1fr; }
  .crud-form .wide { grid-column: auto; }
}

/* Orders Management Module */
.orders-module .order-stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  min-height: 88px;
  box-shadow: var(--shadow);
}
.orders-module .order-stat-card span {
  display: block;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 12px;
  margin-bottom: 8px;
}
.orders-module .order-stat-card strong {
  font-size: 22px;
  line-height: 1;
}
.orders-card .orders-toolbar {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.orders-card .form-label {
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.orders-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px;
  font-family: Arial, sans-serif;
  color: var(--muted);
}
.orders-table-wrap {
  min-height: 120px;
}
.orders-table-wrap .table {
  min-width: 1200px;
  font-family: Arial, sans-serif;
}
.orders-empty {
  text-align: center;
  padding: 36px 18px;
  color: var(--muted);
}
.orders-empty i {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}
.orders-pagination-wrap {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}
.detail-card {
  background: #f8f5ef;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  height: 100%;
}
.detail-card h6 {
  margin: 0 0 8px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--green);
}
.product-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.product-thumb.placeholder {
  display: grid;
  place-items: center;
  background: #ece5d8;
  color: var(--muted);
}
.order-totals {
  margin-top: 16px;
  max-width: 360px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.order-totals > div {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-family: Arial, sans-serif;
  font-size: 14px;
}
.order-totals > div.grand {
  background: #f8f5ef;
  font-weight: 700;
}
.report-box {
  background: #f8f5ef;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}
.report-box h6 {
  margin: 0 0 6px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}
.report-box strong {
  font-size: 20px;
}
.d-none { display: none !important; }
