@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;600;700&family=Barlow:ital,wght@0,400;0,500;0,600;1,400&family=Barlow+Condensed:wght@400;500;600;700&family=Unbounded:wght@900&display=swap');

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

:root {
  --bg: #E5E3DE;
  --fg: #0A0A0A;
  --fg-muted: #4A4A44;
  --surface: #D9D7D2;
  --surface-hover: #CDCBC6;
  --rule: #0A0A0A;
  --rule-light: rgba(10,10,10,0.18);
  --green: #27ae60;
  --green-bg: rgba(39,174,96,0.12);
  --amber: #d68910;
  --amber-bg: rgba(214,137,16,0.12);
  --red: #c0392b;
  --red-bg: rgba(192,57,43,0.12);
  --blue: #2980b9;
  --blue-bg: rgba(41,128,185,0.12);
  --transition: 0.35s ease;
}

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 55% 45% at 8% 12%, rgba(255, 110, 50, 0.16) 0%, transparent 70%),
    radial-gradient(ellipse 50% 55% at 88% 8%, rgba(230, 185, 60, 0.14) 0%, transparent 70%),
    radial-gradient(ellipse 60% 45% at 70% 85%, rgba(70, 145, 210, 0.13) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 5% 88%, rgba(180, 150, 220, 0.10) 0%, transparent 70%);
  background-attachment: fixed;
  color: var(--fg);
  font-family: 'Barlow', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* NAV */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 2px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 32px;
  height: 56px;
}

.nav-brand {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--fg);
  margin-right: 40px;
  white-space: nowrap;
}

.nav-brand span { opacity: 0.35; }

.nav-links {
  display: flex;
  gap: 0;
  flex: 1;
}

.nav-links a {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fg-muted);
  padding: 0 18px;
  height: 56px;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--rule-light);
  transition: color 0.2s, background 0.2s;
}

.nav-links a:first-child { border-left: 1px solid var(--rule-light); }
.nav-links a:hover, .nav-links a.active { color: var(--fg); background: var(--surface); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* BUTTONS */
.btn {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1.5px solid var(--rule);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-hover); }

.btn-primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.btn-primary:hover { opacity: 0.85; background: var(--fg); }

.btn-sm {
  font-size: 11px;
  padding: 5px 11px;
}

.btn-lg {
  font-size: 14px;
  padding: 14px 32px;
}

.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }

.btn-success { border-color: var(--green); color: var(--green); }
.btn-success:hover { background: var(--green-bg); }

/* MAIN LAYOUT */
main { padding: 40px 32px; max-width: 1200px; margin: 0 auto; }

/* PAGE HEADER */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule-light);
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* PROGRESS COUNTER */
.progress-counter {
  padding: 0 0 40px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--rule-light);
}

/* DOT GRID */
.bill-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

@keyframes dotReveal {
  from { opacity: 0; transform: scale(0.3); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pillIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bill-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--rule-light);
  animation: dotReveal 0.3s ease both;
  flex-shrink: 0;
}

.bill-dot-paid {
  background: #00E87A;
  border-color: #00E87A;
  box-shadow: 0 0 6px rgba(0, 232, 122, 0.45);
}

/* PILL COUNTER */
.counter-pill {
  display: inline-flex;
  align-items: center;
  background: #3A5BFF;
  border-radius: 22px;
  padding: 18px 36px;
  animation: pillIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both;
  transition: background 0.4s ease;
  min-height: 80px;
}

.counter-complete .counter-pill {
  background: #00E87A;
}

.counter-pill-num {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(60px, 11vw, 92px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
  color: #0A0A0A;
}

.counter-pill-sep {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 900;
  color: rgba(10, 10, 10, 0.25);
  padding: 0 14px;
  line-height: 1;
}

.counter-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 14px;
}

/* X/Y COUNTER */
.counter-ratio {
  display: flex;
  align-items: center;
}

.counter-num {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 88px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -4px;
  color: var(--fg);
}

.counter-all-paid { color: var(--green) !important; }
.counter-has-unpaid { color: var(--red) !important; }

.counter-slash {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 44px;
  font-weight: 400;
  color: var(--fg-muted);
  line-height: 1;
  padding: 0 12px;
  letter-spacing: 0;
}

/* PAGE TITLE CAPS */
.page-title-caps { text-transform: uppercase; }

/* STATUS BADGES */
.badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 9px;
  display: inline-block;
  white-space: nowrap;
}

