/* Consolish Accounting App - Financial Management Design System */
:root {
  /* System typography with tabular numbers for accounting accuracy */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;

  /* Slate Core Palette */
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --white:     #ffffff;

  /* Semantic Financial Colors */
  /* Emerald: Positive Cash, Earned Revenue, Healthy Margins */
  --emerald-bg:     #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-text:   #065f46;
  --emerald-brand:  #0f766e;
  --emerald-hover:  #115e59;

  /* Rose: OPEX, Negative Margins, Risk, Overdue, Void */
  --rose-bg:        #fef2f2;
  --rose-border:    #fecdd3;
  --rose-text:      #9f1239;
  --rose-btn:       #be123c;
  --rose-hover:     #9f1239;

  /* Indigo: Cash Collected, Direct Labor Efficiency (LER), Operational Ratios */
  --indigo-bg:      #eef2ff;
  --indigo-border:  #c7d2fe;
  --indigo-text:    #3730a3;
  --indigo-accent:  #4338ca;

  /* Amber: Accounts Receivable, Forecast Pipeline, Watch Status */
  --amber-bg:       #fffbeb;
  --amber-border:   #fde68a;
  --amber-text:     #92400e;

  /* Soft Lemon: Subtle Alerts, Warnings */
  --lemon-bg:       #fef9c3;
  --lemon-border:   #fef08a;
  --lemon-text:     #854d0e;

  /* Radii strictly capped at 8px */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Base Setup */
  font-family: var(--font-sans);
  color: var(--slate-800);
  background-color: var(--slate-50);
  font-size: 15px;
  line-height: 1.5;
  color-scheme: light;
}

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

html {
  background-color: var(--slate-50);
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--slate-50);
  color: var(--slate-800);
  font-family: var(--font-sans);
  line-height: 1.5;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.menu-open {
  overflow: hidden;
  touch-action: none;
}

/* Links & Typography */
a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  touch-action: manipulation;
}

/* Accessible focus visible rings */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.data-table-wrap:focus-visible,
.help-tip:focus-visible {
  outline: 2px solid var(--emerald-brand);
  outline-offset: 2px;
}

/* Tabular numbers for all financial figures */
.value,
.summary-item strong,
.data-table td,
.metric-row span:last-child,
input[inputmode="decimal"],
.badge {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Frame Layout */
.app-frame {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
}

/* Sidebar (Desktop) */
.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background: var(--slate-800);
  color: var(--slate-300);
  padding: 1rem 0.75rem;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--white);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
}

.brand span {
  color: #6ee7b7;
  font-weight: 500;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--emerald-brand);
  color: var(--white);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  gap: 0.15rem;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: #94a3b8;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  min-height: 38px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-weight: 700;
}

.logout-form {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.75rem;
}

.logout {
  color: #fca5a5;
}

.logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--white);
}

.menu-close, .menu-scrim {
  display: none;
}

/* Main Content Area */
.main-content {
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--slate-200);
  background: var(--white);
  padding: 0 1.75rem;
}

.topbar-title {
  display: grid;
  min-width: 0;
  gap: 0.05rem;
}

.topbar-title strong {
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0;
}

.topbar-title span {
  overflow: hidden;
  color: var(--slate-500);
  font-size: 0.74rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip {
  display: grid;
  min-width: 0;
  max-width: 260px;
  text-align: right;
  line-height: 1.3;
}

.user-chip span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--slate-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip small {
  color: var(--slate-500);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--slate-700);
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 38px;
  cursor: pointer;
}

.menu-toggle span:first-child {
  font-size: 1rem;
  line-height: 1;
}

/* Page Layout */
.page-content {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 3rem;
  box-sizing: border-box;
}

/* Page Heading */
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-heading > div:first-child {
  min-width: 0;
  flex: 1 1 300px;
}

.page-heading h1 {
  margin: 0;
  color: var(--slate-900);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-heading p {
  max-width: 780px;
  margin: 0.3rem 0 0;
  color: var(--slate-500);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* Button & Action System */
.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.primary-button {
  background: var(--emerald-brand);
  color: var(--white);
  border-color: var(--emerald-brand);
}

.primary-button:hover {
  background: var(--emerald-hover);
  border-color: var(--emerald-hover);
}

.secondary-button {
  border-color: var(--slate-300);
  background: var(--white);
  color: var(--slate-700);
}

.secondary-button:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
  color: var(--slate-900);
}

.danger-button {
  background: var(--rose-btn);
  color: var(--white);
  border-color: var(--rose-btn);
}

.danger-button:hover {
  background: var(--rose-hover);
  border-color: var(--rose-hover);
}

/* Cards & Containers */
.card, .form-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.card {
  padding: 1rem 1.15rem;
}

.card h2, .card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.3;
}

