@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,600&display=swap');

:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-2: #edf2ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --surface-soft: #f7f9fd;
  --text: #111827;
  --muted: #6b7280;
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(148, 163, 184, 0.35);
  --primary: #1f5eff;
  --primary-2: #4f46e5;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09111f;
  --bg-2: #0f172a;
  --surface: rgba(15, 23, 42, 0.86);
  --surface-strong: #0f172a;
  --surface-soft: #111c31;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.28);
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.4);
  --shadow-soft: 0 10px 30px rgba(2, 6, 23, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(31, 94, 255, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(79, 70, 229, 0.10), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
}

body {
  padding-bottom: 112px;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

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

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 18px 0;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(31, 94, 255, 0.16), rgba(79, 70, 229, 0.2));
  box-shadow: var(--shadow-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.screen-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 28px;
  line-height: 1.05;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.btn,
button.btn,
summary.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.icon-button:hover,
.btn:hover,
summary.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.12);
  text-decoration: none;
}

.btn.primary,
button.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
}

.btn.secondary {
  background: rgba(31, 94, 255, 0.08);
  border-color: rgba(31, 94, 255, 0.12);
  color: var(--primary);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.16);
  color: var(--red);
}

.btn.small,
summary.btn.small {
  padding: 9px 12px;
  font-size: 13px;
}

.user-pill {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.app-content {
  display: grid;
  gap: 18px;
}

.screen-block,
.card,
.stat-card,
.hero-card,
.panel-card,
.record-card,
.menu-card,
.detail-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card,
.stat-card,
.hero-card,
.panel-card,
.record-card,
.menu-card,
.detail-card {
  padding: 20px;
}

.hero-card {
  background: linear-gradient(135deg, #1f5eff 0%, #4f46e5 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -18% -40% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.hero-meta,
.summary-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-value {
  margin: 10px 0 4px;
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
}

.hero-subtitle,
.muted,
small,
.help-text {
  color: var(--muted);
}

.hero-card .hero-subtitle,
.hero-card .muted {
  color: rgba(255, 255, 255, 0.78);
}

.trend-chip,
.status-pill,
.badge,
.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.trend-chip {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.status-pill,
.badge,
.mini-pill {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line);
}

.is-paid {
  background: rgba(22, 163, 74, 0.12);
  color: var(--green);
  border-color: rgba(22, 163, 74, 0.18);
}

.is-partial {
  background: rgba(245, 158, 11, 0.12);
  color: #c67b00;
  border-color: rgba(245, 158, 11, 0.18);
}

.is-sent {
  background: rgba(31, 94, 255, 0.1);
  color: var(--primary);
  border-color: rgba(31, 94, 255, 0.18);
}

.is-overdue {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.18);
}

.is-draft {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.2);
}

.grid,
.metric-grid,
.two-col,
.three-col,
.stats-grid,
.list-grid,
.form-grid,
.menu-grid {
  display: grid;
  gap: 16px;
}

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

.grid-3,
.three-col,
.metric-grid,
.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
}

.metric-label {
  font-size: 13px;
  color: var(--muted);
}

.metric-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
}

.metric-foot {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
}

.metric-foot.positive {
  color: var(--green);
}

.metric-foot.negative {
  color: var(--red);
}

.section-head,
.stack-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2,
.section-head h3,
.stack-head h3,
.stack-head h4,
.card h3,
.card h4 {
  margin: 0;
}

.section-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.record-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.record-avatar {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(31, 94, 255, 0.14), rgba(79, 70, 229, 0.14));
  color: var(--primary);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.record-title {
  font-weight: 800;
}

.record-subtitle,
.record-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.record-amount {
  text-align: right;
  font-weight: 800;
}

.record-amount .mini-meta {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-chip {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.detail-chip span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.detail-chip strong {
  display: block;
  font-size: 16px;
}

.field-group {
  display: grid;
  gap: 8px;
}

label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.input,
select,
textarea,
input[type="date"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="text"],
input[type="file"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.input:focus,
select:focus,
textarea:focus,
input:focus {
  border-color: rgba(31, 94, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.12);
}

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

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

.form-grid .span-2 {
  grid-column: span 2;
}

.form-note {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(31, 94, 255, 0.08);
  color: var(--primary);
  font-size: 13px;
}

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

.table th,
.table td,
table th,
table td {
  padding: 14px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th,
table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.right {
  text-align: right;
}

.flex {
  display: flex;
  gap: 10px;
  align-items: center;
}

.space {
  justify-content: space-between;
}

.wrap {
  flex-wrap: wrap;
}

.action-cluster {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-board {
  display: grid;
  gap: 12px;
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.summary-line:last-child {
  border-bottom: 0;
}

.summary-line.total strong {
  font-size: 20px;
}

.empty-state {
  padding: 18px;
  border-radius: 20px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
  text-align: center;
}

details {
  width: 100%;
}

details summary {
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

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

.menu-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.menu-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: rgba(31, 94, 255, 0.08);
  color: var(--primary);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-footer {
  padding: 18px 0 120px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 24px));
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 20;
}

:root[data-theme="dark"] .bottom-nav {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(148, 163, 184, 0.16);
}

.bottom-link,
.bottom-fab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  min-width: 58px;
}

.nav-glyph {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  font-weight: 800;
}

.bottom-link.active {
  color: var(--primary);
}

.bottom-link.active .nav-glyph {
  background: rgba(31, 94, 255, 0.1);
  border-color: rgba(31, 94, 255, 0.14);
}

.bottom-fab {
  margin-top: -30px;
  color: #fff;
}

.bottom-fab .nav-glyph {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 16px 28px rgba(31, 94, 255, 0.3);
}

.bottom-fab span:last-child {
  color: var(--muted);
}

.hidden-mobile {
  display: block;
}

code {
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 7px;
  border-radius: 8px;
}

@media (max-width: 900px) {
  .grid-3,
  .three-col,
  .metric-grid,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-grid,
  .form-grid,
  .grid-2,
  .two-col,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px 14px 0;
  }

  .screen-title {
    font-size: 24px;
  }

  .top-actions .icon-button {
    padding: 10px 12px;
  }

  .app-topbar {
    align-items: flex-start;
  }

  .grid-3,
  .three-col,
  .metric-grid,
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .record-row {
    align-items: flex-start;
  }

  .record-row,
  .summary-line,
  .section-head,
  .stack-head,
  .hero-meta,
  .summary-meta {
    gap: 10px;
  }

  .action-cluster,
  .top-actions,
  .section-head,
  .stack-head {
    flex-wrap: wrap;
  }

  .table th {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }

  .table td {
    padding: 6px 0;
    border-bottom: 0;
    text-align: left;
  }
}

@media (max-width: 560px) {
  body {
    padding-bottom: 126px;
  }

  .screen-title {
    font-size: 22px;
  }

  .grid-3,
  .three-col,
  .metric-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 24px;
  }

  .record-row {
    flex-direction: column;
  }

  .record-amount {
    width: 100%;
    text-align: left;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
    padding-bottom: 0;
  }

  .no-print,
  .bottom-nav,
  .app-footer,
  .app-topbar {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .card,
  .hero-card,
  .panel-card,
  .detail-card {
    box-shadow: none;
    border: 1px solid #ddd;
    background: #fff;
  }
}
