/* ==========================================================================
   OneAccount (วันบัญชี) — Minimal Pastel SaaS Stylesheet
   Palette: Sage Pastel (#4A6B5D / #D8E2DC) + Cream Paper (#F6F4EF)
   Font: Sarabun (Google Fonts) with A- / A / A+ scaling & Warm Dark Mode
   ========================================================================== */

:root {
  --bg-main: #F6F4EF;
  --bg-card: #FFFFFF;
  --bg-subtle: #EDEAE2;
  --bg-input: #FAF9F6;

  --sage-primary: #4A6B5D;
  --sage-hover: #3B574B;
  --sage-soft: #D8E2DC;
  --sage-tint: #EEF3F0;

  --coral-main: #C46858;
  --coral-soft: #F9E6E2;
  --amber-main: #B87D2B;
  --amber-soft: #FAF0DF;

  --text-main: #28322C;
  --text-muted: #65726B;
  --border-soft: #E2DFD6;
  --shadow-card: 0 4px 18px rgba(42, 54, 48, 0.05);
  --shadow-float: 0 10px 28px rgba(42, 54, 48, 0.16);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --sidebar-w: 252px;
  --sidebar-collapsed-w: 74px;
  --bottom-nav-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Warm Dark Eye-Care Mode */
html[data-theme="dark"] {
  --bg-main: #1B201D;
  --bg-card: #242B27;
  --bg-subtle: #2D3631;
  --bg-input: #1F2622;

  --sage-primary: #8AB5A2;
  --sage-hover: #A3C9B8;
  --sage-soft: #31443B;
  --sage-tint: #27352E;

  --coral-main: #E58F80;
  --coral-soft: #422B27;
  --amber-main: #E4B268;
  --amber-soft: #3F3422;

  --text-main: #ECEAE3;
  --text-muted: #A4B0A9;
  --border-soft: #36413B;
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-float: 0 12px 30px rgba(0, 0, 0, 0.45);
}

/* Font Size Scaling (A- / A / A+) */
html[data-font-scale="sm"] {
  font-size: 14px;
}
html[data-font-scale="md"] {
  font-size: 16px;
}
html[data-font-scale="lg"] {
  font-size: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--sage-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   1. AUTH & PIN LOCK SCREEN
   ========================================================================== */
.auth-screen {
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, var(--sage-soft), var(--bg-main) 58%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  padding: 24px 22px;
  box-shadow: var(--shadow-card);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.brand-logo-lg {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--sage-primary);
  color: #F6F4EF;
  font-size: 2.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

html[data-theme="dark"] .brand-logo-lg,
html[data-theme="dark"] .brand-logo-sm {
  color: #1B201D;
}

.auth-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.auth-title .sub-th {
  font-weight: 500;
  color: var(--sage-primary);
  font-size: 1.05rem;
}

.auth-subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-company-box {
  margin-bottom: 14px;
}

.pin-display-wrap {
  text-align: center;
  margin: 12px 0 14px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 6px;
}

.pin-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--sage-primary);
  background: transparent;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.pin-dot.filled {
  background: var(--sage-primary);
  transform: scale(1.12);
}

.pin-dot.error {
  border-color: var(--coral-main);
  background: var(--coral-main);
}

.pin-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.pin-key {
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.08s ease;
  user-select: none;
}

.pin-key:active {
  transform: scale(0.96);
  background: var(--sage-soft);
}

.pin-key-fn {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-saas-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-footer-links {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   2. APP SHELL, DESKTOP SIDEBAR & MOBILE BOTTOM NAV
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

.desktop-sidebar {
  display: none;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 18px);
}

/* Sticky Top Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  padding: calc(8px + var(--safe-top)) 14px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.company-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--sage-tint);
  cursor: pointer;
  max-width: 260px;
}

.company-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage-primary);
  flex-shrink: 0;
}

.company-chip-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.period-filter-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.period-select {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  font-size: 0.85rem;
  font-weight: 500;
}

.fiscal-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: none;
}

.font-scale-group {
  display: inline-flex;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-input);
}

.font-btn {
  border: none;
  background: transparent;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

.font-btn.active {
  background: var(--sage-primary);
  color: #FFFFFF;
}

html[data-theme="dark"] .font-btn.active {
  color: #1B201D;
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  font-size: 0.82rem;
  cursor: pointer;
}

.btn-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mini-count {
  background: var(--sage-primary);
  color: #FFFFFF;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 0.72rem;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn-sm {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 0.95rem;
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.mob-nav-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 2px;
}

.mob-nav-item.active {
  color: var(--sage-primary);
  font-weight: 700;
}

.mob-ico {
  font-size: 1.2rem;
  line-height: 1;
}

.mob-lbl {
  font-size: 0.74rem;
}

.mob-nav-primary .mob-ico-plus {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--sage-primary);
  color: #FFFFFF;
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -8px;
  box-shadow: 0 4px 10px rgba(74, 107, 93, 0.3);
}

html[data-theme="dark"] .mob-nav-primary .mob-ico-plus {
  color: #1B201D;
}

/* Desktop / Tablet Landscape Sidebar Layout */
@media (min-width: 960px) {
  .fiscal-badge {
    display: inline-block;
  }

  .mobile-bottom-nav {
    display: none;
  }

  .main-wrapper {
    padding-bottom: 32px;
  }

  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 16px 12px;
    transition: width 0.2s ease;
    user-select: none;
  }

  .desktop-sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
  }

  .sidebar-brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 16px;
  }

  .brand-logo-sm {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--sage-primary);
    color: #F6F4EF;
    font-weight: 700;
    font-size: 1.45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
  }

  .sidebar-brand-text span {
    font-size: 0.76rem;
    color: var(--text-muted);
  }

  .desktop-sidebar.collapsed .sidebar-brand-text,
  .desktop-sidebar.collapsed .nav-txt,
  .desktop-sidebar.collapsed .sidebar-plan-label {
    display: none;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .nav-item:hover {
    background: var(--sage-tint);
    color: var(--text-main);
  }

  .nav-item.active {
    background: var(--sage-soft);
    color: var(--sage-primary);
    font-weight: 700;
  }

  html[data-theme="dark"] .nav-item.active {
    color: #ECEAE3;
  }

  .nav-ico {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
  }

  .sidebar-spacer {
    flex: 1;
    cursor: ew-resize;
  }

  .sidebar-bottom-box {
    padding-top: 10px;
    border-top: 1px solid var(--border-soft);
  }

  .plan-pill-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: var(--sage-tint);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
  }

  .status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--sage-primary);
    flex-shrink: 0;
  }
}

