:root {
  --bg: #f7f7f5; --surface: #fff; --border: #e8e8e4; --border-strong: #d0d0ca;
  --text: #1a1a18; --text-muted: #7a7a74; --text-faint: #b0b0aa;
  --accent: #1a6b4a; --accent-bg: #edf7f2; --accent-light: #d0eddf;
  --danger: #c0392b; --danger-bg: #fdf0ef;
  --success: #0f6e3a; --success-bg: #edf7f2; --success-border: #d0eddf;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ── Reset cross-browser ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { text-decoration: none; color: inherit; -webkit-tap-highlight-color: transparent; }
button { -webkit-tap-highlight-color: transparent; -webkit-appearance: none; appearance: none; }
input { -webkit-appearance: none; appearance: none; border-radius: 0; }

/* ── Auth ── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; min-height: 100vh;
  background: #0d1f18;
}

.auth-card {
  position: relative; z-index: 1;
  transform: scale(1.5); transform-origin: center;
  -webkit-transform: scale(1.5); -webkit-transform-origin: center;
  background: rgba(10, 20, 16, 0.75);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid rgba(212, 175, 120, 0.3);
  border-radius: 20px; padding: 48px 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.auth-welcome { text-align: center; margin-bottom: 36px; }
.auth-welcome h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 6px; color: #e8d5b0; }
.auth-welcome p { font-size: 14px; color: rgba(212,175,120,0.7); }
.auth-footer { text-align: center; font-size: 12px; color: rgba(212,175,120,0.4); margin-top: 28px; }
.auth-back { display: block; text-align: center; margin-top: 20px; font-size: 13px; color: rgba(212,175,120,0.6); }
.auth-back:hover { color: #e8d5b0; }
.auth-logo { margin: 0 auto 24px; width: 180px; }
.auth-logo img { width: 100%; height: auto; border-radius: 12px; }

/* ── Forms (auth) ── */
.auth-card .form-group { margin-bottom: 16px; }
.auth-card .form-group label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(212,175,120,0.6); margin-bottom: 7px;
}
.auth-card .form-group input {
  width: 100%; padding: 12px 14px;
  border: 1px solid rgba(212,175,120,0.25);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px; color: #fff;
  background: rgba(255,255,255,0.08);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none; appearance: none;
}
.auth-card .form-group input:focus {
  border-color: rgba(212,175,120,0.6);
  background: rgba(255,255,255,0.12);
}
.auth-card .form-group input::placeholder { color: rgba(255,255,255,0.3); }
.auth-card .form-group input::-webkit-input-placeholder { color: rgba(255,255,255,0.3); }

/* ── Forms (app) ── */
.app .form-group { margin-bottom: 16px; }
.app .form-group label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: 7px;
}
.app .form-group input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: 'DM Sans', sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg);
  outline: none; transition: border-color 0.15s;
}
.app .form-group input:focus { border-color: var(--accent); background: var(--surface); }

/* ── Buttons ── */
.btn-primary {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, #c9a96e, #e8d5a3, #b8964f);
  -webkit-background: -webkit-linear-gradient(315deg, #c9a96e, #e8d5a3, #b8964f);
  color: #1a1208; border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s; margin-top: 8px;
  -webkit-appearance: none; appearance: none;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { opacity: 0.8; transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: var(--danger-bg);  border: 1px solid #f5c6c3; color: var(--danger); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }

/* ── OTP ── */
.otp-row { display: flex; gap: 10px; justify-content: center; margin: 28px 0; }
.otp-input {
  width: 48px; height: 56px; text-align: center; font-size: 22px; font-weight: 600;
  font-family: 'DM Mono', 'Courier New', monospace;
  border: 1.5px solid rgba(212,175,120,0.25); border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08); color: #fff;
  outline: none; transition: border-color 0.15s; padding: 0;
  -webkit-appearance: none; appearance: none;
}
.otp-input:focus, .otp-input.filled {
  border-color: rgba(212,175,120,0.6);
  background: rgba(255,255,255,0.12);
}

/* ── App layout ── */
.app { max-width: 560px; margin: 0 auto; padding-bottom: 80px; }
.header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 20px 24px 16px;
  position: sticky; position: -webkit-sticky;
  top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
}
.header-left h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.header-date { font-size: 12px; color: var(--text-muted); font-family: 'DM Mono', monospace; margin-top: 2px; text-transform: capitalize; }
.header-right { display: flex; align-items: center; gap: 10px; }
.back-btn { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 14px; font-weight: 500; }
.back-btn:hover { opacity: 0.8; }
.logout-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 12px; font-size: 12px; color: var(--text-muted); cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: color 0.15s;
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }
.content { padding: 24px; }
.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 12px;
}

