:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --text: #17201a;
  --text-2: #5e6a61;
  --line: #dce3dd;
  --brand: #1f7a4d;
  --brand-2: #155c3a;
  --danger: #c2413b;
  --shadow: 0 16px 40px rgba(22, 42, 29, .10);
  --r: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(246, 247, 244, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.eyebrow {
  margin: 0 0 2px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.15; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 14px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px;
}
.summary-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.metric, .panel, .detail-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.metric {
  padding: 13px;
}
.metric span {
  display: block;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}
.panel {
  min-height: 180px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head p {
  margin-top: 3px;
  color: var(--text-2);
  font-size: 12px;
}
.panel-head h2 {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
#account-count {
  color: var(--text-2);
  font-size: 17px;
}
.account-add-btn {
  font-size: 17px;
  line-height: 1;
}
.account-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 218px);
  overflow: auto;
  padding: 12px;
}
.account-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fbfcfa;
}
.account-item.active {
  background: var(--surface-2);
}
.account-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
}
.account-meta, .small-muted {
  color: var(--text-2);
  font-size: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #dfeee5;
  color: var(--brand-2);
  font-size: 11px;
  font-weight: 800;
}
.badge.off {
  background: #eee7e2;
  color: #8a4c2f;
}
.mini-stats {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.mini-stats span {
  display: grid;
  place-items: center;
  min-width: 42px;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
}
.mini-stats em {
  font-style: normal;
}
.mini-stats strong {
  color: var(--text);
  font-size: 15px;
}
.detail-panel {
  min-height: calc(100vh - 140px);
}
.empty-state {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
  color: var(--text-2);
  text-align: center;
}
.detail-nav {
  padding: 12px 16px 0;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.detail-title-block {
  width: 100%;
}
.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.detail-head h2 {
  font-size: 22px;
}
.tabbar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
.tabbar button, .ghost-btn, .primary-btn, .icon-btn {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
}
.tabbar button {
  flex: 0 0 auto;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 800;
}
.tabbar button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.detail-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.detail-section {
  padding: 13px;
}
.list {
  display: grid;
  gap: 8px;
}
.row-card {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fbfcfa;
}
.row-card strong {
  font-size: 14px;
}
.admin-order-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fbfcfa;
}
.order-card-top, .order-card-main, .reception-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.status-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #dfeee5;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 800;
}
.order-name {
  font-size: 15px;
  font-weight: 900;
}
.order-product {
  font-weight: 800;
}
.order-address {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
}
.template-text {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}
.reception-list {
  display: grid;
  gap: 8px;
}
.reception-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fbfcfa;
  text-align: left;
}
.reception-summary-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.reception-name {
  font-weight: 900;
}
.reception-meta {
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
}
.reception-text {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
label {
  display: grid;
  gap: 5px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  resize: vertical;
}
textarea { line-height: 1.45; }
.wide { grid-column: 1 / -1; }
.primary-btn {
  min-height: 38px;
  padding: 8px 12px;
  border-color: var(--brand);
  background: var(--brand);
  color: white;
  font-weight: 800;
}
.ghost-btn {
  min-height: 38px;
  padding: 8px 12px;
  font-weight: 800;
}
.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
}
.switch-row {
  grid-auto-flow: column;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
}
.switch-row input { width: auto; }
dialog {
  width: min(560px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}
dialog::backdrop { background: rgba(12, 18, 14, .45); }
.auth-dialog {
  width: min(380px, calc(100vw - 24px));
}
.auth-dialog::backdrop { background: rgba(12, 18, 14, .62); }
.dialog-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.dialog-head, .dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dialog-actions {
  justify-content: flex-end;
  margin-top: 4px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 13px;
  border-radius: var(--r);
  background: #17201a;
  color: white;
  font-size: 13px;
  font-weight: 700;
  transition: .2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 760px) {
  .topbar { padding: 12px 14px; }
  h1 { font-size: 20px; }
  .layout {
    display: block;
    padding: 10px;
  }
  .summary-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 10px;
  }
  .account-panel {
    margin-bottom: 10px;
  }
  body.detail-open .account-panel,
  body.detail-open .summary-strip {
    display: none;
  }
  body:not(.detail-open) .detail-panel {
    display: none;
  }
  .detail-head {
    display: block;
  }
  .account-list {
    max-height: 360px;
  }
  .detail-panel {
    min-height: 420px;
  }
  .detail-grid, .form-grid {
    grid-template-columns: 1fr;
  }
}