@media (max-width: 560px) {
  .hide-xs {
    display: none;
  }
}

/* ==========================================================================
   3. TABS, CARDS, GRIDS & TYPOGRAPHY
   ========================================================================== */
.tab-panel {
  display: none;
  padding: 16px 14px;
  max-width: 1260px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.hero-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--sage-tint) 100%);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.hero-entity-name {
  margin: 0 0 4px;
  font-size: 1.3rem;
  font-weight: 700;
}

.quick-actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qa-chip {
  padding: 8px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.qa-chip:hover {
  border-color: var(--sage-primary);
}

.qa-chip-sage {
  background: var(--sage-primary);
  color: #FFFFFF;
  border-color: var(--sage-primary);
}

html[data-theme="dark"] .qa-chip-sage {
  color: #1B201D;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.card-sub {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.kpi-grid,
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.kpi-grid-2,
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.kpi-card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.48rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.kpi-split {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 4px;
  border-top: 1px dashed var(--border-soft);
}

.mini-stat-card {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mini-stat-card span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.mini-stat-card strong {
  font-size: 1.2rem;
}

/* Progress Bar (VAT 1.8M Meter) */
.progress-track {
  width: 100%;
  height: 13px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  margin: 10px 0 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sage-primary), #6D9785);
  transition: width 0.35s ease;
}

.progress-fill.warn {
  background: linear-gradient(90deg, var(--amber-main), #D99B43);
}

.progress-fill.danger {
  background: linear-gradient(90deg, var(--coral-main), #DC7D6D);
}

.meter-foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.84rem;
}

.advance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.advance-amount {
  display: block;
  font-size: 1.45rem;
  color: var(--amber-main);
}

/* Tax Alert Boxes */
.tax-alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.tax-mini-box {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.tax-mini-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 0.88rem;
}

.tax-mini-val {
  margin: 0;
  font-size: 0.92rem;
}

/* ==========================================================================
   4. FORMS, BUTTONS, BADGES & SUBTABS
   ========================================================================== */
.mode-pills,
.subtab-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}

.mode-pill,
.subtab-btn,
.reporttab-btn {
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-pill.active,
.subtab-btn.active,
.reporttab-btn.active {
  background: var(--sage-primary);
  color: #FFFFFF;
  border-color: var(--sage-primary);
}

html[data-theme="dark"] .mode-pill.active,
html[data-theme="dark"] .subtab-btn.active,
html[data-theme="dark"] .reporttab-btn.active {
  color: #1B201D;
}

.ocr-attach-bar {
  background: var(--sage-tint);
  border: 1px dashed var(--sage-primary);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
}

.ocr-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.receipt-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.receipt-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}

.receipt-preview-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 0.84rem;
}

.entry-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

.req {
  color: var(--coral-main);
}

.input-control {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-control:focus {
  outline: none;
  border-color: var(--sage-primary);
  box-shadow: 0 0 0 3px rgba(74, 107, 93, 0.15);
}

.input-sm {
  padding: 6px 10px;
  font-size: 0.86rem;
}

.input-amount {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--sage-primary);
}

.sub-panel {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px;
}

.sub-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.check-row,
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.9rem;
  cursor: pointer;
}

