/* Dashboard app components. Tokens come from taki.css; nothing here
   introduces a raw color that is not derived from those tokens. */

/* ---- page heads and sections -------------------------------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head .page-sub { margin-bottom: 0; }
.page-head-actions { display: flex; align-items: center; gap: 8px; }

.section { margin-top: 28px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.section-title { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: .01em; }
.section-sub { color: var(--text-dim); font-size: 13px; margin: 2px 0 0; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack-8 > * + * { margin-top: 8px; }

/* ---- banners ------------------------------------------------ */
.banner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 22px;
}
.banner-text { flex: 1; min-width: 220px; }
.banner-title { font-weight: 700; }
.banner-desc { color: var(--text-dim); font-size: 13px; }
.banner[data-tone=warn] { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.banner[data-tone=danger] { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

/* ---- stat tiles --------------------------------------------- */
.tiles {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.tile {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.tile-label {
  color: var(--text-faint); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
.tile-value { font-size: 30px; font-weight: 700; line-height: 1.2; margin-top: 6px; }
.tile-note { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.tile[data-tone=warn] .tile-value { color: var(--warn); }
.tile[data-tone=accent] .tile-value { color: var(--accent); }

.usage-meter { margin-top: 16px; }
.usage-meter .usage-clock { font-size: 18px; font-weight: 700; margin-top: 6px; }
.usage-meter .usage-mins { font-size: 13px; margin-top: 2px; }
.usage-bar {
  height: 8px; border-radius: 999px; background: var(--bg-input);
  border: 1px solid var(--border); overflow: hidden; margin: 14px 0 16px;
}
.usage-bar i {
  display: block; height: 100%; width: 0; background: var(--accent);
  transition: width .2s ease;
}
.usage-bar[data-tone=warn] i { background: var(--warn); }
.usage-bar[data-tone=danger] i { background: var(--danger); }
.usage-overage {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; color: var(--text-dim); cursor: pointer;
}
.usage-overage input { margin-top: 3px; accent-color: var(--accent); }
.usage-overage[data-readonly] { cursor: default; }

/* ---- setup checklist ---------------------------------------- */
.checklist { display: grid; gap: 10px; }
.check-item {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.check-item.done { opacity: .68; }
.check-mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); display: grid; place-items: center;
  color: var(--text-faint); font-size: 12px; font-weight: 700; margin-top: 2px;
}
.check-item.done .check-mark {
  border-color: var(--ok); color: var(--ok); background: #4ade8018;
}
.check-body { flex: 1; min-width: 0; }
.check-title { font-weight: 600; }
.check-item.done .check-title { text-decoration: line-through; text-decoration-color: var(--text-faint); }
.check-desc { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.check-action { flex: none; align-self: center; }
.check-done-label { color: var(--ok); font-size: 12.5px; font-weight: 600; }

/* ---- badges and chips --------------------------------------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-dim);
}
.badge[data-tone=live] { color: var(--ok); border-color: #4ade8055; background: #4ade8014; }
.badge[data-tone=draft] { color: var(--text-faint); }
.badge[data-tone=accent] { color: var(--accent); border-color: #38bdf855; background: var(--accent-soft); }
.badge[data-tone=warn] { color: var(--warn); border-color: #fbbf2455; background: #fbbf2414; }
.badge[data-tone=danger] { color: var(--danger); border-color: #f8717155; background: #f8717114; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--font); font-size: 13px; font-weight: 600;
  background: var(--bg-panel); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 999px; padding: 5px 14px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip[aria-pressed=true] {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}
.chip-count { color: var(--text-faint); font-weight: 500; margin-left: 6px; }

/* ---- card grid (flows) -------------------------------------- */
.card-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  display: block; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
a.card:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
}
.card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-icon {
  flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid;
  place-items: center; font-size: 16px; background: var(--bg-raised);
  border: 1px solid var(--border);
}
.card-icon[data-kind=voice] { color: var(--node-cyan); }
.card-icon[data-kind=sms] { color: var(--node-purple); }
.card-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { color: var(--text-faint); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.card.card-new {
  border-style: dashed; color: var(--text-dim); display: grid; place-items: center;
  min-height: 108px; cursor: pointer; font-weight: 600; background: none;
}
.card.card-new:hover { color: var(--accent); border-color: var(--accent); }

/* ---- modal -------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: #0b0b0ecc; z-index: 400;
  display: grid; place-items: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 440px; max-width: 100%; background: var(--bg-panel);
  border: 1px solid var(--border-strong); border-radius: 14px; padding: 24px;
  box-shadow: var(--shadow); max-height: 88vh; overflow: auto;
}
.modal h2 { font-size: 17px; margin: 0 0 4px; }
.modal-desc { color: var(--text-dim); font-size: 13px; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* Radio cards used by the create-flow modal */
.pick-grid { display: grid; gap: 10px; margin-top: 6px; }
.pick {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; background: var(--bg-input);
}
.pick input { margin: 3px 0 0; accent-color: var(--accent); }
.pick:hover { border-color: var(--border-strong); }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick-title { font-weight: 600; }
.pick-desc { color: var(--text-dim); font-size: 12.5px; }

/* ---- editable table (contacts) ------------------------------ */
/* Fixed layout: column widths come from the header row, never from cell
   content, so entering edit mode can never shift a column. */
.table-wrap { overflow-x: auto; }
table.edit {
  width: 100%; border-collapse: collapse; min-width: 860px;
  table-layout: fixed;
}
table.edit th {
  text-align: left; color: var(--text-faint); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
table.edit td {
  padding: 0; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.edit tbody tr:hover { background: #ffffff06; }
table.edit tr.departed .cell { color: var(--text-faint); }
table.edit tr.drag-over td { box-shadow: inset 0 2px 0 var(--accent); }
table.edit tr.dragging { opacity: .4; }

/* Cells have a hard height and single-line text; the edit input is
   absolutely positioned over the same box, so swapping text for the
   input changes nothing the table can measure. */
.cell {
  position: relative; height: 38px; line-height: 18px;
  padding: 9px 10px; cursor: text; border: 1px solid transparent;
  border-radius: var(--radius-sm); margin: 2px; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell:hover { border-color: var(--border); }
.cell.editing { overflow: visible; border-color: transparent; }
.cell.empty-cell::before { content: attr(data-placeholder); color: var(--text-faint); }
.cell input {
  position: absolute; inset: 0; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 8px 9px; font-family: var(--font); font-size: 14px; line-height: 18px;
}
.cell input:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.cell-static { padding: 9px 10px; overflow: hidden; }
.redirect-note {
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.col-handle { width: 34px; }
.col-ext { width: 76px; }
.col-status { width: 130px; }
.drag-handle {
  cursor: grab; color: var(--text-faint); text-align: center; padding: 10px 0;
  user-select: none; letter-spacing: 2px; font-size: 12px;
}
.drag-handle:active { cursor: grabbing; }
.col-menu { width: 44px; }

.row-menu { position: relative; text-align: center; }
.row-menu-btn {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  font-size: 17px; line-height: 1; padding: 6px 8px; border-radius: var(--radius-sm);
  font-family: var(--font);
}
.row-menu-btn:hover { color: var(--text); background: var(--bg-raised); }
.menu-pop {
  position: absolute; right: 0; top: 100%; z-index: 60; min-width: 190px;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px;
  text-align: left;
}
.menu-pop button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); font-family: var(--font); font-size: 13.5px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.menu-pop button:hover { background: var(--bg-panel); }
.menu-pop button[data-danger] { color: var(--danger); }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  font-weight: 600; color: var(--ok);
}
.status-pill[data-status=departed] { color: var(--text-faint); }
.status-pill::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}

/* ---- connect card (numbers) --------------------------------- */
.connect-card {
  max-width: 480px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 26px; box-shadow: var(--shadow);
}
.note {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 18px;
  color: var(--text-dim); font-size: 12.5px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px;
}
.note-icon { flex: none; color: var(--ok); }

/* ---- numbers list ------------------------------------------- */
.num-row {
  display: grid; gap: 12px 16px; align-items: end;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr);
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.num-row:last-child { border-bottom: none; padding-bottom: 0; }
.num-e164 { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.num-head { display: flex; align-items: center; gap: 8px; }
.field label { margin-top: 0; }

/* ---- voicemail ---------------------------------------------- */
.vm-box + .vm-box { margin-top: 20px; }
.vm-box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.vm-item {
  display: grid; gap: 4px 14px; align-items: center; padding: 12px 0;
  grid-template-columns: auto 1fr auto; border-bottom: 1px solid var(--border);
}
.vm-item:last-child { border-bottom: none; }
.vm-item.unread .vm-from { font-weight: 700; color: var(--text); }
.vm-from { font-family: var(--mono); color: var(--text-dim); }
.vm-when { color: var(--text-faint); font-size: 12.5px; }
.vm-item audio { height: 34px; max-width: 260px; }
.vm-transcript {
  grid-column: 1 / -1; color: var(--text-dim); font-size: 13px;
  border-left: 2px solid var(--border-strong); padding-left: 10px; margin-top: 2px;
}
.dot-unread {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  display: inline-block;
}
.vm-item:not(.unread) .dot-unread { background: transparent; }

/* ---- settings ----------------------------------------------- */
.form-grid {
  display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.form-actions { margin-top: 20px; display: flex; align-items: center; gap: 12px; }
.member-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid;
  place-items: center; background: var(--bg-raised); border: 1px solid var(--border);
  color: var(--text-dim); font-weight: 700; font-size: 13px;
}
.member-main { flex: 1; min-width: 0; }
.member-name { font-weight: 600; }
.member-email { color: var(--text-faint); font-size: 12.5px; }
.invite-form {
  display: grid; gap: 12px; align-items: end; margin-top: 16px;
  grid-template-columns: minmax(200px, 2fr) minmax(120px, 1fr) auto;
}

/* ---- billing ------------------------------------------------ */
.segmented {
  display: inline-flex; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.segmented button {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 6px 16px; border-radius: 999px;
}
.segmented button[aria-pressed=true] { background: var(--bg-raised); color: var(--text); }

.plan-grid {
  display: grid; gap: 14px; margin-top: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.plan-card {
  display: flex; flex-direction: column; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 14px; padding: 22px;
}
.plan-card[data-featured] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.plan-name { font-size: 15px; font-weight: 700; }
.plan-price { font-size: 32px; font-weight: 700; margin: 10px 0 0; }
.plan-price span { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.plan-sub { color: var(--text-faint); font-size: 12.5px; min-height: 18px; }
.plan-features { list-style: none; padding: 0; margin: 16px 0 20px; flex: 1; }
.plan-features li {
  position: relative; padding-left: 20px; color: var(--text-dim);
  font-size: 13px; margin: 7px 0;
}
.plan-features li::before {
  content: '✓'; position: absolute; left: 0; color: var(--ok); font-weight: 700;
}
.plan-card .btn, .plan-card .btn-ghost { width: 100%; }

/* ---- small screens ------------------------------------------ */
@media (max-width: 640px) {
  .invite-form, .num-row { grid-template-columns: 1fr; }
  .tile-value { font-size: 26px; }
}
