/* AvtoTime — design tokens + shared UI shell */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;600&family=Manrope:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #12151c;
  --ink-soft: #1e2430;
  --ink-muted: #4b5568;
  --muted: #6b7280;
  --line: rgba(18, 21, 28, 0.08);
  --line-strong: rgba(18, 21, 28, 0.14);

  --steel-50: #f4f6f8;
  --steel-100: #e8ecef;
  --steel-200: #d5dce3;
  --steel-300: #b8c4cf;

  --teal: #0f766e;
  --teal-soft: rgba(15, 118, 110, 0.12);
  --teal-glow: rgba(15, 118, 110, 0.28);
  --mint: #99f6e4;
  --mint-soft: rgba(153, 246, 228, 0.35);

  --cta: #ea580c;
  --cta-hover: #c2410c;
  --cta-soft: rgba(234, 88, 12, 0.14);

  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.12);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.14);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.12);

  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.88);
  --surface-raised: #fafbfc;

  --accent: var(--teal);
  --accent-soft: var(--teal-soft);

  --shadow-sm: 0 2px 10px -2px rgba(18, 21, 28, 0.06);
  --shadow-md: 0 14px 32px -16px rgba(18, 21, 28, 0.14);
  --shadow-lg: 0 28px 56px -24px rgba(18, 21, 28, 0.2);
  --shadow-lift: 0 20px 40px -18px rgba(15, 118, 110, 0.22);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);

  --sidebar-w: 260px;
  --header-h: 64px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 480px at -5% -10%, rgba(15, 118, 110, 0.09), transparent 55%),
    radial-gradient(700px 400px at 105% 5%, rgba(234, 88, 12, 0.06), transparent 50%),
    radial-gradient(600px 360px at 50% 100%, rgba(153, 246, 228, 0.12), transparent 60%),
    linear-gradient(165deg, #f7f9fb 0%, var(--steel-50) 42%, #eef2f5 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
  letter-spacing: -0.012em;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

.handwritten {
  font-family: 'Caveat', cursive;
  font-size: clamp(28px, 4vw, 40px);
  color: var(--muted);
  transform: rotate(-2deg);
  display: inline-block;
}

/* Motion */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.anim-fade-up { animation: fade-up 0.55s var(--ease) both; }
.anim-fade-in { animation: fade-in 0.4s var(--ease) both; }
.anim-delay-1 { animation-delay: 0.08s; }
.anim-delay-2 { animation-delay: 0.16s; }
.anim-delay-3 { animation-delay: 0.24s; }

.hover-lift {
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* App grid */
.app {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 100vh;
}
.app-admin { max-width: 1680px; }

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 0 32px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.brand-name span { color: var(--teal); }
.brand-mark,
.header-mobile-brand .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--ink-soft), var(--ink));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px -4px rgba(18, 21, 28, 0.45);
}
.brand-logo {
  height: 38px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}
.brand.has-logo {
  gap: 0;
  padding-top: 2px;
}
.brand.has-logo .brand-mark,
.brand.has-logo .brand-name { display: none; }
.brand-city,
.brand-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  margin-left: auto;
}
.brand-tag {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: transparent;
}

/* Sidebar */
.sidebar {
  display: none;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 0;
  overflow: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 14px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--steel-100);
  box-shadow: var(--shadow-sm);
}
.side-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 22px 14px 8px;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
  position: relative;
  width: 100%;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.side-item svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
}
.side-item:hover {
  background: var(--steel-50);
  color: var(--ink);
}
.side-item.active {
  background: var(--teal-soft);
  color: var(--ink);
  font-weight: 600;
}
.side-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 3px;
  background: var(--teal);
}
.side-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.side-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 60;
  background: linear-gradient(180deg, rgba(247, 249, 251, 0.94), rgba(247, 249, 251, 0.5) 85%, transparent);
  backdrop-filter: blur(14px);
  margin: 0 -16px 8px;
  padding: 8px 16px;
}
.header-mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}
.header-nav { display: none; align-items: center; gap: 2px; }
.header-nav a {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-muted);
  transition: background 0.2s, color 0.2s;
}
.header-nav a:hover,
.header-nav a.active {
  background: var(--surface);
  color: var(--ink);
}
.header-spacer { flex: 1; }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--steel-100);
  position: relative;
  flex: 0 0 auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.icon-btn:hover {
  border-color: var(--steel-200);
  box-shadow: var(--shadow-sm);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

/* Forms */
input:not([type='checkbox']):not([type='radio']):not([type='file']):not([type='hidden']):not([type='submit']):not([type='button']),
select,
textarea {
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-glass);
  padding: 0 14px;
  outline: none;
  min-width: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
  width: 100%;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal-glow);
  box-shadow: 0 0 0 4px var(--teal-soft);
}
input[type='checkbox'],
input[type='radio'] {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.form-grid > label,
.field,
form.panel > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}
.wide { grid-column: 1 / -1; }
.check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}
.hint {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

/* Buttons */
.btn,
.card-cta,
.btn-book,
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.2s var(--ease), background 0.2s, box-shadow 0.2s, color 0.2s;
}
.btn svg,
.card-cta svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
}

