:root {
  --ink: #19232d;
  --muted: #64717f;
  --line: #dce3ea;
  --paper: #ffffff;
  --soft: #f5f7f8;
  --brand: #146c63;
  --danger: #c23b2a;
  --warn: #9d6a00;
  --blue: #225c9a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}
button, input, select, textarea { font: inherit; }
button, .link-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover, .link-button:hover { filter: brightness(0.92); }
button:disabled { opacity: 0.55; cursor: wait; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  padding: 0;
  accent-color: #0f766e;
}
label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 34px; }
h2 { margin-bottom: 16px; font-size: 22px; }
.eyebrow { margin-bottom: 6px; color: var(--danger); font-size: 12px; text-transform: uppercase; font-weight: 900; letter-spacing: 0; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  background: #19232d;
  color: white;
}
.brand { color: white; font-size: 24px; font-weight: 900; text-decoration: none; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav button, .ghost {
  justify-content: flex-start;
  background: transparent;
  color: rgba(255,255,255,.82);
}
.sidebar nav button.active { background: rgba(255,255,255,.12); color: white; }
.ghost { margin-top: auto; border: 1px solid rgba(255,255,255,.2); }

.admin-main { padding: 28px; min-width: 0; }
.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}
.toast {
  min-height: 24px;
  margin-bottom: 14px;
  font-weight: 800;
  color: var(--brand);
}
.toast.error { color: var(--danger); }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--paper);
  box-shadow: 0 12px 30px rgba(25, 35, 45, 0.06);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: white;
}
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { display: block; margin-top: 8px; font-size: 32px; }
.toolbar {
  display: grid;
  grid-template-columns: 1fr 190px auto;
  gap: 10px;
  margin-bottom: 14px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 13px; }
.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
  background: #edf2f7;
}
.status-new { color: var(--blue); background: #e7f1ff; }
.status-in_progress { color: var(--warn); background: #fff4d9; }
.status-callback { color: #6d3ab8; background: #f0e7ff; }
.status-closed { color: var(--brand); background: #ddf3ee; }
.status-rejected { color: var(--danger); background: #ffe9e4; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions button { min-height: 32px; padding: 6px 8px; }
.danger { background: var(--danger); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }
.integration-help {
  margin-bottom: 16px;
  color: var(--ink);
}
.integration-help summary {
  cursor: pointer;
  font-weight: 800;
}
.integration-help ol,
.integration-help ul {
  margin: 12px 0 0;
  padding-left: 20px;
}
.integration-help li + li { margin-top: 8px; }
.integration-help p {
  margin: 12px 0 0;
  color: var(--muted);
}
.integration-help code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.integration-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.provider-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
}
.provider-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.provider-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.provider-badge.ok { background: #e8f5f1; color: #0d453f; }
.provider-badge.soon { background: #eef2f7; color: #475569; }
.provider-card strong,
.provider-card span {
  display: block;
}
.provider-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.provider-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.onboarding-banner ul {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.onboarding-steps { display: grid; gap: 10px; }
.onboarding-step {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  cursor: pointer;
}
.onboarding-step:hover { background: #f8fafb; }
.onboarding-steps .done .onboarding-step { opacity: 0.82; }
.onboarding-mark { font-weight: 800; min-width: 18px; }
.onboarding-copy strong { display: block; }
.onboarding-copy small { display: block; margin-top: 4px; color: var(--muted); font-weight: 500; }
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.schedule-day {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  cursor: pointer;
}
.schedule-day.free { background: #ecfdf5; border-color: #86efac; }
.schedule-day.partial { background: #fffbeb; border-color: #fcd34d; }
.schedule-day.busy { background: #fef2f2; border-color: #fca5a5; }
.schedule-nav { display: flex; gap: 10px; align-items: center; }
.schedule-day.panel { margin-top: 18px; }
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.slot-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
}
.slot-card.free { border-color: #86efac; background: #ecfdf5; }
.slot-card.busy { border-color: #fca5a5; background: #fef2f2; }

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.cms-item {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.cms-item:first-child { border-top: 0; }
.cms-item p { color: var(--muted); margin-bottom: 0; }
.cms-actions { display: flex; gap: 8px; }
.form-grid, [data-edit-form] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.checkbox-setting {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--ink);
}
.checkbox-setting span {
  line-height: 1.35;
}
.color-field {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: center;
}
.color-field input[type="color"] {
  width: 52px;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.upload-panel { margin-top: 16px; }
.upload-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}
.billing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.billing-card {
  min-height: 92px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafb;
}
.billing-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.billing-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
}
.billing-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 700;
}
.full { grid-column: 1 / -1; }
dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
dialog::backdrop { background: rgba(0,0,0,.36); }

.login-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(120deg, rgba(20,108,99,.92), rgba(25,35,45,.86)),
    url("https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1600&q=80") center/cover;
}
.login-panel {
  width: min(420px, 100%);
  border-radius: 8px;
  padding: 26px;
  background: white;
  box-shadow: 0 18px 50px rgba(0,0,0,.2);
}
.login-panel form { display: grid; gap: 14px; }
.login-panel a { display: inline-block; margin-top: 18px; color: var(--brand); font-weight: 800; }
.notice { min-height: 22px; color: var(--danger); font-weight: 800; }

@media (max-width: 920px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .sidebar nav { grid-auto-flow: column; grid-auto-columns: max-content; }
  .ghost { margin-top: 0; margin-left: auto; }
  .metrics, .content-grid, .form-grid, [data-edit-form], .upload-form, .billing-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .admin-main { padding: 16px; }
  .admin-header { align-items: stretch; flex-direction: column; }
  .sidebar { padding: 12px; }
}
