:root {
  color-scheme: light;
  --ink: #18212b;
  --muted: #687386;
  --line: #dce3ea;
  --paper: #f5f7f9;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0f5f59;
  --accent-soft: #e4f4f1;
  --blue: #2563eb;
  --rose: #be123c;
  --shadow: 0 18px 44px rgba(24, 33, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.11), transparent 34%),
    linear-gradient(315deg, rgba(37, 99, 235, 0.08), transparent 42%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 750;
  padding: 0 18px;
}

button:hover {
  background: var(--accent-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lead {
  color: #4b5563;
  font-size: 1.08rem;
  line-height: 1.6;
  max-width: 560px;
}

.login-view {
  min-height: calc(100vh - 70px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 420px);
  gap: 28px;
  align-items: center;
}

.brand-panel h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(3rem, 8vw, 6.4rem);
  line-height: 0.94;
}

.auth-card,
.panel,
.payment-dialog {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(221, 227, 234, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 10px;
}

.entra-button {
  width: 100%;
  margin-bottom: 10px;
  background: #1f2937;
}

.entra-button:hover {
  background: #111827;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: #edf2f6;
}

.tab-button {
  background: transparent;
  color: var(--muted);
}

.tab-button.active,
.tab-button:hover {
  background: white;
  color: var(--ink);
}

.auth-form {
  display: grid;
  gap: 16px;
  padding: 22px 18px 14px;
}

label {
  display: grid;
  gap: 8px;
  color: #374151;
  font-size: 0.92rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--rose);
  font-weight: 700;
}

.app-view {
  display: grid;
  gap: 22px;
}

.topbar,
.panel-heading,
.month-toolbar,
.topbar-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar h1,
.panel-heading h2,
.month-toolbar h2 {
  margin: 0;
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.ghost-button {
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
}

.ghost-button:hover {
  background: #eef2f7;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.metric-card {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.metric-card.outstanding {
  background: #113f3c;
  color: white;
}

.metric-card span {
  color: inherit;
  opacity: 0.75;
  font-weight: 750;
}

.metric-card strong {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.types-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.types-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 340px);
  gap: 14px;
  align-items: end;
}

.types-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.type-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.type-add-form input {
  min-height: 36px;
  padding: 8px 10px;
}

.side-panel {
  min-height: 180px;
}

.upcoming-list,
.month-payments {
  display: grid;
  gap: 10px;
}

.payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.payment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.chip-icon-button {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}

.payment-row h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.payment-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.amount {
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 850;
  white-space: nowrap;
}

.status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.status-toggle input {
  width: 18px;
  min-height: 18px;
}

.type-list,
.type-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-list {
  display: grid;
}

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  max-width: 100%;
  padding: 4px 5px 4px 10px;
  border: 1px solid #c9d7e3;
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--ink);
}

.type-chip span {
  max-width: 220px;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-chip.inactive {
  border-style: dashed;
  background: #f1f5f9;
  color: var(--muted);
}

.type-chip.editing {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto 30px;
  flex: 1 1 520px;
  padding: 8px;
}

.type-chip.editing input[data-type-name] {
  min-height: 34px;
  padding: 7px 9px;
}

.type-active {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  font-size: 0.86rem;
  font-weight: 800;
}

.type-active input {
  width: 18px;
  min-height: 18px;
}

.archived-types {
  margin-top: 4px;
}

.archived-types summary {
  width: fit-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
}

.archived-types .type-chip-group {
  margin-top: 8px;
}

.compact-empty {
  padding: 12px;
}

.month-toolbar {
  margin-bottom: 16px;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
}

.empty-state {
  padding: 22px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.payment-dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: min(900px, calc(100vh - 28px));
  margin: auto;
  border: 0;
  padding: 0;
  overflow: hidden;
}

.payment-dialog::backdrop {
  background: rgba(12, 18, 26, 0.52);
}

.payment-form {
  display: grid;
  max-height: inherit;
  overflow: auto;
  padding: 20px;
}

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

.wide {
  grid-column: 1 / -1;
}

.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.schedule-header h3 {
  margin: 0;
}

#scheduleTotal {
  color: var(--accent-dark);
  font-size: 1.35rem;
  font-weight: 850;
}

.schedule-lines {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.schedule-line {
  display: grid;
  grid-template-columns: 42px minmax(130px, 1fr) minmax(120px, 0.75fr) minmax(160px, 1.1fr) 74px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.line-paid {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--muted);
}

.line-paid input {
  width: 18px;
  min-height: 18px;
}

.line-index {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 850;
}

.dialog-actions {
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .login-view,
  .metrics,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

  .topbar,
  .panel-heading,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .month-toolbar {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .types-header,
  .form-grid,
  .schedule-line,
  .payment-row,
  .type-add-form,
  .type-chip.editing {
    grid-template-columns: 1fr;
  }

  .payment-dialog {
    width: 100vw;
    max-width: none;
    max-height: 100vh;
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .payment-form {
    min-height: 100vh;
  }

  .line-index {
    border-radius: 8px;
  }
}