.btn-primary,
.btn-book,
.card-cta {
  background: linear-gradient(165deg, #f97316, var(--cta));
  color: #fff;
  border: none;
  box-shadow: 0 8px 20px -8px rgba(234, 88, 12, 0.55);
}
.btn-primary:hover,
.btn-book:hover,
.card-cta:hover {
  background: linear-gradient(165deg, var(--cta), var(--cta-hover));
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -10px rgba(234, 88, 12, 0.5);
}
.btn-primary { display: none; }
.btn-primary.show,
.is-admin .btn-primary { display: inline-flex; }

.btn-ghost,
.tool-btn {
  background: var(--surface);
  color: var(--teal);
  border: 1px solid var(--steel-200);
  box-shadow: none;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
}
.btn-ghost:hover,
.tool-btn:hover {
  background: var(--teal-soft);
  border-color: rgba(15, 118, 110, 0.25);
}
.tool-btn.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* Cards & panels */
.card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--steel-100);
  position: relative;
  transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--steel-100);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.content > .panel,
.content > form.panel { margin-top: 16px; }
.panel-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}
.panel-title svg {
  width: 18px;
  height: 18px;
  stroke: var(--teal);
  fill: none;
}

/* Tables */
.table-wrap {
  overflow: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--steel-100);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 640px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--steel-50);
}
table.data tr:hover td { background: rgba(15, 118, 110, 0.03); }

/* Badges & status */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: var(--teal-soft);
  color: var(--teal);
}
.st-active,
.st-confirmed,
.st-paid,
.st-succeeded,
.st-published,
.st-done { background: var(--green-soft); color: var(--green); }
.st-pending,
.st-waiting { background: var(--amber-soft); color: var(--amber); }
.st-in_progress { background: var(--teal-soft); color: var(--teal); }
.st-rejected,
.st-cancelled,
.st-canceled,
.st-blocked,
.st-no_show { background: var(--red-soft); color: var(--red); }
.st-expired,
.st-archived,
.st-draft { background: rgba(18, 21, 28, 0.06); color: var(--muted); }

/* Flashes */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.flash {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
}
.flash-error,
.flash-danger { background: var(--red-soft); color: #991b1b; border-color: transparent; }
.flash-ok,
.flash-success { background: var(--green-soft); color: #065f46; border-color: transparent; }
.flash-warn { background: var(--amber-soft); color: #92400e; border-color: transparent; }

/* Typography helpers */
.accent { color: var(--teal); }
.muted { color: var(--muted); font-size: 13px; }
.page-head h1,
.article h1 {
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.page-sub { margin-top: 8px; color: var(--ink-muted); font-size: 14px; }
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.breadcrumbs .current { color: var(--ink); font-weight: 600; }
.section { margin-top: 28px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.empty {
  padding: 32px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px dashed var(--steel-200);
  text-align: center;
  color: var(--muted);
}

/* Avatars */
.avatar img,
.chat-ava img,
.host-ava img,
.side-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px;
  border-radius: 22px;
  background: var(--surface-glass);
  border: 1px solid var(--steel-100);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
}
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px;
  border-radius: 14px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}
.bn-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}
.bn-item.active { color: var(--teal); }
.bn-fab {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--teal), #0d5c56);
  color: #fff;
  flex: 0 0 auto;
  box-shadow: var(--shadow-lift);
}

/* Footer */
.site-foot {
  margin-top: 24px;
  padding: 20px 0 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 13px;
  display: grid;
  gap: 14px;
}
.site-foot a:hover { color: var(--teal); }

/* PWA bar */
.pwa-bar {
  position: fixed;
  z-index: 130;
  left: 10px;
  right: 10px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.pwa-bar[hidden] { display: none; }
#pwaInstall {
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: var(--cta);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

/* City modal */
.city-modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px;
  background: rgba(18, 21, 28, 0.5);
  backdrop-filter: blur(4px);
}
.city-sheet {
  width: min(560px, 100%);
  max-height: min(82vh, 640px);
  overflow: auto;
  padding: 16px;
  border-radius: 22px 22px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--steel-100);
  box-shadow: var(--shadow-lg);
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  max-height: 70vh;
  overflow: auto;
  padding: 8px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--steel-100);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  z-index: 80;
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
}
.dropdown-menu a:hover { background: var(--steel-50); }

/* Responsive */
@media (min-width: 768px) {
  body { padding-bottom: 32px; }
  .bottom-nav { display: none; }
  .header {
    position: relative;
    background: none;
    backdrop-filter: none;
    margin: 0 0 8px;
    padding: 0;
  }
  .header-mobile-brand { display: none; }
  .header-nav,
  .btn-primary { display: flex; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr;
    padding: 0 24px;
  }
  .sidebar { display: block; }
  .content { padding-left: 28px; }
}

@media (max-width: 767px) {
  .panel { padding: 14px; }
  .card:hover { transform: none; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, .hover-lift:hover { animation: none !important; transition: none !important; transform: none !important; }
}
