* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  --footer-height: 72px;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.38;
  padding-bottom: var(--footer-height);
}

a {
  color: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  letter-spacing: 0;
}

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

.app-shell {
  min-height: 100vh;
}

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid #1E1E1E;
  background: color-mix(in srgb, var(--nav-bg) 98%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}

.brand-stack {
  display: grid;
  gap: 2px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex: 0 0 auto;
  display: block;
  max-width: 24px;
  max-height: 24px;
}

.brand-line img.brand-logo {
  width: 24px !important;
  height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
}

.brand-eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--nav-text-muted);
  font-weight: 700;
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--nav-text);
}

.brand-subtitle {
  font-size: 11px;
  color: var(--nav-text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-action-link,
.topbar-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  color: var(--nav-text-muted);
  text-decoration: none;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 0 9px;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.topbar-action-icon {
  min-width: 34px;
  width: 34px;
  padding: 0;
  font-size: 16px;
}

.topbar-action-link:hover,
.topbar-action-link:focus,
.topbar-action-icon:hover,
.topbar-action-icon:focus {
  color: var(--nav-text);
  background: rgba(255, 255, 255, 0.08);
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0 14px 8px;
}

.app-nav-link {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 36px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: var(--nav-text-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.app-nav-link.is-active {
  color: var(--nav-text);
  border-color: rgba(255, 255, 255, 0.54);
  background: rgba(255, 255, 255, 0.16);
}

.app-nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: -6px;
  height: 2px;
  border-radius: 999px;
  background: var(--active-indicator);
}

.content {
  padding: 12px;
  padding-bottom: 12px;
}

.panel,
.auth-card,
.summary-chip,
.disbursement-card,
.report-card,
.expense-entry,
.info-card,
.preview-list > div {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.dashboard-summary-grid,
.disbursement-list,
.report-card-grid,
.expense-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-chip {
  display: grid;
  gap: 7px;
  padding: 12px;
  min-height: 94px;
}

.summary-chip span {
  color: var(--text-light);
  font-size: 12px;
  font-weight: 600;
}

.summary-chip strong {
  font-size: clamp(22px, 4.8vw, 30px);
  line-height: 1.05;
  color: var(--text);
  font-weight: 700;
}

.summary-chip-main {
  display: grid;
  gap: 6px;
}

.dashboard-summary-grid .summary-chip {
  min-height: 86px;
  padding: 12px;
}

.summary-chip-action {
  width: auto;
  justify-self: start;
}

.panel {
  margin-bottom: 12px;
  padding: 14px;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.panel-heading-row {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.muted,
.auth-subtitle,
.topbar p,
small {
  color: var(--text-light);
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

label {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface-1);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.no-zoom {
  font-size: 16px;
}

button,
.btn-primary,
.btn-secondary,
.btn-danger,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: all 0.2s ease;
}

.btn-primary {
  color: var(--white);
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary,
.icon-btn {
  color: var(--primary);
  border-color: var(--border);
  background: var(--white);
}

.btn-secondary:hover,
.icon-btn:hover {
  background: var(--primary-soft-2);
}

[data-theme="dark"] .btn-primary {
  color: #050505;
}

[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .icon-btn {
  color: #141414;
  background: #F5F5F2;
  border-color: #5A5A5A;
}

[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .icon-btn:hover {
  background: #FFFFFF;
}

.theme-icon-btn {
  min-width: 36px;
  width: 36px;
  padding: 0;
}

.button-link {
  width: auto;
}

.inline-action-form {
  margin-top: 10px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
}

.link-button:hover {
  color: var(--primary-dark);
}

.alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.alert-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--border);
}

.alert-success {
  color: var(--success);
  background: var(--success-soft);
  border-color: var(--border);
}

.alert-warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: var(--border);
}

.status-pill,
.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.count-pill {
  color: var(--text-light);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.status-pill.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--border);
}

.status-pill.is-inactive {
  color: var(--inactive-text);
  background: var(--inactive-bg);
  border: 1px solid var(--inactive-border);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--text-light);
  font-size: 12px;
  font-weight: 600;
}

.card-list {
  display: grid;
  gap: 9px;
}

.report-card,
.expense-entry,
.info-card {
  display: grid;
  gap: 6px;
  padding: 11px;
}

.report-card-meta,
.expense-entry-meta {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-card-meta span,
.expense-entry-meta span,
.disbursement-card-meta span {
  display: grid;
  gap: 2px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-light);
  font-size: 12px;
}

.report-card-meta strong,
.expense-entry-meta strong,
.disbursement-card-meta strong {
  color: var(--text);
  font-size: 14px;
}

.disbursement-card {
  padding: 11px;
  display: grid;
  gap: 9px;
}

.disbursement-card-head {
  display: grid;
  gap: 7px;
}

.disbursement-card-head strong {
  font-size: 15px;
}

.disbursement-card-date {
  font-size: 12px;
}

.disbursement-card-description {
  margin: 0;
  font-size: 13px;
}

.disbursement-card-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-icon {
  min-width: 36px;
  width: 36px;
  padding: 0;
}

.disbursement-card-meta {
  display: grid;
  gap: 6px;
}

.preview-list {
  display: grid;
  gap: 8px;
}

.preview-list > div {
  padding: 10px;
}

.attachment-viewer-frame-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.attachment-viewer-frame {
  display: block;
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: var(--white);
}

.viewer-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

.viewer-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.viewer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--nav-bg) 96%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--white) 8%, transparent);
}

.viewer-topbar .row-actions {
  gap: 8px;
}

.viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--white);
}

.viewer-stage {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--white);
}

.viewer-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--white);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.form-panel {
  max-width: 760px;
}

.span-3 {
  grid-column: 1 / -1;
}

.empty-state {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--empty-border);
  background: var(--empty-bg);
  color: var(--text-light);
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
  background: #050505;
}

.auth-shell {
  width: min(400px, 100%);
}

.auth-card {
  padding: 22px;
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-strong);
}

.auth-brand {
  display: grid;
  gap: 3px;
  margin-bottom: 16px;
  justify-items: center;
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  max-width: 64px;
  max-height: 64px;
  object-fit: contain;
  display: block;
  margin-inline: auto;
}

.auth-brand img.auth-logo {
  width: 64px !important;
  height: 64px !important;
  max-width: 64px !important;
  max-height: 64px !important;
}

.auth-brand strong {
  font-size: 18px;
}

.auth-card h1 {
  font-size: 26px;
  margin-bottom: 6px;
}

.footer {
  position: fixed !important;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--nav-bg) 98%, transparent);
  border-top: 1px solid #1E1E1E;
  backdrop-filter: blur(10px);
}

.footer-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 10px 5px;
  grid-template-columns: none;
}

.footer-nav::-webkit-scrollbar {
  display: none;
}

.footer-nav .app-nav-link {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
}

.footer-meta {
  text-align: center;
  font-size: 10px;
  color: var(--nav-text-muted);
}

@media (min-width: 720px) {
  .topbar-main {
    padding: 10px 18px;
  }

  .app-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding: 0 18px 8px;
  }

  .content {
    padding: 16px 18px;
    padding-bottom: 16px;
  }

  .footer-nav {
    justify-content: center;
    overflow-x: visible;
    padding: 0 14px 5px;
  }

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

  .report-card-grid,
  .expense-list,
  .disbursement-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

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

@media (min-width: 1024px) {
  .dashboard-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .report-card-grid,
  .expense-list,
  .disbursement-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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