/* Cody Nuntio, in the CodySuite theme (the CodyAI site's look).
   Light by default; Settings -> Dark mode adds body.dark-theme.
   Orange #f25c1f is a fill for the one main action per screen, with ink text
   on it. Where orange has to be text it is #b83e0c (light) / #ff9a6b (dark).
   Fonts are served from /fonts because the CSP blocks Google Fonts. */

@font-face {
  font-family: 'Outfit';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/outfit-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-weight: 500;
  font-display: swap;
  src: url('fonts/outfit-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/outfit-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Funnel Display';
  font-weight: 700;
  font-display: swap;
  src: url('fonts/funnel-display-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Funnel Display';
  font-weight: 800;
  font-display: swap;
  src: url('fonts/funnel-display-latin-800-normal.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --bg: #f8f5fc;
  --panel: #ffffff;
  --panel-2: #f8f5fc;
  --wash-2: #efe9f8;
  --text: #24163a;
  --sub: #4a3f5e;
  --muted: #6b6080;
  --accent: #b83e0c;
  --orange: #f25c1f;
  --orange-hover: #e04f14;
  --on-orange: #24163a;
  --nav-active-bg: #24163a;
  --nav-active-fg: #ffffff;
  --switch-on-bg: #24163a;
  --switch-on-knob: #ffffff;
  --danger: #c42b1c;
  --ok: #127a4b;
  --badge-sent-bg: #e3f4ec;
  --badge-failed-bg: #fde7e4;
  --warn-bg: #fdf1e6;
  --warn-fg: #8a4a0c;
  --warn-border: #f3d2b0;
  --border: #ddd5ea;
  --divider: #ece6f4;
  --focus-ring: rgba(242, 92, 31, 0.22);
  --backdrop: rgba(36, 22, 58, 0.45);
  --shadow: 0 12px 32px rgba(36, 22, 58, 0.18);
  --display: 'Funnel Display', 'Outfit', system-ui, sans-serif;
  --body: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
body.dark-theme {
  color-scheme: dark;
  --bg: #150f1e;
  --panel: #1f1830;
  --panel-2: #191326;
  --wash-2: #2c2240;
  --text: #f3effa;
  --sub: #cdc3de;
  --muted: #a497b9;
  --accent: #ff9a6b;
  --orange-hover: #ff6d33;
  --nav-active-bg: #efe9f8;
  --nav-active-fg: #24163a;
  --switch-on-bg: #efe9f8;
  --switch-on-knob: #24163a;
  --danger: #ff8a7f;
  --ok: #4ade9b;
  --badge-sent-bg: rgba(74, 222, 155, 0.14);
  --badge-failed-bg: rgba(255, 138, 127, 0.14);
  --warn-bg: rgba(232, 128, 30, 0.16);
  --warn-fg: #f5b57a;
  --warn-border: rgba(232, 128, 30, 0.35);
  --border: #3a2f50;
  --divider: #2c2340;
  --focus-ring: rgba(242, 92, 31, 0.35);
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font-family: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 20px;
  padding: 0 8px 20px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sub);
  text-decoration: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
}
.nav-item:hover {
  background: var(--panel-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-fg);
}
.main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1100px;
}
.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.logout-btn:hover {
  background: var(--panel-2);
}

h1,
.card-title,
.modal-title {
  font-family: var(--display);
  letter-spacing: -0.02em;
}
h1 {
  margin: 0 0 4px;
  font-size: 26px;
}
/* Page titles, with the orange cursor bar from the CodyAI site */
.page h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.page h1::after {
  content: '';
  display: inline-block;
  width: 0.14em;
  height: 0.8em;
  margin-left: 0.1em;
  vertical-align: -0.06em;
  border-radius: 3px;
  background: var(--orange);
}
.subtitle {
  color: var(--sub);
  font-size: 16px;
  margin: 0 0 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--wash-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--text);
}
.stat-icon svg {
  width: 20px;
  height: 20px;
}
.stat-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}
.stat-value {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 4px;
  transition: color 0.3s ease;
}
.stat-value.flash {
  color: var(--ok);
}
.stat-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}
.stat-sub a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.stat-sub a:hover {
  text-decoration: underline;
}
.stat-card.low {
  border-color: var(--warn-border);
}
.stat-card.low .stat-value,
.stat-card.low .stat-sub {
  color: var(--warn-fg);
}

/* Low-credit warning above Quick Send */
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-fg);
  font-weight: 500;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 20px;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 19px;
  margin-bottom: 16px;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 6px;
}
input[type='text'],
input[type='password'],
input[type='tel'],
input[type='email'],
input[type='date'],
textarea,
select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea {
  resize: vertical;
  min-height: 90px;
}
.form-row {
  margin-bottom: 16px;
}
.char-count {
  font-size: 12px;
  color: var(--muted);
}