/* KPI Cards & Financial Hierarchy */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.kpi {
  min-width: 0;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: var(--white);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.kpi .label {
  color: var(--slate-600);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.kpi .value {
  margin: 0.5rem 0 0.25rem;
  color: var(--slate-900);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.kpi .detail {
  color: var(--slate-500);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.35;
}

/* Semantic KPI Variants */
.kpi.emerald {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
}
.kpi.emerald .label {
  color: var(--emerald-text);
}

.kpi.indigo {
  background: var(--indigo-bg);
  border-color: var(--indigo-border);
}
.kpi.indigo .label {
  color: var(--indigo-text);
}

.kpi.amber {
  background: var(--amber-bg);
  border-color: var(--amber-border);
}
.kpi.amber .label {
  color: var(--amber-text);
}

.kpi.rose {
  background: var(--rose-bg);
  border-color: var(--rose-border);
}
.kpi.rose .label {
  color: var(--rose-text);
}

/* Content Grid & Stack Layout */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--slate-100);
}

.section-title h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
}

.section-title a, .data-table a, .table-link {
  color: var(--emerald-brand);
  font-weight: 600;
  font-size: 0.84rem;
}

.section-title a:hover, .data-table a:hover, .table-link:hover {
  color: var(--emerald-hover);
  text-decoration: underline;
}

/* Metric Row / Compact Key-Value List */
.metric-list {
  display: grid;
  gap: 0.5rem;
}

.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--slate-100);
  font-size: 0.86rem;
}

.metric-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.metric-row span:first-child {
  min-width: 0;
  color: var(--slate-600);
  font-weight: 500;
}

.metric-row span:last-child {
  font-weight: 700;
  color: var(--slate-900);
  text-align: right;
  overflow-wrap: anywhere;
}

/* Notices / Alerts */
.notice {
  margin: 0 0 1rem;
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  font-size: 0.86rem;
  line-height: 1.45;
  border: 1px solid transparent;
  border-left-width: 4px;
}

.notice-success {
  border-color: var(--emerald-border);
  border-left-color: var(--emerald-brand);
  background: var(--emerald-bg);
  color: var(--emerald-text);
}

.notice-error {
  border-color: var(--rose-border);
  border-left-color: var(--rose-btn);
  background: var(--rose-bg);
  color: var(--rose-text);
}

.notice-info {
  border-color: var(--indigo-border);
  border-left-color: var(--indigo-accent);
  background: var(--indigo-bg);
  color: var(--indigo-text);
}

/* Form Styling */
.form-card {
  margin-bottom: 1rem;
  padding: 1.15rem 1.25rem;
}

.form-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.3;
}

.form-card > p, .form-hint {
  margin: 0.35rem 0 0.85rem;
  color: var(--slate-500);
  font-size: 0.84rem;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.full {
  grid-template-columns: 1fr;
}

.field-full {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin: 0 0 0.35rem;
  color: var(--slate-700);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--slate-900);
  padding: 0.55rem 0.65rem;
  line-height: 1.3;
  font-size: 0.88rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input, select {
  min-height: 38px;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

input::placeholder, textarea::placeholder {
  color: var(--slate-400);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--emerald-brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

input[readonly], input:disabled, select:disabled, textarea:disabled {
  background-color: var(--slate-100);
  color: var(--slate-500);
  cursor: not-allowed;
  border-color: var(--slate-200);
}

/* Checkbox and Radios */
.check-row {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  color: var(--slate-700);
  font-size: 0.86rem;
  font-weight: 600;
  min-height: 38px;
  cursor: pointer;
  user-select: none;
}

.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--emerald-brand);
}

/* Form Action Buttons Bar */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.15rem;
  border-top: 1px solid var(--slate-200);
  padding-top: 0.85rem;
}

.form-actions form {
  margin: 0;
}

/* Tables & Scroll Containers */
.data-table-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: var(--white);
  scrollbar-color: var(--slate-300) var(--slate-100);
  scrollbar-width: thin;
}

