/* ==========================================================================
   ETERNAL COSMOS — Multi-Brand Invoicing & Payments Engine
   Typography: Headings (Plus Jakarta Sans), Body/UI (Inter)
   Palette (60-30-10):
     Primary 60%: Void Black (#08090C)
     Secondary 30%: Steel White (#F6F8FA)
     Accent 10%: Sovereign Cobalt (#004FE8)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --void-black: #08090C;
  --void-black-light: #12141A;
  --void-black-surface: #1B1E26;
  --steel-white: #F6F8FA;
  --steel-white-pure: #FFFFFF;
  --steel-white-dark: #EDF1F5;
  --steel-white-border: #E2E8F0;
  --steel-white-border-subtle: #ECEFF3;
  --sovereign-cobalt: #004FE8;
  --sovereign-cobalt-hover: #0043C7;
  --sovereign-cobalt-light: #EEF4FF;
  --sovereign-cobalt-glow: rgba(0, 79, 232, 0.15);
  --text-muted: #64748B;
  --text-dim: #94A3B8;
  --success-emerald: #059669;
  --success-light: #ECFDF5;
  --warning-amber: #D97706;
  --warning-light: #FFFBEB;
  --danger-rose: #E11D48;
  --danger-light: #FFF1F2;
  
  --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-body);
  color: var(--void-black);
  background-color: var(--steel-white);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography Rules */
h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: var(--font-heading);
  letter-spacing: -0.025em;
  font-weight: 700;
  color: var(--void-black);
}

.font-mono {
  font-family: var(--font-mono);
}

/* Base Layout Containers */
.app-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.25rem 3rem 1.25rem;
}

/* Institutional Header */
.inst-header {
  background-color: var(--void-black);
  color: var(--steel-white-pure);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 50;
}

.inst-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.inst-brand-mark {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.inst-logo-badge {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1E2330 0%, #08090C 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.inst-title-block h1 {
  color: #FFFFFF;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
}

.inst-title-block p {
  color: #94A3B8;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Header Action Buttons & Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background-color: rgba(255, 255, 255, 0.06);
  padding: 0.3rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #94A3B8;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.06);
}

.nav-tab-btn.active {
  color: #FFFFFF;
  background-color: var(--sovereign-cobalt);
  box-shadow: 0 2px 6px var(--sovereign-cobalt-glow);
}

.badge-hostinger {
  background: #22C55E;
  color: #FFFFFF;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Brand Operating Units Switcher Banner */
.brand-strip {
  background-color: var(--steel-white-pure);
  border-bottom: 1px solid var(--steel-white-border);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
}

.brand-strip-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-pills-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.brand-selector-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.brand-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--void-black);
  background-color: var(--steel-white);
  border: 1px solid var(--steel-white-border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.brand-pill-btn:hover {
  background-color: var(--steel-white-dark);
  border-color: #CBD5E1;
}

.brand-pill-btn.active {
  background-color: var(--void-black);
  color: #FFFFFF;
  border-color: var(--void-black);
  box-shadow: 0 2px 6px rgba(8, 9, 12, 0.15);
}

.brand-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.brand-status-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Grid Layout for Studio */
.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

/* UI Panel Cards (Secondary: Steel White Surfaces) */
.card-panel {
  background-color: var(--steel-white-pure);
  border: 1px solid var(--steel-white-border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(8, 9, 12, 0.04);
}

.card-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--steel-white-border-subtle);
}

.card-panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--void-black);
}

/* Forms & Input Elements */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  font-family: var(--font-body);
  color: var(--void-black);
  background-color: var(--steel-white);
  border: 1px solid var(--steel-white-border);
  border-radius: 8px;
  transition: all 0.15s ease;
  outline: none;
}

.form-control:focus {
  background-color: var(--steel-white-pure);
  border-color: var(--sovereign-cobalt);
  box-shadow: 0 0 0 3px var(--sovereign-cobalt-glow);
}

textarea.form-control {
  resize: vertical;
  min-height: 70px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 640px) {
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--sovereign-cobalt);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--sovereign-cobalt-hover);
  box-shadow: 0 2px 8px var(--sovereign-cobalt-glow);
}

.btn-secondary {
  background-color: var(--steel-white);
  color: var(--void-black);
  border: 1px solid var(--steel-white-border);
}

.btn-secondary:hover {
  background-color: var(--steel-white-dark);
  border-color: #CBD5E1;
}

.btn-dark {
  background-color: var(--void-black);
  color: #FFFFFF;
}

.btn-dark:hover {
  background-color: var(--void-black-light);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
}

/* Line Items Table in Editor */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.line-items-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--steel-white-border);
}

.line-items-table td {
  padding: 0.4rem;
  vertical-align: middle;
}

.btn-remove-line {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  transition: color 0.15s;
}

.btn-remove-line:hover {
  color: var(--danger-rose);
  background-color: var(--danger-light);
}

/* Invoice Preview Canvas (Steel White Frame) */
.preview-canvas-wrapper {
  position: sticky;
  top: 5rem;
}

