/* ─── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #4F6AF0;
  --primary-light: #EEF1FD;
  --success:    #34C759;
  --success-bg: #F0FBF3;
  --warning:    #FF9500;
  --warning-bg: #FFF8EC;
  --error:      #FF3B30;
  --error-bg:   #FFF1F0;
  --text-1:     #1A1A2E;
  --text-2:     #555770;
  --text-3:     #9B9DB5;
  --bg:         #F4F5FA;
  --card:       #FFFFFF;
  --border:     #E8E9F2;
  --radius:     16px;
  --radius-sm:  10px;
  --shadow:     0 2px 16px rgba(79,106,240,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  padding-bottom: 48px;
}

/* ─── Layout ──────────────────────────────────────────────── */
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* ─── Header ──────────────────────────────────────────────── */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.header-title { font-size: 17px; font-weight: 700; color: var(--text-1); }
.header-sub   { font-size: 13px; color: var(--text-3); margin-top: 1px; }

/* ─── Card ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-top: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

/* ─── Status Badge ────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.status-badge.paid    { background: var(--success-bg); color: var(--success); }
.status-badge.warning { background: var(--warning-bg); color: var(--warning); }
.status-badge.error   { background: var(--error-bg);   color: var(--error);   }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ─── Payment Hero ────────────────────────────────────────── */
.payment-hero {
  text-align: center;
  padding: 8px 0 16px;
}
.payment-amount {
  font-size: 42px;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -1.5px;
  line-height: 1;
  margin: 12px 0 6px;
}
.payment-period {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 16px;
}

/* ─── Info Rows ───────────────────────────────────────────── */
.info-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-label { font-size: 14px; color: var(--text-2); flex-shrink: 0; }
.info-value { font-size: 14px; font-weight: 500; color: var(--text-1); text-align: right; word-break: break-word; }
.info-value.mono {
  font-family: 'SF Mono', 'Courier New', monospace;
  font-size: 13px;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: .8; transform: scale(.98); }

.btn-primary  { background: var(--primary); color: white; }
.btn-success  { background: var(--success); color: white; }
.btn-outline  {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-ghost {
  background: var(--bg);
  color: var(--text-2);
}
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ─── Form ────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-1);
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
}
.form-textarea { resize: vertical; min-height: 80px; }

.form-select-wrap { position: relative; }
.form-select-wrap::after {
  content: "▾";
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* ─── Meter Types ─────────────────────────────────────────── */
.meter-tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.meter-tab {
  flex: 1; min-width: 70px;
  padding: 9px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.meter-tab.active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.meter-tab-icon { font-size: 20px; display: block; margin-bottom: 3px; }
.meter-tab-label { font-size: 11px; color: var(--text-2); font-weight: 500; }
.meter-tab.active .meter-tab-label { color: var(--primary); }

/* ─── Payment History ─────────────────────────────────────── */
.payment-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.payment-item:last-child { border-bottom: none; padding-bottom: 0; }
.payment-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.payment-icon.confirmed { background: var(--success-bg); }
.payment-icon.manual    { background: var(--primary-light); }
.payment-info { flex: 1; min-width: 0; }
.payment-name {
  font-size: 14px; font-weight: 500; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.payment-date { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.payment-amount-small {
  font-size: 15px; font-weight: 700; color: var(--success);
  white-space: nowrap;
}

/* ─── Readings History ────────────────────────────────────── */
.reading-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.reading-item:last-child { border-bottom: none; }
.reading-type-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.reading-info { flex: 1; }
.reading-name  { font-size: 13px; color: var(--text-2); }
.reading-value { font-size: 15px; font-weight: 600; color: var(--text-1); }
.reading-date  { font-size: 12px; color: var(--text-3); }

/* ─── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-1);
  color: white;
  padding: 13px 22px;
  border-radius: 24px;
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  z-index: 9999;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }

/* ─── Loader ──────────────────────────────────────────────── */
.loader-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh;
  flex-direction: column; gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh;
  flex-direction: column; gap: 12px;
  text-align: center; padding: 32px;
}
.error-icon { font-size: 48px; }
.error-title { font-size: 20px; font-weight: 700; }
.error-sub   { font-size: 15px; color: var(--text-2); }

/* ─── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px; background: var(--border);
  margin: 16px 0;
}

/* ─── Chip ────────────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
}

/* ─── Empty state ─────────────────────────────────────────── */
.empty {
  text-align: center; padding: 24px 0;
  color: var(--text-3); font-size: 14px;
}

/* ─── Section toggle ──────────────────────────────────────── */
.section-toggle {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.section-toggle .arrow {
  color: var(--text-3);
  font-size: 12px;
  transition: transform .2s;
}
.section-toggle.open .arrow { transform: rotate(180deg); }
.collapsible { display: none; }
.collapsible.open { display: block; }