.data-table-wrap::-webkit-scrollbar {
  height: 6px;
}

.data-table-wrap::-webkit-scrollbar-track {
  background: var(--slate-100);
}

.data-table-wrap::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: var(--radius-sm);
}

/* Scroll indicator cues */
.data-table-wrap.has-overflow::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 16px;
  pointer-events: none;
  background: rgba(248, 250, 252, 0.88);
  box-shadow: -7px 0 8px -8px rgba(15, 23, 42, 0.55);
  transition: opacity 0.2s ease;
}

.data-table-wrap.is-scrolled-end::after {
  opacity: 0;
}

.data-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--slate-200);
  background: var(--slate-50);
  color: var(--slate-600);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.25;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
  line-height: 1.4;
  color: var(--slate-800);
}

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

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td small {
  display: block;
  color: var(--slate-500);
  font-size: 0.75rem;
}

/* Inline action forms inside table cells */
.inline-form, .data-table td form {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  margin: 0;
}

.data-table td form input[type="text"],
.data-table td form input:not([type]),
.data-table td form select {
  width: auto;
  max-width: 140px;
  min-height: 30px;
  height: 30px;
  padding: 0.2rem 0.45rem;
  font-size: 0.78rem;
}

.data-table td form button,
.data-table td .danger-button,
.data-table td .secondary-button {
  min-height: 30px;
  height: 30px;
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 600;
}

.danger-link {
  color: var(--rose-btn);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-weight: 600;
}

.danger-link:hover {
  text-decoration: underline;
  color: var(--rose-hover);
}

/* Search and Filter Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.toolbar > div {
  min-width: 140px;
}

.toolbar input, .toolbar select {
  max-width: 240px;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.good {
  background: var(--emerald-bg);
  color: var(--emerald-text);
  border-color: var(--emerald-border);
}

.badge.watch {
  background: var(--amber-bg);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.badge.risk {
  background: var(--rose-bg);
  color: var(--rose-text);
  border-color: var(--rose-border);
}

.badge.neutral {
  background: var(--slate-100);
  color: var(--slate-700);
  border-color: var(--slate-300);
}

/* Accessible Help Tip */
.help-tip {
  display: inline-flex;
  width: 15px;
  height: 15px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--slate-400);
  border-radius: 50%;
  color: var(--slate-500);
  font-size: 0.65rem;
  font-weight: 700;
  vertical-align: middle;
  cursor: help;
  margin-left: 0.25rem;
  line-height: 1;
}

.help-tip:hover, .help-tip:focus {
  border-color: var(--emerald-brand);
  color: var(--emerald-brand);
  background: var(--emerald-bg);
}

/* Summary Grid & Items */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.summary-item {
  min-width: 0;
  border-radius: var(--radius-sm);
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.summary-item small {
  display: block;
  color: var(--slate-600);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.3;
}

.summary-item strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--slate-900);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.muted {
  color: var(--slate-500);
}

/* Empty States */
.empty, .empty-state {
  padding: 2.25rem 1rem;
  text-align: center;
  color: var(--slate-500);
  font-size: 0.88rem;
}

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
  align-items: center;
}

.pagination a {
  display: inline-flex;
  min-width: 36px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  padding: 0.35rem 0.65rem;
  color: var(--slate-700);
  font-size: 0.84rem;
  font-weight: 600;
}

.pagination a:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
  color: var(--slate-900);
}

/* Authentication Page */
.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem 1rem;
  background: var(--slate-100);
}

.auth-shell .panel {
  width: 100%;
  max-width: 390px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  background: var(--white);
  padding: 1.75rem 1.6rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.auth-shell .panel-header {
  margin-bottom: 1.25rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  color: var(--slate-800);
  font-size: 1.05rem;
}

.auth-brand strong {
  font-weight: 700;
}

.auth-brand strong span {
  color: var(--emerald-brand);
}

.auth-brand-badge {
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
}

.auth-shell .panel h1 {
  margin: 0;
  color: var(--slate-900);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.25;
}

.auth-shell .panel > p,
.auth-shell .panel-header p {
  margin: 0.35rem 0 0;
  color: var(--slate-500);
  font-size: 0.84rem;
}

.auth-shell form {
  display: grid;
  gap: 0.75rem;
}

.auth-shell form button {
  min-height: 42px;
  margin-top: 0.4rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--emerald-brand);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.auth-shell form button:hover {
  background: var(--emerald-hover);
}

/* Print Reports */
.print-report {
  display: grid;
  gap: 1.25rem;
}

.print-report section {
  break-inside: avoid;
}

.report-header {
  border-bottom: 2px solid var(--slate-800);
  padding-bottom: 0.75rem;
}

.report-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--slate-900);
}