.preview-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.preview-canvas-frame {
  background-color: var(--steel-white-dark);
  border: 1px solid var(--steel-white-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: inset 0 2px 6px rgba(8, 9, 12, 0.03);
  display: flex;
  justify-content: center;
}

/* The Paper Invoice Sheet */
.paper-invoice {
  background-color: #FFFFFF;
  width: 100%;
  max-width: 650px;
  min-height: 820px;
  border-radius: 10px;
  border: 1px solid #E6EAF0;
  box-shadow: 0 10px 25px -5px rgba(8, 9, 12, 0.07), 0 8px 10px -6px rgba(8, 9, 12, 0.04);
  padding: 2.25rem 2.25rem 2rem 2.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  font-size: 0.85rem;
}

/* Paper Document Header */
.paper-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--steel-white-border-subtle);
  margin-bottom: 1.5rem;
}

.paper-brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.paper-brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--void-black);
  line-height: 1.2;
}

.paper-parent-claim {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.paper-meta-right {
  text-align: right;
}

.paper-doc-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--void-black);
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 1;
}

.paper-inv-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.paper-date-row {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.paper-status-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  margin-top: 0.5rem;
}

.status-paid {
  background-color: var(--success-light);
  color: var(--success-emerald);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.status-sent {
  background-color: var(--sovereign-cobalt-light);
  color: var(--sovereign-cobalt);
  border: 1px solid rgba(0, 79, 232, 0.2);
}

.status-draft {
  background-color: var(--steel-white-dark);
  color: var(--text-muted);
  border: 1px solid var(--steel-white-border);
}

/* Paper Parties (Billed To & Issued By) */
.paper-parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.paper-party-col h4 {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.party-client-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--void-black);
}

.party-detail-text {
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.45;
}

/* Paper Line Items */
.paper-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.paper-table thead th {
  border-bottom: 1.5px solid var(--void-black);
  padding: 0.5rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--void-black);
}

.paper-table tbody td {
  padding: 0.7rem 0.25rem;
  border-bottom: 1px solid var(--steel-white-border-subtle);
  font-size: 0.8rem;
}

.paper-table .col-desc {
  width: 55%;
}

.paper-table .col-qty {
  width: 12%;
  text-align: center;
  font-family: var(--font-mono);
}

.paper-table .col-rate {
  width: 18%;
  text-align: right;
  font-family: var(--font-mono);
}

.paper-table .col-amt {
  width: 15%;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
}

.item-desc-title {
  font-weight: 600;
  color: var(--void-black);
}

.item-desc-tax {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Paper Financial Calculation Summary */
.paper-summary-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

.paper-summary-box {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #475569;
}

.summary-row-grand {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--void-black);
  border-top: 1.5px solid var(--void-black);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

/* Paper Payment Link Banner */
.paper-pay-banner {
  background: var(--steel-white);
  border: 1px solid var(--steel-white-border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.paper-pay-info h5 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--void-black);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.paper-pay-info p {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.pay-online-btn {
  background-color: var(--sovereign-cobalt);
  color: #FFFFFF;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  transition: all 0.15s;
}

.pay-online-btn:hover {
  background-color: var(--sovereign-cobalt-hover);
  box-shadow: 0 2px 8px var(--sovereign-cobalt-glow);
}

/* Paper Notes */
.paper-notes-box {
  background-color: var(--steel-white);
  border: 1px dashed var(--steel-white-border);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 1.5rem;
  font-size: 0.72rem;
  color: #475569;
  line-height: 1.5;
}

.paper-notes-box h6 {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

/* Paper Institutional Footer */
.paper-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--steel-white-border-subtle);
  text-align: center;
}

.paper-footer p {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.paper-footer-strong {
  font-weight: 600;
  color: var(--void-black);
}

/* Ledger View */
.ledger-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--steel-white-pure);
  border: 1px solid var(--steel-white-border);
  border-radius: 12px;
  padding: 1.25rem;
}

.stat-card-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-card-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--void-black);
  margin-top: 0.35rem;
}

.stat-card-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th {
  background-color: var(--steel-white);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--steel-white-border);
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--steel-white-border-subtle);
  color: #334155;
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: #FAFCFE;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(8, 9, 12, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: #FFFFFF;
  border-radius: 16px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--steel-white-border);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--steel-white-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--steel-white-border-subtle);
  background-color: var(--steel-white);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Code Snippet Box */
.code-box {
  background: var(--void-black);
  color: #E2E8F0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.5;
  margin: 0.75rem 0;
  border: 1px solid #1E293B;
  position: relative;
}

/* PRINT STYLESHEET (Clean A4 Paper Export) */
@media print {
  body {
    background-color: #FFFFFF !important;
    color: #000000 !important;
  }

  .no-print, .inst-header, .brand-strip, .preview-top-bar, .nav-tabs, .btn, .card-panel {
    display: none !important;
  }

  .studio-grid {
    display: block !important;
  }

  .preview-canvas-wrapper, .preview-canvas-frame {
    position: static !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .paper-invoice {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    padding: 0 !important;
    width: 100% !important;
  }

  @page {
    size: A4 portrait;
    margin: 1.2cm;
  }
}
