:root {
  --ink: #1b1712;
  --ink-soft: #3f382f;
  --paper: #f3ead9;
  --paper-2: #fff8ec;
  --line: #e2d5c0;
  --copper: #c45c26;
  --copper-dark: #9a3f14;
  --forest: #2f5d45;
  --rose: #9a3040;
  --sidebar: #16130f;
  --muted: #7a7166;
  --shadow: 0 14px 34px rgba(27, 23, 18, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Manrope, sans-serif;
}

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

a {
  color: inherit;
}

#app {
  min-height: 100vh;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(196, 92, 38, 0.18), transparent 32%),
    radial-gradient(circle at 90% 80%, rgba(47, 93, 69, 0.16), transparent 28%),
    var(--paper);
}

.login-card {
  width: min(420px, calc(100% - 32px));
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 36px 32px;
  box-shadow: var(--shadow);
  border-radius: 22px;
}

.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--copper);
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: Fraunces, serif;
  font-weight: 650;
  margin: 8px 0 12px;
}

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

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 6px;
}

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

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

.btn {
  border: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn.copper {
  background: var(--copper);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--rose);
}

.btn.small {
  padding: 7px 10px;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.side {
  background: var(--sidebar);
  color: #f6ecdc;
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  padding: 4px 12px 22px;
}

.brand h1 {
  color: #f6ecdc;
  margin: 6px 0 0;
  font-size: 28px;
}

.nav-btn {
  text-align: left;
  background: transparent;
  color: #d9cbb6;
  border: 0;
  padding: 11px 12px;
  cursor: pointer;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.nav-btn .ico {
  opacity: 0.82;
}

.nav-btn.active {
  background: #2a241c;
  color: #fff;
}

.nav-btn:hover {
  background: #221e18;
  color: #fff;
}

.side .spacer {
  flex: 1;
}

.main {
  padding: 28px 32px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 24px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.card .value {
  font-family: Fraunces, serif;
  font-size: 32px;
  margin-top: 10px;
}

.stat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.stat-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f3e6d3;
  color: var(--copper);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--paper-2);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  border: 0;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 14px;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #efe6d4;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #f7efe1;
}

.table-compact td,
.table-compact th {
  padding: 10px 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #ece1ce;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.delivered { background: #d9eadf; color: var(--forest); }
.badge.queued, .badge.pending { background: #f4e3c2; }
.badge.failed, .badge.duplicate { background: #f3d5d8; color: var(--rose); }
.badge.active { background: #d9eadf; color: var(--forest); }
.badge.off { background: #ece1ce; color: var(--muted); }
.badge.log-quota { background: #e8ddd0; }
.badge.log-duplicate { background: #f3d5d8; color: var(--rose); }
.badge.log-no_client, .badge.log-telegram_failed { background: #f4e3c2; }
.badge.log-recording { background: #dce8f2; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(22, 19, 15, 0.46);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--paper-2);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.error {
  color: var(--rose);
  font-size: 13px;
  margin-top: 8px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.clickable {
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.check input {
  width: auto;
}

.pre {
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px;
  font-size: 13px;
  border-radius: 10px;
}

.notice {
  border: 1px solid var(--line);
  padding: 14px 16px;
  margin-bottom: 14px;
  background: #fff6e8;
  border-radius: 12px;
}

.notice.danger {
  background: #f8e4e6;
  border-color: #e4b4ba;
  color: var(--rose);
}

.notice.warn {
  background: #f7edd4;
}

.notice b {
  display: block;
  margin-bottom: 6px;
}

.ok-note {
  color: var(--forest);
  font-size: 13px;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.log-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  z-index: 50;
  border-radius: 12px;
}

.ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.phone-link {
  color: var(--copper-dark);
  font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

.phone-link:hover {
  text-decoration: underline;
}

.cell-main b {
  display: block;
}

.cell-main .muted {
  margin-top: 3px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .brand,
  .spacer {
    display: none;
  }
  .cards,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 18px;
  }
  table {
    min-width: 640px;
  }
}
