/* =============================================================
   Therapy Billing Suite — therapy-billing.css
   Mobile-first. Scoped to .tb-wrap. Calm green/teal theme.
   ============================================================= */

.tb-wrap *, .tb-wrap *::before, .tb-wrap *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}
.tb-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; color: #1e293b;
  max-width: 1100px; margin: 0 auto;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 16px; overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
.tb-header {
  padding: 18px 24px 16px;
  background: #f0fdf4; border-bottom: 1px solid #dcfce7;
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.tb-title    { font-size: 21px; font-weight: 700; color: #14532d; margin-bottom: 3px; }
.tb-subtitle { font-size: 13px; color: #4ade80; color: #166534; }
.tb-currency-wrap { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.tb-currency-label { font-size: 11px; font-weight: 600; color: #4d7c5f; text-transform: uppercase; letter-spacing: .05em; }
.tb-currency-select {
  padding: 8px 30px 8px 12px; border: 1.5px solid #bbf7d0;
  border-radius: 8px; font-size: 14px; font-weight: 600;
  color: #14532d; background: #fff; cursor: pointer;
  appearance: none; min-width: 110px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.tb-currency-select:focus { outline: none; border-color: #16a34a; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tb-tabs {
  display: flex; border-bottom: 1px solid #e2e8f0;
  background: #f8fafc; overflow-x: auto;
}
.tb-tab {
  flex: 1; min-width: 140px; padding: 14px 16px;
  border: none; background: transparent;
  font-size: 13.5px; font-weight: 600; color: #64748b;
  cursor: pointer; border-bottom: 3px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.tb-tab:hover   { color: #16a34a; background: #f0fdf4; }
.tb-tab.active  { color: #16a34a; border-bottom-color: #16a34a; background: #fff; }

/* ── Panel body ───────────────────────────────────────────── */
.tb-panel { display: block; }
.tb-panel-body {
  display: flex; flex-direction: column;
}
@media (min-width: 760px) {
  .tb-panel-body { flex-direction: row; align-items: flex-start; }
  .tb-form-col    { width: 52%; border-right: 1px solid #e2e8f0; }
  .tb-results-col { width: 48%; position: sticky; top: 0; }
  .tb-preview-panel { width: 48%; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
}

/* ── Form col ─────────────────────────────────────────────── */
.tb-form-col { padding: 20px; display: flex; flex-direction: column; gap: 12px; }

.tb-section-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #64748b;
}
.tb-optional { font-weight: 400; color: #94a3b8; font-size: 11px; }

.tb-info-box {
  background: #f0fdf4; border-left: 3px solid #16a34a;
  border-radius: 0 8px 8px 0; padding: 10px 14px;
  font-size: 12.5px; color: #14532d;
}

.tb-field { display: flex; flex-direction: column; gap: 5px; }
.tb-label { font-size: 12.5px; font-weight: 600; color: #334155; }

.tb-input {
  flex: 1; border: none; background: transparent;
  padding: 0 12px; height: 42px; font-size: 13.5px;
  color: #1e293b; outline: none; min-width: 0;
  font-family: inherit;
  -moz-appearance: textfield;
}
.tb-input::-webkit-outer-spin-button,
.tb-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.tb-input-plain {
  width: 100%; padding: 9px 12px; height: 42px;
  border: 1.5px solid #cbd5e1; border-radius: 8px;
  font-size: 13.5px; color: #1e293b; background: #f8fafc;
  outline: none; font-family: inherit;
  transition: border-color .18s;
  -moz-appearance: textfield;
}
.tb-input-plain::-webkit-outer-spin-button,
.tb-input-plain::-webkit-inner-spin-button { -webkit-appearance: none; }
.tb-input-plain:focus { border-color: #16a34a; background: #fff; }

.tb-textarea { resize: vertical; min-height: 60px; width: 100%; padding: 9px 12px; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 13.5px; color: #1e293b; background: #f8fafc; outline: none; font-family: inherit; transition: border-color .18s; }
.tb-textarea:focus { border-color: #16a34a; background: #fff; }

.tb-select {
  width: 100%; padding: 9px 32px 9px 12px; height: 42px;
  border: 1.5px solid #cbd5e1; border-radius: 8px;
  font-size: 13.5px; color: #1e293b; background: #f8fafc;
  appearance: none; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color .18s;
}
.tb-select:focus { border-color: #16a34a; background: #fff; }

.tb-prefix-wrap, .tb-suffix-wrap {
  display: flex; align-items: center;
  border: 1.5px solid #cbd5e1; border-radius: 8px;
  overflow: hidden; background: #f8fafc; transition: border-color .18s;
}
.tb-prefix-wrap:focus-within,
.tb-suffix-wrap:focus-within { border-color: #16a34a; background: #fff; }
.tb-prefix, .tb-suffix {
  padding: 0 10px; font-size: 13px; font-weight: 600;
  color: #64748b; background: #f1f5f9; height: 42px;
  display: flex; align-items: center; flex-shrink: 0;
}
.tb-prefix { border-right: 1px solid #e2e8f0; }
.tb-suffix  { border-left:  1px solid #e2e8f0; white-space: nowrap; }

.tb-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tb-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .tb-row-2, .tb-row-3 { grid-template-columns: 1fr; } }

/* Session type cards */
.tb-session-type-card {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 14px; display: flex;
  flex-direction: column; gap: 10px;
}
.tb-session-label { font-size: 12px; font-weight: 700; color: #334155; text-transform: uppercase; letter-spacing: .05em; }

/* Superbill session row */
.tb-sb-session-row {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 12px; margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.tb-sb-session-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
@media (max-width: 520px) { .tb-sb-session-grid { grid-template-columns: 1fr; } }
.tb-sb-row-del {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: #cbd5e1;
  font-size: 18px; cursor: pointer; padding: 0; line-height: 1;
  transition: color .15s;
}
.tb-sb-row-del:hover { color: #ef4444; }
.tb-add-row-btn {
  width: 100%; padding: 9px; margin-top: 4px;
  border: 1.5px dashed #cbd5e1; border-radius: 8px;
  background: none; color: #64748b; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.tb-add-row-btn:hover { border-color: #16a34a; color: #16a34a; }

/* ── Results col ──────────────────────────────────────────── */
.tb-results-col { padding: 20px; background: #f8fafc; display: flex; flex-direction: column; gap: 14px; }

.tb-hero-card {
  border-radius: 12px; padding: 20px; text-align: center; color: #fff;
}
.tb-hero-teal { background: #0f766e; }
.tb-hero-blue { background: #1e40af; }
.tb-hero-label  { font-size: 11px; font-weight: 700; opacity: .8; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px; }
.tb-hero-amount { font-size: 44px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.tb-hero-sub    { font-size: 12.5px; opacity: .75; margin-top: 6px; }

.tb-results-card, .tb-tip-box {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px;
}
.tb-results-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; margin-bottom: 10px; }
.tb-result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 13px; color: #475569;
  border-bottom: 1px solid #f8fafc;
}
.tb-result-row:last-child { border-bottom: none; }
.tb-result-border-top { border-top: 1.5px solid #e2e8f0; margin-top: 4px; padding-top: 10px; }
.tb-result-bold { font-weight: 700; font-size: 14.5px; color: #14532d; }
.tb-green { color: #16a34a; font-weight: 600; }
.tb-teal  { color: #0f766e; font-weight: 600; }
.tb-amber { color: #b45309; font-weight: 600; }
.tb-red   { color: #dc2626; }
.tb-tip-box { font-size: 12.5px; color: #475569; background: #fefce8; border-color: #fef08a; }
.tb-tip-box strong { color: #854d0e; }

/* Goal bar */
.tb-goal-bar-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; }
.tb-goal-bar-label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: #475569; margin-bottom: 8px; }
.tb-goal-bar-track { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.tb-goal-bar-fill  { height: 10px; background: #16a34a; border-radius: 6px; width: 0%; transition: width .5s ease; }

/* ── Preview panel (superbill) ────────────────────────────── */
.tb-preview-panel { padding: 20px; background: #f8fafc; display: flex; flex-direction: column; gap: 12px; }
.tb-preview-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #94a3b8; }
.tb-preview-doc {
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 20px; font-size: 12.5px;
  line-height: 1.6; color: #1e293b; min-height: 400px;
  flex: 1;
}
.tb-preview-actions { display: flex; gap: 8px; }

/* Buttons */
.tb-btn {
  padding: 10px 18px; border-radius: 8px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; border: none; transition: opacity .18s;
}
.tb-btn:hover { opacity: .86; }
.tb-btn-primary   { background: #16a34a; color: #fff; }
.tb-btn-secondary { background: #0f766e; color: #fff; }
.tb-btn-ghost     { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }

/* ── Superbill preview internals ──────────────────────────── */
.sb-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 2px solid #16a34a; }
.sb-practice-name { font-size: 16px; font-weight: 800; color: #14532d; }
.sb-practice-meta { font-size: 11px; color: #64748b; margin-top: 3px; line-height: 1.6; }
.sb-doc-label { font-size: 18px; font-weight: 800; color: #16a34a; letter-spacing: .04em; }
.sb-doc-date  { font-size: 11px; color: #64748b; text-align: right; margin-top: 3px; }

.sb-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: #f0fdf4; border-radius: 8px; padding: 12px; margin-bottom: 14px; font-size: 12px; }
.sb-party-lbl  { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #4ade80; color: #4d7c5f; margin-bottom: 3px; }
.sb-party-name { font-weight: 700; color: #1e293b; font-size: 12.5px; }
.sb-party-meta { color: #64748b; font-size: 11px; margin-top: 2px; line-height: 1.5; }

.sb-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 12px; }
.sb-table th { background: #14532d; color: #fff; padding: 7px 10px; text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.sb-table th.r { text-align: right; }
.sb-table td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.sb-table td.r { text-align: right; }
.sb-table tr:nth-child(even) td { background: #f8fafc; }

.sb-dx-box { background: #f0fdf4; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 12px; }
.sb-dx-title { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #4d7c5f; margin-bottom: 4px; letter-spacing: .05em; }

.sb-totals { max-width: 220px; margin-left: auto; margin-bottom: 12px; }
.sb-total-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12.5px; color: #475569; border-bottom: 1px solid #e2e8f0; }
.sb-total-row:last-child { border-bottom: none; font-weight: 700; font-size: 14px; color: #14532d; }

.sb-provider-box { background: #f8fafc; border-radius: 8px; padding: 10px 14px; font-size: 12px; margin-bottom: 12px; }
.sb-sig-line { border-bottom: 1px solid #334155; height: 28px; max-width: 220px; margin-bottom: 4px; }
.sb-notes { background: #f0fdf4; border-left: 3px solid #16a34a; border-radius: 0 6px 6px 0; padding: 8px 12px; font-size: 11.5px; color: #4d7c5f; white-space: pre-line; }
.sb-footer { text-align: center; margin-top: 14px; font-size: 10px; color: #cbd5e1; padding-top: 12px; border-top: 1px solid #f1f5f9; }

/* ── Modal ────────────────────────────────────────────────── */
.tb-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.tb-modal { background: #fff; border-radius: 12px; width: 100%; max-width: 820px; max-height: 90vh; overflow-y: auto; padding: 24px; }
.tb-modal-actions { display: flex; gap: 10px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 520px) {
  .tb-header  { flex-direction: column; padding: 16px; }
  .tb-form-col, .tb-results-col, .tb-preview-panel { padding: 16px; }
  .tb-title   { font-size: 18px; }
  .tb-hero-amount { font-size: 36px; }
  .sb-parties { grid-template-columns: 1fr; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .tb-form-col, .tb-tabs, .tb-header, .tb-preview-label,
  .tb-preview-actions, .tb-modal-actions { display: none !important; }
  .tb-panel-body { display: block; }
  .tb-preview-panel { width: 100%; background: #fff; padding: 0; position: static; max-height: none; }
  .tb-preview-doc { border: none; padding: 0; }
  .tb-wrap { border: none; border-radius: 0; }
  .tb-modal-overlay { position: static !important; background: none !important; padding: 0; }
  .tb-modal { box-shadow: none !important; max-height: none !important; padding: 0; }
}
