/* ============================================================
   Kanata Winter Tire — UI theme (winter night blue + ice)
   ============================================================ */
:root {
  --navy-900: #0b1f4b;
  --navy-800: #0f2a63;
  --brand-700: #123d8f;
  --brand-600: #1a56db;
  --brand-500: #3b82f6;
  --brand-100: #e3edff;
  --brand-50: #f1f6ff;
  --ice-300: #7dd3fc;
  --ice-100: #e0f2fe;
  --danger: #d92d3e;
  --danger-bg: #fff1f2;
  --success: #16a34a;
  --bg: #edf2fa;
  --card: #ffffff;
  --text: #14213d;
  --text-muted: #61708f;
  --border: #dee7f5;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(20, 33, 61, .05), 0 2px 10px rgba(20, 33, 61, .06);
  --shadow-md: 0 6px 24px rgba(11, 31, 75, .10);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* aliases kept for qrcode.html */
  --primary: var(--brand-600);
  --primary-dark: var(--brand-700);
  --primary-light: var(--brand-100);
  --shadow: var(--shadow-md);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 24px);
}

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; font-size: 16px; font-weight: 700;
  padding: 14px 20px; cursor: pointer;
  transition: transform .08s ease, opacity .2s, box-shadow .2s, background .2s;
  touch-action: manipulation; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff; box-shadow: 0 8px 20px rgba(26, 86, 219, .30);
}
.btn-ghost {
  background: #fff; color: var(--text-muted); border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }
.btn-danger {
  background: #fff; color: var(--danger); border: 1.5px solid #f5c8cd;
}
.btn-danger:hover { background: var(--danger-bg); }
.btn-lg { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 10px; }

.input {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: #f8fafd;
  font-size: 16px; color: var(--text); outline: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.input:focus { border-color: var(--brand-500); background: #fff; box-shadow: 0 0 0 3px rgba(59, 130, 246, .14); }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg); padding: 18px 18px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-900), var(--brand-700) 58%, var(--brand-600));
  box-shadow: 0 14px 34px rgba(11, 31, 75, .30);
  margin-bottom: 16px;
}
.hero::before {
  content: ""; position: absolute; top: -70px; right: -50px;
  width: 210px; height: 210px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(125, 211, 252, .38), rgba(125, 211, 252, 0));
}
.hero::after {
  content: ""; position: absolute; bottom: -90px; left: -50px;
  width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0));
}
.hero-row { position: relative; display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .28);
  display: flex; align-items: center; justify-content: center;
}
.brand-text { min-width: 0; flex: 1; }
.brand-text h1 {
  margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text p {
  margin: 3px 0 0; font-size: 12.5px; color: rgba(255, 255, 255, .78);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.chip-btn {
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .32);
  color: #fff; border-radius: 999px; padding: 5px 13px;
  font-size: 12.5px; font-weight: 700; cursor: pointer;
  transition: background .2s;
}
.chip-btn:hover { background: rgba(255, 255, 255, .26); }
.autobadge {
  background: var(--ice-300); color: var(--navy-900);
  border-radius: 999px; padding: 4px 10px;
  font-size: 12px; font-weight: 800; letter-spacing: .5px;
}
.hero-call {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; padding: 13px 16px;
  background: #fff; color: var(--brand-700);
  border-radius: 14px; font-size: 16px; font-weight: 800; text-decoration: none;
  box-shadow: 0 10px 22px rgba(4, 14, 40, .28);
}
.hero-call:active { transform: scale(.98); }
.hero-call svg { flex-shrink: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 16px;
}
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px; font-size: 14.5px; font-weight: 800;
}
.section-title::before {
  content: ""; width: 4px; height: 14px; border-radius: 2px;
  background: linear-gradient(var(--brand-500), var(--brand-700));
}