/* ── Clinic cards ── */
.clinic-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.clinic-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow); transition: border-color 0.15s, box-shadow 0.15s; cursor: pointer;
}
.clinic-card:hover { border-color: var(--border-strong); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.clinic-card-left { display: flex; align-items: center; gap: 14px; }
.clinic-icon {
  width: 40px; height: 40px; background: var(--accent-bg); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0;
}
.clinic-icon svg { width: 20px; height: 20px; }
.clinic-name { font-size: 15px; font-weight: 500; }
.clinic-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.text-faint { color: var(--text-faint); }
.hist-btn {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 20px; display: flex; align-items: center; gap: 12px;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  box-shadow: var(--shadow); transition: color 0.15s, border-color 0.15s;
  font-family: 'DM Sans', sans-serif; cursor: pointer;
}
.hist-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ── Date field ── */
.date-field {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; display: flex; align-items: center;
  gap: 10px; margin-bottom: 24px; box-shadow: var(--shadow);
}
.date-field svg { color: var(--text-muted); flex-shrink: 0; }
.date-field input[type=date] {
  border: none; background: none;
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 13px; padding: 0; flex: 1; color: var(--text); outline: none;
  -webkit-appearance: none; appearance: none; min-height: 20px;
}
.date-field input[type=date]::-webkit-datetime-edit { color: var(--text); }
.date-field input[type=date]::-webkit-calendar-picker-indicator { opacity: 0.5; cursor: pointer; }

/* ── Services ── */
.services-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.service-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.service-name { font-size: 14px; font-weight: 500; }
.service-meta { font-size: 11px; color: var(--text-muted); font-family: 'DM Mono', monospace; margin-top: 2px; }
.qty-control { display: flex; align-items: center; gap: 12px; }
.qty-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s; -webkit-appearance: none; appearance: none; line-height: 1;
}
.qty-btn:hover { background: var(--border); }
.qty-num { font-size: 16px; font-weight: 600; min-width: 22px; text-align: center; font-family: 'DM Mono', monospace; }
.qty-num.active { color: var(--accent); }

/* ── Summary ── */
.summary-main {
  background: var(--accent-bg); border: 1px solid var(--accent-light); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 10px;
}
.summary-main-label { font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 6px; opacity: 0.8; }
.summary-main-value { font-size: 28px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--accent); letter-spacing: -0.5px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.summary-card-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.summary-card-value { font-size: 18px; font-weight: 600; font-family: 'DM Mono', monospace; }
.summary-card-pct { font-size: 11px; color: var(--text-faint); font-family: 'DM Mono', monospace; margin-top: 3px; }
.summary-card-liquid {
  background: #eef4fc; border: 1px solid #c8ddf5; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.summary-card-liquid .summary-card-label { color: #1a5fa8; }
.summary-card-liquid .summary-card-value { font-size: 22px; font-weight: 700; font-family: 'DM Mono', monospace; color: #1a5fa8; }
.summary-card-tag {
  font-size: 10px; font-weight: 500; background: #c8ddf5; color: #1a5fa8;
  padding: 2px 7px; border-radius: 99px; margin-left: 6px; letter-spacing: 0.02em; vertical-align: middle;
}

/* ── Actions ── */
.actions { display: flex; gap: 10px; }
.actions .btn-primary { margin-top: 0; }
.btn-secondary {
  padding: 14px 18px; background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  cursor: pointer; box-shadow: var(--shadow); white-space: nowrap;
  -webkit-appearance: none; appearance: none;
}
.btn-secondary:hover { color: var(--text); border-color: var(--border-strong); }

/* ── History total ── */
.hist-total {
  background: var(--accent-bg); border: 1px solid var(--accent-light); border-radius: var(--radius);
  padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.hist-total-label { font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.hist-total-sub { font-size: 12px; color: var(--accent); opacity: 0.7; }
.hist-total-value { font-size: 26px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--accent); letter-spacing: -0.5px; }
.hist-total-liquid { font-size: 13px; color: #1a5fa8; font-family: 'DM Mono', monospace; margin-top: 4px; font-weight: 500; }

/* ── History table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.hist-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 13px; }
.hist-table thead tr { background: var(--bg); border-bottom: 1px solid var(--border); }
.hist-table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-faint); white-space: nowrap; }
.hist-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.hist-table tbody tr:last-child td { border-bottom: none; }
.hist-table tbody tr:hover { background: var(--bg); }
.hist-table tfoot tr { background: var(--bg); border-top: 1.5px solid var(--border-strong); }
.hist-table tfoot td { padding: 12px 14px; font-size: 13px; }
.hist-table .num { text-align: right; }
.hist-table .mono { font-family: 'DM Mono', 'Courier New', monospace; }
.hist-table .accent { color: var(--accent); }
.hist-table .muted { color: var(--text-muted); }
.hist-table .bold { font-weight: 700; }
.hist-table .liquid { color: #1a5fa8; font-weight: 600; }
.hist-table .foot-label { font-weight: 600; color: var(--text-muted); }
.hist-table .detail { color: var(--text-muted); font-size: 12px; max-width: 180px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 0; color: var(--text-faint); font-size: 13px; }
.empty-state svg { margin: 0 auto 12px; display: block; opacity: 0.4; }

/* ── Animations ── */
@keyframes shake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)}
  40%{transform:translateX(8px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)}
}
.shake { animation: shake 0.4s ease; }

/* ── Mobile Safari ── */
@supports (-webkit-touch-callout: none) {
  .auth-body { min-height: -webkit-fill-available; }
  input, button { font-size: 16px; }
  .otp-input { font-size: 16px; }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .auth-card { transform: scale(1.1); -webkit-transform: scale(1.1); padding: 32px 24px; }
  .summary-grid { grid-template-columns: 1fr; }
  .hist-table { font-size: 12px; }
  .hist-table th, .hist-table td { padding: 8px 10px; }
}
@media (min-width: 600px) {
  .content { padding: 32px; }
  .header { padding: 24px 32px 18px; }
}