.badge-paid { background: var(--green-bg); color: var(--green); }
.badge-due_soon { background: var(--amber-bg); color: var(--amber); }
.badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-upcoming { background: var(--blue-bg); color: var(--blue); }
.badge-unknown { background: var(--surface); color: var(--fg-muted); }

/* TABLE (form page) */
.table-wrap { overflow-x: auto; }

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

thead th {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 2px solid var(--rule-light);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--rule-light); transition: background 0.15s; }
tbody tr:hover { background: var(--surface); }
tbody td { padding: 14px 16px; vertical-align: middle; }

.td-provider {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 600;
  font-size: 16px;
}

.td-type {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

/* UPCOMING TILES (Flat Bills page) */
.section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule-light);
}
.section-title-bold {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.12em;
}

.upcoming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 1px;
  background: var(--rule-light);
  border: 1px solid var(--rule-light);
  margin-bottom: 40px;
}

.upcoming-card {
  background: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upcoming-provider {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 700;
  font-size: 18px;
}

.upcoming-due {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* SPLIT TRACKER */
.split-tracker {
  background: var(--surface);
  border: 1px solid var(--rule-light);
  padding: 20px;
  margin-bottom: 40px;
}

.split-rows {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}

.split-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.split-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.split-amount {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.split-balance {
  font-family: 'Barlow', sans-serif;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 0;
  border-top: 1px solid var(--rule-light);
}

.split-owed { color: var(--green); }
.split-owes { color: var(--red); }
.split-even { color: var(--green); }

.split-settled-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  padding: 5px 11px;
  border: 1.5px solid var(--green);
}

/* PAY FORM */
.pay-amount-input {
  font-size: 15px !important;
  padding: 8px 10px !important;
  border-color: var(--rule) !important;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* INFO TILES (INFO page) */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 12px;
  margin-top: 8px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--rule-light);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.info-card:hover { background: var(--surface-hover); }

.info-login-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: var(--fg);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 14px;
  line-height: 1;
}

.info-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.info-provider {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  flex-wrap: wrap;
}

.info-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  min-width: 36px;
}

.info-login-link {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue);
  text-decoration: none;
}

.info-login-link:hover { text-decoration: underline; }

.info-notes {
  font-size: 13px;
  color: var(--fg-muted);
  font-style: italic;
}

.info-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--rule-light);
}

/* FORM */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
}

.form-input, .form-select, .form-textarea {
  font-family: 'Barlow', sans-serif;
  font-size: 15px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--fg);
  border: 1.5px solid var(--rule-light);
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--fg); }

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

.form-section {
  border: 1px solid var(--rule-light);
  padding: 20px;
  margin-bottom: 24px;
}

.form-section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-light);
}

/* FLOATING ADD BUTTON */
.fab-add {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 52px;
  height: 52px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 50;
  cursor: pointer;
}

/* EDIT ACTION ROW */
.edit-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-light);
}

/* URL VIEW LINK */
.url-view-link {
  display: none;
}
.form-locked .url-view-link {
  display: block;
  color: var(--blue);
  text-decoration: none;
  font-size: 14px;
  word-break: break-all;
  padding: 10px 12px;
  background: var(--surface);
}
.form-locked input[name="login_url"] {
  display: none;
}

/* FORM LOCKED (view mode) */
.form-locked input,
.form-locked select,
.form-locked textarea {
  pointer-events: none;
  border-color: transparent !important;
  cursor: default;
  resize: none;
  overflow: hidden;
}
.form-locked select { -webkit-appearance: none; appearance: none; }
.form-locked .form-section { border-color: var(--rule-light); }

/* DANGER ZONE */
.danger-zone {
  margin-top: 40px;
  padding: 20px;
  border: 1.5px solid var(--red);
}

.danger-zone-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 8px;
}

.danger-zone-sub {
  font-size: 14px;
  color: var(--fg-muted);
  margin-bottom: 16px;
}

/* FLASH */
.flash {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 20px;
  margin-bottom: 24px;
  background: var(--surface);
  border-left: 3px solid var(--fg);
}

/* LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 380px;
  border: 2px solid var(--rule);
  padding: 40px;
}

.login-title {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.login-sub {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.login-error {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  color: var(--red);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 12px;
  background: var(--red-bg);
  margin-bottom: 16px;
}

/* EMPTY STATE */
.empty-state {
  padding: 60px 0;
  text-align: center;
  color: var(--fg-muted);
}

.empty-state-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  nav { padding: 0 16px; }
  main { padding: 24px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
}

@media (max-width: 480px) {
  .upcoming-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .counter-ratio { font-size: 52px; }
  main { padding: 20px 14px; }
}
