* { box-sizing: border-box; }

body.login-page {
  background: #f5f2ee;
  min-height: 100vh;
  color: var(--text);
}

:root {
  /* Палитра в духе бренда: тёплый тёмно-коричневый + приглушённый зелёный */
  --bg-deep: #0f0d0c;
  --bg-brown: #1a1614;
  --bg-brown-mid: #221e1b;
  --bg-card-dark: #26211f;
  --surface: #faf8f5;
  --surface-2: #f2ede8;
  --border: #e4dcd3;
  --text: #1c1917;
  --muted: #7a6f66;
  --primary: #4a7c44;
  --primary-hover: #3d6a38;
  --primary-muted: #6b9664;
  --primary-soft: rgba(74, 124, 68, 0.16);
  --tan: #c9bfb5;
  --danger: #dc2626;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow: 0 24px 60px rgba(8, 5, 3, 0.38);
}

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  color: var(--text);
  background: radial-gradient(1000px 520px at 14% 0%, var(--bg-brown-mid) 0%, var(--bg-brown) 45%, var(--bg-deep) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.app-surface {
  background: radial-gradient(1000px 520px at 14% 0%, var(--bg-brown-mid) 0%, var(--bg-brown) 45%, var(--bg-deep) 100%);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}
.container.narrow { max-width: 480px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(26, 22, 20, 0.90);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 0 rgba(0,0,0,0.18);
}
.topbar .container {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 11px 24px;
}
.brand {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: none;
  color: #d4e8d1;
  font-size: 16px;
  line-height: 1.3;
}
.nav {
  display: flex;
  gap: 2px;
}
.nav a {
  color: rgba(201, 191, 181, 0.85);
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover {
  background: rgba(74, 124, 68, 0.22);
  color: #f0ede8;
}
.logout { margin-left: auto; }
.linkbtn {
  border: 0;
  background: transparent;
  color: rgba(168, 158, 148, 0.9);
  cursor: pointer;
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.linkbtn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ede8e2;
}

h2 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
  color: #1e1a18;
}
h3 {
  margin: 22px 0 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: #3d3630;
}

/* Generic cards (stats, detail) */
.card,
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.card.inline {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.card .v {
  font-size: 1.25rem;
  font-weight: 700;
  color: #292420;
  margin-top: 4px;
}
.label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
label { display: block; }

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cfc7be;
  outline: none;
  background: #fff;
  font-size: 14px;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button.btn-primary,
button[type="submit"]:not(.icon-btn):not(.btn-danger):not(.linkbtn):not(.page-btn):not(.btn-queue) {
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
button.btn-primary:hover,
button[type="submit"]:not(.icon-btn):not(.btn-danger):not(.linkbtn):not(.page-btn):not(.btn-queue):hover {
  background: var(--primary-hover);
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.alert {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

/* ——— Calls page (product-style shell) ——— */
.calls-restaurant-tabs .hub-restaurant-tab {
  text-decoration: none;
}

.calls-restaurant-hint {
  margin: 0 22px 16px;
  max-width: 920px;
}

.calls-shell {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(228, 220, 211, 0.9);
  overflow: hidden;
  margin-top: 8px;
}

.calls-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 22px 8px;
  border-bottom: 1px solid var(--border);
}
.calls-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #292420;
}
.calls-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  max-width: 720px;
}

.calls-toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.calls-toolbar .tb-search {
  grid-column: span 2;
}
.calls-toolbar select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237a6f66' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.calls-toast {
  margin: 0 22px 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #c8e6c9;
}
.calls-toast-warn {
  background: #fff8e1;
  color: #5d4037;
  border-color: #ffe082;
}

.calls-process-now {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 22px 16px;
}
.calls-process-now .hint {
  flex: 1 1 240px;
  margin: 0;
}

button.btn-queue {
  background: #5c534c;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.btn-queue:hover {
  background: #453d38;
}

.shell-table-wrap {
  overflow: auto;
  max-width: 100%;
}
.shell-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.shell-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a7f74;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #f0ebe5;
  white-space: nowrap;
}
.shell-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #ebe4dc;
  vertical-align: middle;
  color: #3d3834;
}
.shell-table tbody tr:hover td {
  background: #f7f3ef;
}
.shell-table tbody tr.row-new td {
  background: #edf5eb;
}
.shell-table tbody tr.row-new:hover td {
  background: #dcebd8;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok { background: #dcebd8; color: #2d5a28; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-pend { background: #fef3c7; color: #92400e; }
.badge-wait { background: #ede6dc; color: #5c4f42; }

.icon-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #ded6ce;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: var(--primary);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.icon-btn:hover {
  background: var(--primary-soft);
  border-color: rgba(74, 124, 68, 0.35);
  transform: translateY(-1px);
}
.icon-btn.danger {
  color: var(--danger);
  border-color: #fecaca;
}
.icon-btn.danger:hover {
  background: #fef2f2;
}
.icon-btn svg {
  display: block;
}

.calls-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 18px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.per-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.per-wrap select {
  width: auto;
  min-width: 72px;
}

.page-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.page-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 16px;
  line-height: 1;
}
.page-btn:hover:not(.disabled) {
  background: var(--primary-hover);
}
.page-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Mobile cards */
.mobile-cards {
  display: none;
  padding: 12px 14px 18px;
}
.call-mcard {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: #fff;
  overflow: hidden;
}
.call-mcard summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.call-mcard summary::-webkit-details-marker { display: none; }
.call-mcard summary::after {
  content: "▾";
  color: #9a8f86;
  font-size: 12px;
}
.call-mcard[open] summary::after {
  content: "▴";
}
.mcard-body {
  padding: 0 14px 14px;
  font-size: 13px;
  color: #524a44;
  border-top: 1px solid #ebe4dc;
}
.mcard-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed #ded6ce;
}
.mcard-row:last-child { border-bottom: 0; }
.muted { color: #8a7f74; }
.mcard-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Legacy / other pages */
.tablewrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid #ebe4dc;
  vertical-align: top;
}
th {
  text-align: left;
  font-size: 12px;
  color: #6b5f56;
  background: #f0ebe5;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.stats-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* Call detail: two-column meta + transcript */
.detail-top-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 8px;
}
.detail-meta-card .kv {
  grid-template-columns: 130px 1fr;
  align-items: baseline;
}
.detail-meta-card .k {
  min-width: 0;
}
.detail-transcript-card {
  min-width: 0;
}
.detail-section-title {
  margin: 18px 0 10px;
  font-size: 16px;
  color: #4a433d;
}
.analysis-criteria-table {
  table-layout: fixed;
}
.analysis-criteria-table th.col-crit,
.analysis-criteria-table td.col-crit {
  width: 26%;
}
.analysis-criteria-table th.col-st,
.analysis-criteria-table td.col-st {
  width: 10%;
  white-space: nowrap;
  vertical-align: top;
}
.analysis-criteria-table th.col-pts,
.analysis-criteria-table td.col-pts {
  width: 8%;
  text-align: right;
  vertical-align: top;
}
.analysis-criteria-table th.col-ev,
.analysis-criteria-table td.col-ev {
  width: 56%;
  word-break: break-word;
  vertical-align: top;
}
.signal-strip .signal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.signal-chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid #ded6ce;
  background: var(--surface-2);
  color: var(--muted);
}
.signal-chip.on {
  border-color: rgba(74, 124, 68, 0.45);
  background: #edf5eb;
  color: #2d5a28;
}
.signal-chip.off {
  opacity: 0.85;
}
.stat-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.stats-note {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.45;
}
@media (max-width: 900px) {
  .detail-top-grid {
    grid-template-columns: 1fr;
  }
}
.pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
  background: var(--bg-card-dark);
  color: #e8e2dc;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  padding: 6px 0;
  border-bottom: 1px dashed #ded6ce;
}
.kv:last-child { border-bottom: 0; }
.k { color: var(--muted); font-size: 12px; }
.v { font-size: 14px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: inline; margin: 0; }
.btn-danger {
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  background: #b91c1c;
  color: white;
  cursor: pointer;
  font-size: 12px;
}
.btn-danger:hover { background: #991b1b; }

.small { font-size: 12px; }
.detail-forms {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.detail-forms .textarea {
  width: 100%;
  min-height: 140px;
}
.form-row-check { margin: 4px 0; }
.check-label {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lexicon-suggest-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.lexicon-pair {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) {
  .lexicon-suggest-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .calls-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .calls-toolbar .tb-search {
    grid-column: span 2;
  }
  .calls-toolbar .tb-submit {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .shell-table-wrap { display: none; }
  .mobile-cards { display: block; }
  .calls-toolbar {
    grid-template-columns: 1fr;
  }
  .calls-toolbar .tb-search {
    grid-column: span 1;
  }
  .calls-toolbar .tb-submit {
    grid-column: span 1;
  }
  .calls-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