/* Buttons: orange fill with ink text for the main action, plain for the rest */
.btn {
  border: none;
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
}
.btn-primary {
  background: var(--orange);
  color: var(--on-orange);
}
.btn-primary:hover {
  background: var(--orange-hover);
}
.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--panel-2);
}
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn-small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
}
.provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.btn-icon {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--sub);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-icon:hover {
  color: var(--text);
  background: var(--panel-2);
}
button:focus-visible,
.nav-item:focus-visible,
.switch:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.password-wrap {
  position: relative;
}
.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 360px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-sizing: border-box;
}
.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}
.hint-text {
  color: var(--muted);
  font-size: 12px;
  margin-top: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}
.switch {
  position: relative;
  width: 42px;
  height: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s;
}
.switch.on {
  background: var(--switch-on-bg);
  border-color: var(--switch-on-bg);
}
.switch.on::after {
  transform: translateX(18px);
  background: var(--switch-on-knob);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.status-pill.ok {
  color: var(--ok);
}
.status-pill.bad {
  color: var(--danger);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.template-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.template-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.template-name {
  font-weight: 600;
  font-size: 16px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--wash-2);
  color: var(--sub);
  margin-top: 6px;
}
.badge.status-sent {
  background: var(--badge-sent-bg);
  color: var(--ok);
}
.badge.status-draft {
  background: var(--wash-2);
  color: var(--muted);
}
.badge.status-failed {
  background: var(--badge-failed-bg);
  color: var(--danger);
}
.template-msg {
  color: var(--sub);
  font-size: 14px;
  margin: 12px 0;
  line-height: 1.45;
}
.template-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.usage-text {
  font-size: 13px;
  color: var(--muted);
}
.card-actions {
  display: flex;
  gap: 8px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  overflow: auto;
  padding: 24px;
}
.modal {
  width: 420px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-height: 90vh;
  overflow: auto;
}
.modal-title {
  font-weight: 700;
  font-size: 19px;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.page {
  display: none;
}
.page.active {
  display: block;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
td .badge {
  margin-top: 0;
}
.lg-message {
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
}

@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
    min-height: auto;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px;
    gap: 2px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar::-webkit-scrollbar {
    display: none;
  }
  .brand {
    padding: 0 10px 0 4px;
    flex-shrink: 0;
  }
  .nav-item {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 14px;
    padding: 8px 10px;
  }
  .sidebar-footer {
    display: none;
  }
  .main {
    padding: 16px;
    max-width: 100%;
  }
  .topbar {
    margin-bottom: 4px;
  }
  .page h1 {
    font-size: 26px;
  }
  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
  }
  .stat-value {
    font-size: 26px;
  }
  .card {
    padding: 16px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .card table {
    min-width: 560px;
  }
  .modal {
    width: 92vw;
    padding: 18px;
  }
  #toast-container {
    left: 12px;
    right: 12px;
    transform: none;
    width: auto;
  }
  .toast {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .section-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
}
tr:last-child td {
  border-bottom: none;
}
.empty-state {
  color: var(--muted);
  font-size: 14px;
  padding: 20px 0;
}

.checkbox-list {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 14px;
}
.checkbox-row input {
  width: auto;
}

#toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.toast {
  min-width: 300px;
  max-width: 480px;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow);
  border: none;
  text-align: center;
  color: #ffffff;
  opacity: 0;
  transform: translateY(-16px) translateX(0);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
/* Fixed colours: white text needs the darker green and red in both themes. */
.toast.success {
  background: #127a4b;
}
.toast.error {
  background: #c42b1c;
}

/* A quiet credit at the foot of the sidebar: the CodySuite mark, the version,
   and who makes the Cody apps. Hidden in the phone menu strip. */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 4px;
  border-top: 1px solid var(--divider);
}
.made-by {
  display: grid;
  gap: 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
.made-by-suite {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
}
.cody-mark {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text);
}

/* Cody Nuntio logo: ink wordmark on light, white wordmark on dark. */
.brand-logo {
  display: block;
  height: 30px;
  width: auto;
}
.theme-dark-only {
  display: none;
}
body.dark-theme .theme-dark-only {
  display: block;
}
body.dark-theme .theme-light-only {
  display: none;
}
.login-brand {
  margin: 0 0 12px;
  display: flex;
  justify-content: center;
}
.login-brand .brand-logo {
  height: 40px;
}
.build-number {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.03em;
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .switch::after,
  .stat-value {
    transition: none;
  }
}
