:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #20242a;
  --muted: #69717d;
  --line: #dde2e8;
  --primary: #1f7a58;
  --primary-dark: #176144;
  --danger: #bb3b35;
  --success: #26734d;
  --warning: #a56a12;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

.topbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  flex: 1;
}

.logout {
  margin-left: auto;
}

.sound-toggle {
  white-space: nowrap;
}

.sound-toggle.sound-active {
  border-color: var(--success);
  color: var(--success);
}

.sound-toggle.sound-ringing,
.pending-order-alert button.sound-ringing {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 60px;
}

h1 {
  font-size: 28px;
  margin: 0 0 22px;
}

h2 {
  font-size: 20px;
  margin: 0 0 16px;
}

.auth-box,
.panel,
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.auth-box {
  max-width: 420px;
  margin: 70px auto;
}

.form {
  display: grid;
  gap: 14px;
}

.form.wide {
  max-width: 760px;
}

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

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.fieldset legend {
  padding: 0 8px;
  font-weight: 700;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

input[type="checkbox"] {
  width: auto;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.small {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
}

.alert {
  border-radius: 6px;
  padding: 11px 13px;
  margin-bottom: 16px;
}

.alert-danger {
  background: #fff0ef;
  color: #8a211d;
  border: 1px solid #f1bbb7;
}

.alert-success {
  background: #edf8f2;
  color: #185b3a;
  border: 1px solid #b9dec8;
}

.alert-warning {
  background: #fff8e8;
  color: #704a08;
  border: 1px solid #e2b95f;
}

button:disabled,
.button.disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.page-head,
.actions-row,
.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 18px;
}

.filters label {
  width: 260px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: #eef2f5;
  font-weight: 700;
}

.select-cell {
  width: 42px;
  text-align: center;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 700;
}

.success {
  background: #e8f6ee;
  color: var(--success);
}

.warning {
  background: #fff8e8;
  color: var(--warning);
}

.muted-badge {
  background: #eef0f2;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

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

.stats-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.detail-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.stat-value {
  font-size: 34px;
  font-weight: 800;
}

.stat-label {
  color: var(--muted);
}

.attention {
  border-color: #e6c58d;
}

.info-list {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

.info-list dt {
  color: var(--muted);
}

.info-list dd {
  margin: 0;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.image-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
}

.settings-section {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.bulk-actions {
  margin-top: 12px;
}

.delivery-calculation-form {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 16px;
}

.delivery-calculation-form h3 {
  font-size: 17px;
  margin: 0;
}

.compact-table input {
  min-width: 140px;
}

.pending-order-alert {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100% - 40px));
  padding: 12px 14px;
  background: #fff8e8;
  border: 1px solid #e2b95f;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

.pending-order-alert.is-ringing {
  border-color: var(--warning);
  box-shadow: 0 12px 30px rgba(165, 106, 18, 0.24);
}

.pending-order-alert[hidden] {
  display: none;
}

.pending-order-alert a {
  color: #704a08;
  font-weight: 700;
}

.pending-order-alert button {
  min-height: 32px;
  padding: 6px 10px;
  background: #704a08;
  border-color: #704a08;
  color: #fff;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .logout {
    margin-left: 0;
  }

  .form-row,
  .stats-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .table {
    display: block;
    overflow-x: auto;
  }
}