.check-row input,
.switch-row input {
  margin-top: 4px;
  accent-color: var(--sage-primary);
  transform: scale(1.15);
}

.calc-hint {
  margin: 8px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.wht-summary-pill {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.92rem;
}

.drcr-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.form-submit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.08s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-lg {
  padding: 11px 20px;
  font-size: 0.98rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 4px 9px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
}

.btn-sage {
  background: var(--sage-primary);
  color: #FFFFFF;
}
.btn-sage:hover {
  background: var(--sage-hover);
}
html[data-theme="dark"] .btn-sage {
  color: #1B201D;
}

.btn-sage-outline {
  background: transparent;
  border-color: var(--sage-primary);
  color: var(--sage-primary);
}
.btn-sage-outline:hover {
  background: var(--sage-tint);
}

.btn-soft {
  background: var(--bg-subtle);
  border-color: var(--border-soft);
  color: var(--text-main);
}

.btn-coral-soft {
  background: var(--coral-soft);
  color: var(--coral-main);
}

/* Badges & Alerts */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge-sage {
  background: var(--sage-soft);
  color: var(--sage-primary);
}
html[data-theme="dark"] .badge-sage {
  color: #ECEAE3;
}

.badge-amber {
  background: var(--amber-soft);
  color: var(--amber-main);
}

.badge-coral {
  background: var(--coral-soft);
  color: var(--coral-main);
}

.badge-neutral {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.alert-box {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.alert-box p {
  margin: 3px 0 0;
}

.alert-coral {
  background: var(--coral-soft);
  border: 1px solid var(--coral-main);
  color: var(--text-main);
}

.alert-amber {
  background: var(--amber-soft);
  border: 1px solid var(--amber-main);
  color: var(--text-main);
  margin-bottom: 12px;
}

.notice-strip {
  background: var(--sage-soft);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

/* ==========================================================================
   5. TABLES & FINANCIAL STATEMENTS
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.compact-table th,
.compact-table td {
  padding: 7px 8px;
  font-size: 0.85rem;
}

.data-table tbody tr:hover {
  background: var(--sage-tint);
}

.summary-row td {
  background: var(--sage-tint);
  border-top: 2px solid var(--sage-primary);
}

.empty-cell {
  text-align: center !important;
  padding: 26px 12px !important;
  color: var(--text-muted);
}

.statement-paper {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 20px;
}

.st-header {
  text-align: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--sage-primary);
}

.st-header h3,
.st-header h4,
.st-header p {
  margin: 2px 0;
}

.st-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px dashed var(--border-soft);
}

.st-total {
  display: flex;
  justify-content: space-between;
  padding: 9px 4px;
  font-weight: 700;
  border-top: 1px solid var(--text-main);
  border-bottom: 3px double var(--text-main);
  margin-top: 4px;
}

.cit-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 0.9rem;
}

.cit-highlight {
  background: var(--sage-tint);
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border-bottom: none;
  margin-top: 8px;
}

.export-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

/* ==========================================================================
   6. VOICE BANNER, FLOATING MIC (60FPS) & MODALS
   ========================================================================== */
.voice-banner {
  margin: 10px 14px 0;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--sage-soft);
  border: 1px solid var(--sage-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.voice-banner-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.voice-badge {
  background: var(--sage-primary);
  color: #FFFFFF;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.voice-banner-texts {
  display: flex;
  flex-direction: column;
  font-size: 0.88rem;
}

.voice-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Floating Draggable Mic 60FPS */
.floating-mic {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  height: 50px;
  padding: 0 15px;
  border-radius: 999px;
  border: none;
  background: var(--sage-primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-float);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  will-change: transform;
}

html[data-theme="dark"] .floating-mic {
  color: #1B201D;
}

.floating-mic:active {
  cursor: grabbing;
}

.floating-mic.is-listening {
  background: var(--coral-main);
  color: #FFFFFF;
}

.mic-icon {
  font-size: 1.2rem;
}

.mic-tag {
  font-weight: 700;
  font-size: 0.85rem;
}

.floating-mic.is-listening .mic-wave {
  position: absolute;
  inset: -5px;
  border-radius: 999px;
  border: 2px solid var(--coral-main);
  animation: micPulse 1.2s infinite ease-out;
  pointer-events: none;
}

@keyframes micPulse {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.28);
    opacity: 0;
  }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 26, 23, 0.52);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-lg {
  max-width: 780px;
}

.modal-xl {
  max-width: 920px;
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.06rem;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Pricing Grid */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.price-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-input);
}

.price-card-featured {
  border: 2px solid var(--sage-primary);
  background: var(--sage-tint);
}

.price-card h4 {
  margin: 8px 0 4px;
  font-size: 1.15rem;
}

.price-tag {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--sage-primary);
}

.price-tag span {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
}

.price-features {
  list-style: none;
  padding: 0;
  margin: 12px 0 16px;
  font-size: 0.86rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qr-preview-box {
  background: #FFFFFF;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  text-align: center;
}

/* Toast */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 14px);
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast-item {
  background: #26312B;
  color: #F6F4EF;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow-float);
  font-size: 0.88rem;
  border-left: 4px solid var(--sage-soft);
}

/* Utility Helpers */
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-sage { color: var(--sage-primary) !important; }
.text-coral { color: var(--coral-main) !important; }
.text-amber { color: var(--amber-main) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 0.84rem; }
.mt-xs { margin-top: 6px; }
.mt-sm { margin-top: 12px; }
.mb-xs { margin-bottom: 6px; }
.mb-sm { margin-bottom: 12px; }
.mb-md { margin-bottom: 16px; }
.pt-xs { padding-top: 8px; }
.wrap-gap { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-heading { margin: 0 0 8px; font-size: 0.96rem; }
.block-label { display: block; font-size: 0.9rem; }
.divider { border: none; border-top: 1px solid var(--border-soft); margin: 12px 0; }

/* ==========================================================================
   7. A4 PRINT PREVIEW & CRISP @media print DOCUMENT ENGINE
   ========================================================================== */
.print-portal {
  display: none;
}

.print-preview-scroll {
  background: #D9D7D0;
  padding: 16px;
}

.a4-preview-sheet {
  background: #FFFFFF;
  color: #111111;
  max-width: 210mm;
  margin: 0 auto;
  padding: 14mm;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  line-height: 1.45;
}

/* Shared Document Classes inside A4 Sheet & Print Portal */
.doc-a4 {
  color: #111111;
  background: #FFFFFF;
  font-family: 'Sarabun', sans-serif;
  page-break-after: always;
}
.doc-a4:last-child {
  page-break-after: auto;
}

.doc-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 2px solid #2F483E;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.doc-company-block h2 {
  margin: 0 0 2px;
  font-size: 17px;
  color: #1E332A;
}

.doc-company-block p {
  margin: 1px 0;
  font-size: 12px;
  color: #333333;
}

.doc-title-box {
  text-align: right;
}

.doc-title-badge {
  display: inline-block;
  padding: 5px 12px;
  border: 1.5px solid #2F483E;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  color: #1E332A;
  margin-bottom: 4px;
}

.doc-meta-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.doc-box {
  border: 1px solid #999999;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 12.5px;
}

.doc-table th,
.doc-table td {
  border: 1px solid #888888;
  padding: 6px 8px;
}

.doc-table th {
  background: #EEF3F0 !important;
  color: #111111 !important;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* 4-Box Signature Footer for CPD / CPA / Managing Partner */
.doc-sign-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 22px;
  break-inside: avoid;
}

.doc-sign-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 22px;
  break-inside: avoid;
}

.doc-sign-box {
  border: 1px solid #999999;
  border-radius: 6px;
  padding: 10px 8px;
  text-align: center;
  font-size: 11.5px;
}

.sign-line {
  height: 36px;
  border-bottom: 1px dotted #555555;
  margin-bottom: 6px;
}

/* 50 Tawi Official-Style Bordered Sections */
.tawi-frame {
  border: 1.5px solid #222222;
  padding: 10px;
  font-size: 12px;
}

.tawi-section {
  border: 1px solid #555555;
  padding: 7px 9px;
  margin-bottom: 7px;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 11mm;
  }

  html,
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 12.5px !important;
  }

  #auth-screen,
  #app-shell,
  #floating-mic-btn,
  #modal-backdrop,
  #toast-container {
    display: none !important;
  }

  #print-portal {
    display: block !important;
    width: 100% !important;
  }
}