:root {
  --bg: #eff4ee;
  --bg-soft: #f6f9f4;
  --panel: #ffffff;
  --ink: #1d2a23;
  --muted: #617062;
  --accent: #0d7a5f;
  --accent-hover: #0b684f;
  --accent-2: #d85e32;
  --accent-2-hover: #be5028;
  --border: #d6ddd3;
  --border-strong: #c2cdbf;
  --focus: rgba(13, 122, 95, 0.2);
  --shadow-sm: 0 2px 10px rgba(22, 38, 29, 0.06);
  --shadow-md: 0 10px 30px rgba(16, 31, 23, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 92% 2%, #d6ece2 0%, transparent 35%),
    radial-gradient(circle at 4% 96%, #e8efe1 0%, transparent 28%),
    var(--bg);
  color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  align-items: start;
  gap: 1rem;
  padding: 1rem;
  max-width: 1460px;
  margin: 0 auto;
}

.layout.single-col {
  grid-template-columns: minmax(320px, 640px);
  justify-content: center;
  min-height: 100vh;
  align-content: center;
  padding: 1.25rem;
}

.layout.admin-layout {
  grid-template-columns: repeat(2, minmax(420px, 1fr));
  max-width: 1600px;
}

.panel {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdf9 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow-md);
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel.rail {
  grid-row: span 2;
}

.onesignal-panel {
  grid-column: 1;
}

.api-health-panel {
  grid-column: 2;
}

.onesignal-panel,
.api-health-panel {
  min-height: 250px;
}

.business-panel {
  grid-column: 1 / -1;
}

.campaign-panel {
  grid-column: 1;
}

.daily-panel {
  grid-column: 2;
  grid-row: span 2;
}

.panel.compact {
  padding: 0.9rem;
}

.panel.compact .form-grid {
  grid-template-columns: 1fr;
}

.auth-panel {
  width: 100%;
  padding: 1.2rem;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.2;
  color: #2f4136;
}

h1 {
  font-size: 1.55rem;
  letter-spacing: 0.01em;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.muted {
  color: var(--muted);
  margin: 0.3rem 0 0 0;
  line-height: 1.42;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.status-strip {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.status-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.65rem;
  margin-bottom: 0.4rem;
}

.business-split {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
  margin-top: 0.6rem;
}

.business-col {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.business-config-col {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.72rem;
  background: #f9fcf8;
}

.business-panel textarea#businessContext {
  min-height: 190px;
}

.rag-badge {
  display: inline-block;
  width: fit-content;
  padding: 0.24rem 0.56rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
}

.rag-green {
  background: #e8f8ef;
  color: #12623f;
}

.rag-amber {
  background: #fff4e7;
  color: #8b5c1a;
}

.rag-red {
  background: #feeaea;
  color: #8a1f1f;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 0.65rem;
  margin-bottom: 0.9rem;
}

.setup-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem;
  background: #f9fcf8;
  margin-top: 0;
}

.schedule-builder .builder-grid {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  align-items: start;
}

.builder-left {
  align-self: start;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem;
  background: #f9fcf8;
}

.builder-right {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem;
  background: #f9fcf8;
  align-self: start;
}

.builder-right .day-planner {
  max-height: 900px;
}

.base-times-picker {
  margin-top: 0.28rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.weekly-pattern-config {
  margin-top: 0.56rem;
  padding: 0.56rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.weekday-count-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 0.44rem 0.7rem;
}

.weekday-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #2f4136;
}

.weekday-count-row input {
  width: 74px;
  text-align: center;
  padding: 0.36rem 0.32rem;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
  margin-bottom: 0.9rem;
}

.form-grid .full-row {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
  font-size: 0.84rem;
  color: #34453a;
}

.inline-note {
  display: inline-block;
  padding: 0.52rem 0.68rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.9rem;
}

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

input,
textarea,
select {
  padding: 0.56rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

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

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

button {
  border: 0;
  border-radius: 9px;
  padding: 0.56rem 0.92rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 100ms ease, background-color 120ms ease, box-shadow 120ms ease;
  box-shadow: var(--shadow-sm);
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: #2f473d;
}

button.secondary:hover {
  background: #273b33;
}

button.danger-secondary {
  background: #5f2f34;
}

button.danger-secondary:hover {
  background: #4c2529;
}

.mini {
  margin-top: 0.35rem;
  padding: 0.34rem 0.52rem;
  font-size: 0.76rem;
  line-height: 1.1;
}

.tiny-accent {
  background: var(--accent);
  color: #fff;
  padding: 0.56rem 0.92rem;
  font-size: 1rem;
  line-height: normal;
}

.tiny-accent:hover {
  background: var(--accent-hover);
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.day-planner {
  display: flex;
  flex-direction: column;
  gap: 0.68rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.panel.rail .day-planner {
  max-height: 900px;
}

.day-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.68rem;
  background: linear-gradient(180deg, #fff 0%, #f8fbf7 100%);
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.day-head strong {
  font-size: 0.9rem;
}

.day-head input[type="number"] {
  width: 74px;
  text-align: center;
  padding: 0.4rem 0.3rem;
}

.times {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.time-slot {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 210px;
}

.time-slot-label {
  font-size: 0.72rem;
  color: var(--muted);
  padding-left: 0.15rem;
}

.time-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.26rem;
  padding: 0.22rem 0.34rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f3f8f2;
}

.time-picker select {
  width: 58px;
  padding: 0.24rem 0.28rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 0.82rem;
}

.time-sep {
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}

.time-note-input {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  line-height: 1.35;
  font-size: 0.78rem;
  padding: 0.38rem 0.44rem;
}

.day-note {
  margin-top: 0.62rem;
}

.chat-log {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  height: 300px;
  overflow-y: auto;
  background: #f9fcf8;
}

.chat-msg {
  margin: 0 0 0.56rem 0;
  line-height: 1.42;
}

.chat-msg strong {
  color: var(--accent-2);
}

.chat-input-row {
  margin-top: 0.62rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.table-wrap {
  overflow: auto;
  max-height: 470px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

#pushFailureWrap {
  margin-bottom: 0.68rem;
}

.table-caption {
  margin: 0.7rem 0 0.38rem 0;
  color: #4a5d51;
  font-size: 0.82rem;
  font-weight: 600;
}

.admin-metrics {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 0.75rem;
}

.admin-metric {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fcf8;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-metric strong {
  font-size: 1.25rem;
  color: #223329;
}

.admin-table-wrap {
  max-height: 420px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 39, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 2000;
}

.modal-card {
  width: min(860px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow-md);
}

.billing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.75rem;
}

.billing-grid-single {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: start;
}

.billing-option {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fcf8;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.billing-option strong {
  color: #1f3028;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #e5ebe3;
  text-align: left;
  padding: 0.5rem;
  vertical-align: top;
  font-size: 0.88rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f5ef;
  color: #2f4136;
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background: #fcfefb;
}

tbody tr:hover {
  background: #f3f8f2;
}

td input,
td textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
}

td textarea {
  min-height: 70px;
  resize: vertical;
}

.updated-flash {
  animation: flashGreen 1.25s ease-out;
}

@keyframes flashGreen {
  0% {
    background: #dff7e8;
  }
  100% {
    background: transparent;
  }
}

code {
  font-size: 0.84em;
  background: #eef4eb;
  border: 1px solid #dde6da;
  border-radius: 6px;
  padding: 0.06rem 0.28rem;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }

  .panel.rail,
  .onesignal-panel,
  .api-health-panel,
  .business-panel,
  .campaign-panel,
  .daily-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .business-split {
    grid-template-columns: 1fr;
  }

  .business-config-col {
    padding: 0.85rem;
  }

  .weekday-count-grid {
    grid-template-columns: 1fr;
  }

  .schedule-builder .builder-grid {
    grid-template-columns: 1fr;
  }

  .base-times-picker {
    flex-direction: column;
  }

  .time-slot {
    min-width: 0;
  }

  .day-planner {
    max-height: none;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 760px;
  }

  .billing-grid {
    grid-template-columns: 1fr;
  }

  .billing-grid-single {
    grid-template-columns: 1fr;
  }

  .modal-card {
    max-height: 92vh;
    padding: 0.85rem;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }

  .panel {
    padding: 0.85rem;
    border-radius: 14px;
  }

  h1 {
    font-size: 1.28rem;
  }

  h2 {
    font-size: 1.02rem;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.55rem;
  }

  .actions button {
    width: 100%;
  }

  .chat-input-row {
    grid-template-columns: 1fr;
  }

  .chat-input-row button {
    width: 100%;
  }

  .business-panel textarea#businessContext {
    min-height: 150px;
  }

  .admin-metrics {
    grid-template-columns: 1fr;
  }

  th,
  td {
    font-size: 0.84rem;
    padding: 0.45rem;
  }

  table {
    min-width: 660px;
  }
}

@media (max-width: 480px) {
  .layout {
    padding: 0.6rem;
    gap: 0.85rem;
  }

  .panel {
    padding: 0.78rem;
    border-radius: 13px;
  }

  .modal-backdrop {
    padding: 0.75rem;
  }

  .modal-card {
    padding: 0.75rem;
  }

  th,
  td {
    font-size: 0.82rem;
    padding: 0.4rem;
  }

  table {
    min-width: 600px;
  }

  .time-picker select {
    width: 54px;
  }
}