/* ---------- calendar ---------- */
.cal-card { padding: 14px 12px 12px; }
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; padding: 0 4px;
}
.month-nav h3 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: .2px; }
.nav-btn {
  width: 36px; height: 36px; border-radius: 11px;
  border: 1.5px solid var(--border); background: #fff;
  font-size: 20px; line-height: 1; color: var(--brand-600);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .08s;
}
.nav-btn:hover { background: var(--brand-50); }
.nav-btn:active { transform: scale(.94); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar .dow {
  text-align: center; font-size: 11px; color: var(--text-muted);
  font-weight: 700; padding: 4px 0 8px; letter-spacing: .5px;
}
.calendar .dow.sat, .calendar .dow.sun { color: var(--brand-500); }

.day {
  position: relative; aspect-ratio: 1; border: none; border-radius: 13px;
  background: transparent; color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; padding: 0;
  transition: background .15s, transform .08s;
}
.day:hover { background: var(--brand-50); }
.day:active { transform: scale(.93); }
.day.empty { visibility: hidden; }
.day > span:first-child {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14.5px; font-weight: 600; line-height: 1;
  transition: background .15s, color .15s;
}
.day.today > span:first-child { background: var(--brand-100); color: var(--brand-700); font-weight: 800; }
.day.selected {
  background: linear-gradient(150deg, var(--brand-600), var(--brand-700));
  box-shadow: 0 6px 16px rgba(26, 86, 219, .35);
}
.day.selected > span:first-child { background: rgba(255, 255, 255, .18); color: #fff; }
.day.selected .dot-booked { background: #fff; }
.day.selected .dot-free { background: rgba(255, 255, 255, .45); }
.day.selected .count { color: rgba(255, 255, 255, .9); }
.day.past { cursor: default; }
.day.past > span:first-child { color: #b6c2d9; }
.day.past:hover { background: transparent; }
.day.full { background: var(--danger-bg); }
.day.full:hover { background: var(--danger-bg); }
.day.full > span:first-child { color: #bb2d3b; font-weight: 700; }
.day .count { font-size: 10px; font-weight: 700; color: var(--text-muted); }

.dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 5px; height: 5px; border-radius: 50%; }
.dot-free { background: #d9e2f1; }
.dot-booked { background: var(--brand-600); }

.legend {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin: 12px 2px 0;
}
.legend span {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  background: #f6f9fe; border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 11px; white-space: nowrap;
}
.legend .dot { width: 8px; height: 8px; flex: 0 0 auto; }
.legend .dot-full { background: var(--danger-bg); border: 1.5px solid #f0b9be; border-radius: 3px; width: 8px; height: 8px; }
.legend .dot-past { background: #c9d4e7; }

/* ---------- service info ---------- */
.info-card { margin-top: 16px; }
.info-list { display: flex; flex-direction: column; }
.info-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid #eef3fa;
}
.info-row:last-child { border-bottom: none; padding-bottom: 2px; }
.info-ico {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  background: var(--brand-50); color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
}
.info-body { min-width: 0; }
.info-label { font-size: 12px; color: var(--text-muted); }
.info-value {
  font-size: 14.5px; font-weight: 600; margin-top: 1px;
  overflow-wrap: anywhere; color: var(--text); text-decoration: none;
}
a.info-value { color: var(--brand-600); }
.call-hint { font-size: 12px; color: var(--text-muted); text-align: center; margin: 12px 0 0; }

/* ---------- admin panel ---------- */
.admin-panel { margin-top: 16px; }
.mgmt-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.mgmt-head .section-title { margin: 0; }
.mgmt-actions { display: flex; gap: 6px; }
.booking-list { display: flex; flex-direction: column; gap: 10px; }
.booking-card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); padding: 12px 12px 12px 14px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.booking-card .b-main { min-width: 0; }
.booking-card .b-date { font-weight: 800; font-size: 14.5px; color: var(--brand-700); }
.booking-card .b-name { font-weight: 700; font-size: 14px; margin-top: 3px; }
.booking-card .b-line { font-size: 13px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.booking-card .b-line a { color: var(--brand-600); font-weight: 600; text-decoration: none; }
.slot-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.slot-actions .btn { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.empty-state {
  color: var(--text-muted); font-size: 13px; text-align: center;
  padding: 20px 0; background: #fff; border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ---------- footer ---------- */
.foot { text-align: center; color: #9fb0cc; font-size: 12px; margin-top: 24px; padding: 10px 0 4px; }
.foot a { color: var(--text-muted); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* ---------- privacy page ---------- */
.privacy { max-width: 640px; margin: 0 auto; padding: 28px 20px 60px; }
.privacy .back { color: var(--brand-600); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 14px; }
.privacy h1 { font-size: 26px; margin: 0 0 6px; }
.privacy .updated { color: var(--text-muted); font-size: 13px; margin: 0 0 26px; }
.privacy h2 { font-size: 18px; margin: 28px 0 8px; color: var(--text); }
.privacy p, .privacy li { font-size: 15px; line-height: 1.7; color: var(--text-muted); }
.privacy ul { padding-left: 20px; margin: 8px 0; }
.privacy strong { color: var(--text); }

/* ---------- sheets ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(8, 20, 45, .5);
  z-index: 40; animation: fadeIn .18s ease;
}
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 10px); z-index: 50;
  width: calc(100% - 20px); max-width: 500px;
  max-height: 86dvh; overflow-y: auto;
  background: var(--card); border-radius: 22px;
  padding: 8px 18px calc(var(--safe-bottom) + 16px);
  box-shadow: 0 -10px 44px rgba(8, 20, 45, .28);
  animation: slideUp .22s ease;
}
.sheet-handle { width: 42px; height: 4px; border-radius: 2px; background: #e2e8f4; margin: 8px auto 14px; }
.sheet h3 { margin: 0; font-size: 19px; font-weight: 800; }
.sheet-date { color: var(--text-muted); font-size: 13px; margin: 3px 0 12px; }
.sheet-avail {
  display: flex; align-items: center;
  font-size: 14px; font-weight: 700; color: var(--brand-700);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  border-radius: 12px; padding: 10px 14px; margin: 0 0 14px;
}
.sheet-avail.full { color: #b4232a; background: var(--danger-bg); border-color: #f6ccd0; }

.slot-list { display: flex; flex-direction: column; gap: 10px; }
.slot-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; background: #fbfcfe;
}
.slot-item .s-time { font-weight: 700; font-size: 14px; }
.slot-item .s-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.slot-item .s-owner { font-size: 12px; color: var(--brand-600); font-weight: 600; margin-top: 3px; }
.slot-item .s-owner a { color: inherit; text-decoration: none; }

.form { display: flex; flex-direction: column; }
.form .input { text-align: left; letter-spacing: normal; margin-bottom: 10px; }
.form .textarea { resize: vertical; min-height: 58px; font-family: inherit; }
.f-label { display: block; font-size: 13px; color: var(--text-muted); margin: 2px 0 6px; }
.form .btn { margin-top: 2px; }
.edit-hint {
  font-size: 13px; font-weight: 700; color: var(--brand-700);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  border-radius: 10px; padding: 9px 12px; margin: 0 0 12px;
}

.sheet .btn { width: 100%; margin-top: 12px; }
.sheet-hint { color: var(--text-muted); font-size: 13px; text-align: center; padding: 4px 0 0; }
#login-sheet .input { margin-top: 4px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 24px);
  background: rgba(11, 31, 75, .94); color: #fff;
  padding: 12px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 60;
  box-shadow: 0 8px 26px rgba(8, 20, 45, .35);
  animation: fadeIn .2s ease; max-width: 90%; text-align: center;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

@media (display-mode: standalone) {
  #app { padding-top: calc(var(--safe-top) + 8px); }
}
