:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --border: rgba(0,0,0,0.07);
  --text: #111111;
  --muted: #6e6e73;
  --accent: #007aff;
  --accent-soft: rgba(0,122,255,0.13);
  --danger: #ff3b30;
  --shadow: 0 18px 45px rgba(15,23,42,0.09);
  --r-lg: 20px;
  --r-md: 12px;
  --r-sm: 8px;
  --safe-bottom: env(safe-area-inset-bottom,0px);
  --safe-left: env(safe-area-inset-left,0px);
  --safe-right: env(safe-area-inset-right,0px);
  --tabbar: calc(49px + var(--safe-bottom));
  /* Compatibility alias used by insights.css */
  --primary: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card-bg: #1c1c1e;
    --border: rgba(255,255,255,0.08);
    --text: #f5f5f7;
    --muted: #a1a1aa;
    --accent: #0a84ff;
    --accent-soft: rgba(10,132,255,0.26);
    --shadow: 0 24px 60px rgba(0,0,0,0.85);
  }
}

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

body {
  margin: 0;
  font-family: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Auth ── */
.auth-wrap {
  min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%,rgba(0,122,255,0.06),var(--bg));
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.auth-logo {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg,#0a84ff,#64d2ff);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px;
  box-shadow: 0 12px 30px rgba(10,132,255,0.35);
  margin: 0 auto 20px;
}
.auth-title {
  text-align: center; font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em; margin: 0 0 24px;
}

/* ── Form primitives ── */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field-group { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 10px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-row > .field { min-width: 0; }
.field-row input[type="date"] { width: 100%; min-width: 0; max-width: 100%; }
@media (max-width: 520px) {
  #trip-form .field-row,
  #trip-edit-form .field-row {
    grid-template-columns: 1fr;
  }
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

input,select,textarea {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font: inherit; font-size: 16px;
  background: var(--card-bg); color: var(--text);
  min-height: 44px;
}
input:focus,select:focus,textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 44px; transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn:not(:disabled):active { opacity: 0.75; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost   { background: var(--accent-soft); color: var(--accent); border-color: var(--border); }
.btn-xs      { font-size: 13px; padding: 6px 12px; min-height: 32px; }
.btn-full    { width: 100%; display: flex; }
.upper       { text-transform: uppercase; }

/* ── Utilities ── */
.hidden { display: none !important; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.field-error { font-size: 12px; color: var(--danger); }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-title   { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 14px; }
.card-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 14px; margin-top: -10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head .card-title { margin-bottom: 0; }
.card-head-actions { display: flex; gap: 6px; }
@media (max-width: 899px) {
  .mobile-icon-btn { width: 34px; min-width: 34px; height: 30px; padding: 0; font-size: 0; line-height: 0; }
  .mobile-icon-text { display: none; }
  .mobile-icon-edit::before { content: "\270E"; font-size: 14px; line-height: 1; }
  .mobile-icon-save::before { content: "\2713"; font-size: 15px; line-height: 1; }
  .mobile-icon-delete {
    background: #ffaaa5;
    border-color: #ffc0bc;
  }
  .mobile-icon-delete::before {
    content: "\1F5D1";
    font-size: 14px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
  }
}
