/* Fidélio — démo IM Services */

:root {
  --navy-900: #12161c;
  --navy-800: #1c222b;
  --navy-700: #272f39;
  --blue-600: #2c7aa6;
  --blue-500: #3793c3;
  --cyan-400: #6cc0e6;
  --white: #ffffff;
  --gray-50: #f4f7fb;
  --gray-100: #e9eef5;
  --gray-300: #c4cfdc;
  --gray-600: #5b6b7c;
  --gray-900: #101823;
  --green: #1a9d63;
  --red: #d0433f;
  --amber: #c98a1c;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 10px rgba(7, 28, 51, 0.08);
  --shadow-md: 0 10px 30px rgba(7, 28, 51, 0.14);
  --shadow-lg: 0 20px 50px rgba(7, 28, 51, 0.22);

  --topbar-h: 60px;
  --bottomnav-h: 64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
ul { list-style: none; }

/* ===== App shell ===== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--navy-900);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; }
.topbar .brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-400));
  display: flex; align-items: center; justify-content: center;
}
.topbar .brand-mark svg { width: 17px; height: 17px; color: var(--white); }
.topbar .brand small { display: block; font-size: 0.62rem; font-weight: 500; color: var(--gray-300); }

.install-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-400));
  color: var(--white);
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}
.install-btn.visible { display: inline-flex; }
.install-btn svg { width: 15px; height: 15px; }

.demo-banner {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  background: #fff6e0;
  color: #7a5a12;
  font-size: 0.78rem;
  text-align: center;
  padding: 7px 14px;
  z-index: 99;
  border-bottom: 1px solid #f0dca3;
}
.demo-banner a { font-weight: 700; text-decoration: underline; }

main.view-container {
  flex: 1;
  padding: calc(var(--topbar-h) + 40px) 18px calc(var(--bottomnav-h) + 32px);
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-100);
  display: flex;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(7,28,51,0.06);
}
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--gray-600);
  font-size: 0.68rem;
  font-weight: 600;
}
.bottom-nav button svg { width: 21px; height: 21px; }
.bottom-nav button.active { color: var(--blue-500); }

/* ===== Section header ===== */
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
.view-header h1 { font-size: 1.4rem; font-weight: 800; color: var(--navy-900); }
.view-header p { color: var(--gray-600); font-size: 0.88rem; margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  border: 2px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--blue-500), var(--cyan-400)); color: var(--white); box-shadow: var(--shadow-sm); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: 0.45; pointer-events: none; }
.btn-ghost { background: var(--white); color: var(--navy-900); border-color: var(--gray-100); }
.btn-ghost:hover { border-color: var(--blue-500); color: var(--blue-500); }
.btn-danger { background: #fdecec; color: var(--red); }
.btn-gold { background: linear-gradient(135deg, #e0a72c, #f4cf6b); color: var(--navy-900); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; }

/* ===== Cards ===== */
.card { background: var(--white); border-radius: var(--radius-md); border: 1px solid var(--gray-100); box-shadow: var(--shadow-sm); padding: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 26px; }
.stat-card { background: var(--white); border-radius: var(--radius-md); border: 1px solid var(--gray-100); padding: 16px 14px; text-align: center; }
.stat-card strong { display: block; font-size: 1.5rem; font-weight: 800; color: var(--navy-900); }
.stat-card span { font-size: 0.72rem; color: var(--gray-600); font-weight: 600; }
.stat-card.accent { background: linear-gradient(160deg, var(--navy-900), var(--navy-700)); border: none; }
.stat-card.accent strong { color: var(--white); }
.stat-card.accent span { color: var(--gray-300); }

.section-title { font-size: 0.95rem; font-weight: 800; color: var(--navy-900); margin: 26px 0 12px; }
.quick-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 8px; }

/* ===== List items ===== */
.item-list { display: flex; flex-direction: column; gap: 10px; }

.client-item, .history-item {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.client-item:hover { border-color: var(--blue-500); transform: translateX(2px); }
.history-item { cursor: default; }

.avatar {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-400));
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.client-body, .history-body { flex: 1; min-width: 0; }
.client-body h4, .history-body h4 { font-size: 0.95rem; font-weight: 700; color: var(--navy-900); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-body p, .history-body p { font-size: 0.8rem; color: var(--gray-600); }

.mini-progress { width: 60px; flex-shrink: 0; }
.mini-progress-bar { height: 6px; border-radius: 999px; background: var(--gray-100); overflow: hidden; margin-bottom: 4px; }
.mini-progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--cyan-400)); border-radius: 999px; }
.mini-progress span { font-size: 0.68rem; color: var(--gray-600); font-weight: 700; text-align: right; display: block; }

.chip { flex-shrink: 0; font-size: 0.68rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(55,147,195,0.1); color: var(--blue-500); }
.chip.ready { background: linear-gradient(135deg, #e0a72c, #f4cf6b); color: #5a3c05; }
.chip.today { background: rgba(26,157,99,0.12); color: var(--green); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-600); }
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 14px; color: var(--gray-300); }
.empty-state p { font-size: 0.9rem; margin-bottom: 16px; }

.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--white); border: 1px solid var(--gray-100); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 18px;
}
.search-bar svg { width: 17px; height: 17px; color: var(--gray-600); flex-shrink: 0; }
.search-bar input { border: none; outline: none; width: 100%; font-size: 0.9rem; background: transparent; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(7, 28, 51, 0.55);
  display: none; align-items: flex-end; justify-content: center; z-index: 200;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease;
}
@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius-lg); }
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-size: 1.15rem; font-weight: 800; color: var(--navy-900); }
.modal-close { background: var(--gray-50); border: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--gray-600); }
.modal-close svg { width: 16px; height: 16px; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--navy-900); margin-bottom: 5px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.92rem; background: var(--gray-50); resize: vertical;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(55,147,195,0.15); background: var(--white);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ===== Loyalty stamp card ===== */
.stamp-card {
  background: linear-gradient(155deg, var(--navy-900), var(--navy-700));
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  color: var(--white);
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}
.stamp-card::after {
  content: "";
  position: absolute;
  top: -40%; right: -20%;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,192,230,0.25), transparent 70%);
}
.stamp-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; position: relative; }
.stamp-card-head h4 { font-size: 1.05rem; font-weight: 800; }
.stamp-card-head span { font-size: 0.78rem; color: var(--gray-300); }
.stamp-card-shop { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cyan-400); }

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  position: relative;
  margin-bottom: 18px;
}
.stamp-dot {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stamp-dot.filled {
  border-style: solid;
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-400));
}
.stamp-dot svg { width: 55%; height: 55%; color: var(--white); }

.stamp-card-progress { font-size: 0.85rem; color: var(--gray-300); font-weight: 600; position: relative; }
.stamp-card-progress strong { color: var(--white); }

.reward-banner {
  margin-top: 16px;
  background: linear-gradient(135deg, #e0a72c, #f4cf6b);
  color: #5a3c05;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.reward-banner svg { width: 20px; height: 20px; flex-shrink: 0; }

.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.card-actions.single { grid-template-columns: 1fr; }

.history-list-title { font-size: 0.85rem; font-weight: 800; color: var(--navy-900); margin: 18px 0 10px; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 300;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.view[data-view] { display: none; }
.view[data-view].active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 720px) {
  main.view-container { max-width: 900px; padding-left: 32px; padding-right: 32px; }
  .quick-actions { grid-template-columns: max-content; }
}