.report-header p, .print-report footer {
  color: var(--slate-500);
  font-size: 0.82rem;
}

.print-report h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
}

.print-report footer {
  border-top: 1px solid var(--slate-300);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

/* Printable transaction records */
.receipt-document {
  display: grid;
  max-width: 1020px;
  gap: 1rem;
  margin: 0 auto;
  padding: 1.25rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: var(--white);
}

.receipt-header,
.receipt-parties {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
}

.receipt-header {
  align-items: flex-start;
  padding-bottom: 0.85rem;
  border-bottom: 2px solid var(--slate-800);
}

.receipt-header h1 {
  margin: 0;
  color: var(--slate-900);
  font-size: 1.3rem;
}

.invoice-company {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.invoice-logo {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.invoice-logo-fallback {
  display: grid;
  place-items: center;
  background: var(--emerald-brand);
  color: var(--white);
  font-size: 1.5rem;
  font-weight: 800;
}

.invoice-company p {
  margin: 0.2rem 0 0;
  color: var(--slate-500);
  font-size: 0.82rem;
  line-height: 1.45;
}

.receipt-header p,
.receipt-header small,
.receipt-parties small,
.receipt-parties span,
.receipt-footer {
  color: var(--slate-500);
  font-size: 0.82rem;
}

.receipt-header > div:last-child {
  display: grid;
  justify-items: end;
  gap: 0.15rem;
  text-align: right;
}

.receipt-parties > div {
  display: grid;
  flex: 1 1 0;
  gap: 0.15rem;
  min-width: 0;
}

.receipt-parties strong {
  color: var(--slate-900);
  font-size: 0.95rem;
}

.receipt-section h2 {
  margin: 0 0 0.5rem;
  color: var(--slate-900);
  font-size: 0.95rem;
}

.receipt-footer {
  padding-top: 0.85rem;
  border-top: 1px solid var(--slate-300);
}

.receipt-footer strong {
  color: var(--rose-text);
}

/* Subscriptions in Project Form */
.subscription-entry {
  padding-top: 0.75rem;
  border-top: 1px dashed var(--slate-200);
}

.subscription-entry:first-child {
  border-top: 0;
  padding-top: 0;
}

.component-editor {
  margin: 0.9rem 0 0;
  padding: 1rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.component-editor legend {
  padding: 0 0.35rem;
  color: var(--slate-700);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: capitalize;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* Medium Desktop & Tablet Landscape (<= 1100px) */
@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .content-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  }
}

/* Tablet Portrait & Mobile Breakpoint (<= 860px) */
@media (max-width: 860px) {
  .app-frame {
    display: block;
  }

  /* Off-canvas mobile drawer */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 290px);
    z-index: 100;
    padding: 1rem 0.85rem;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 12px 0 32px rgba(15, 23, 42, 0.25);
  }

  .menu-open .sidebar {
    transform: translateX(0);
  }

  .menu-scrim {
    position: fixed;
    inset: 0;
    z-index: 99;
    border: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    display: block;
    margin: 0;
    padding: 0;
  }

  .menu-open .menu-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    background: var(--slate-700);
    color: var(--white);
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
    min-height: 34px;
    cursor: pointer;
  }

  .menu-close:hover {
    background: var(--slate-600);
  }

  /* Topbar on mobile */
  .topbar {
    min-height: 54px;
    padding: 0 1rem;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar-title {
    flex: 1;
  }

  .user-chip {
    display: none;
  }

  /* Page content padding */
  .page-content {
    padding: 1.15rem 1rem 2.5rem;
  }

  /* Page Heading adjustments */
  .page-heading {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .page-heading .form-actions {
    justify-content: stretch;
    width: 100%;
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
  }

  .page-heading .form-actions > a,
  .page-heading .form-actions > button,
  .page-heading > .primary-button,
  .page-heading > .secondary-button {
    flex: 1 1 auto;
    text-align: center;
  }

  /* KPI Grid */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .kpi {
    padding: 0.8rem;
  }

  .kpi .value {
    font-size: 1.12rem;
  }

  /* Content Grid & Cards */
  .content-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-top: 0.85rem;
  }

  .stack {
    gap: 0.85rem;
  }

  .card {
    padding: 0.9rem;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .form-card {
    padding: 1rem;
  }

  /* Form columns collapse on mobile */
  .form-grid, .form-grid.two {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .field-full {
    grid-column: auto;
  }

  .form-actions {
    display: flex;
    flex-direction: column-reverse;
    width: 100%;
    gap: 0.5rem;
  }

  .form-actions > a,
  .form-actions > button,
  .form-actions form,
  .form-actions form button {
    width: 100%;
    min-height: 42px;
  }

  /* Toolbar Filter Stack */
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .toolbar > div {
    min-width: 0;
    width: 100%;
  }

  .toolbar input, .toolbar select {
    max-width: none;
    width: 100%;
  }

  .toolbar .secondary-button, .toolbar .primary-button {
    width: 100%;
    min-height: 40px;
  }

  .data-table {
    min-width: 620px;
    font-size: 0.82rem;
  }

  .data-table th, .data-table td {
    padding: 0.6rem 0.65rem;
  }
}

/* Small Smartphone Viewports (<= 480px, including 390px, 375px, 320px) */
@media (max-width: 480px) {
  .page-content {
    padding: 1rem 0.75rem 2rem;
  }

  .topbar {
    padding: 0 0.75rem;
  }

  .topbar-title strong {
    font-size: 0.9rem;
  }

  .topbar-title span {
    max-width: 180px;
    font-size: 0.7rem;
  }

  .page-heading h1 {
    font-size: 1.3rem;
  }

  .receipt-document {
    padding: 0.9rem;
  }

  .receipt-header,
  .receipt-parties {
    flex-direction: column;
  }

  .invoice-company {
    align-items: center;
  }

  .receipt-header > div:last-child {
    justify-items: start;
    text-align: left;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .kpi .value {
    font-size: 1.18rem;
  }

  .summary-grid {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .section-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .section-title a {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  .metric-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .metric-row span:last-child {
    text-align: left;
  }

  .auth-shell {
    padding: 1rem 0.75rem;
    place-items: start center;
    padding-top: max(2rem, 8vh);
  }

  .auth-shell .panel {
    padding: 1.25rem 1rem;
  }

  .auth-shell .panel h1 {
    font-size: 1.2rem;
  }
}

/* Ultra-compact screens (320px) */
@media (max-width: 340px) {
  .page-content {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .topbar {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .kpi, .card, .form-card {
    padding: 0.75rem 0.65rem;
  }
}

/* ==========================================================================
   PRINT MEDIA STYLESHEET
   ========================================================================== */
@media print {
  @page {
    margin: 12mm;
    size: auto;
  }

  *, *::before, *::after {
    color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sidebar,
  .topbar,
  .menu-scrim,
  .no-print,
  .menu-toggle,
  .form-actions,
  .toolbar,
  .pagination,
  button {
    display: none !important;
  }

  .app-frame {
    display: block !important;
  }

  .main-content {
    display: block !important;
  }

  .page-content {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .print-report {
    display: block !important;
  }

  .print-report section {
    margin: 0 0 10pt !important;
    break-inside: avoid !important;
  }

  .card {
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .summary-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6pt !important;
  }

  .summary-item {
    border: 1px solid var(--slate-300) !important;
    background: var(--white) !important;
    padding: 5pt !important;
  }

  .data-table-wrap {
    overflow: visible !important;
    border: 1px solid var(--slate-300) !important;
  }

  .data-table {
    min-width: 0 !important;
    width: 100% !important;
    font-size: 7.5pt !important;
  }

  .data-table th, .data-table td {
    padding: 3.5pt 5pt !important;
    border-bottom: 1px solid var(--slate-200) !important;
  }

  .data-table-wrap.has-overflow::after {
    display: none !important;
  }

  .notice {
    font-size: 7.5pt !important;
    padding: 4pt 6pt !important;
  }

  .print-report footer {
    margin-top: 12pt !important;
    font-size: 7pt !important;
  }

  .receipt-document {
    display: block !important;
    max-width: none !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  .receipt-document > * {
    margin: 0 0 10pt !important;
    break-inside: avoid !important;
  }
}
