:root {
  --bg: #f5f6f1;
  --ink: #18201f;
  --muted: #68706c;
  --line: #dfe3dc;
  --panel: #ffffff;
  --accent: #0f6f63;
  --accent-strong: #0a544b;
  --warn: #b95f24;
  --danger: #b54040;
  --shadow: 0 18px 45px rgba(26, 37, 35, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.auth-screen {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 86px 22px 42px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.96), rgba(9, 5, 18, 0.82), rgba(0, 0, 0, 0.94)),
    url("assets/detailing-hero.png") center / cover no-repeat;
}

.client-hero {
  display: grid;
  justify-items: center;
  gap: 20px;
  width: min(920px, 100%);
  color: #fff;
  text-align: center;
}

.auth-logo {
  width: min(760px, 96vw);
  height: 310px;
  object-fit: contain;
  justify-self: center;
  filter: drop-shadow(0 16px 36px rgba(107, 41, 214, 0.42));
  opacity: 0.98;
}

.service-view h1 {
  font-size: clamp(42px, 6vw, 82px);
  font-weight: 400;
  line-height: 1.05;
}

.service-view > p {
  max-width: 850px;
  color: #f0edf8;
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1.45;
}

.auth-error {
  min-height: 20px;
  color: #ffb7b7;
  font-weight: 700;
}

.client-hero .stack,
.service-view,
.portal-view {
  width: min(620px, 100%);
}

.service-view {
  display: grid;
  justify-items: center;
  gap: 24px;
}

.hero-input {
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 0;
  background: transparent;
  color: #fff;
  padding: 18px 10px;
  text-align: center;
  font-size: 21px;
}

.hero-input::placeholder {
  color: rgba(255, 255, 255, 0.56);
}

.hero-input:focus {
  border-color: #8c43ff;
  box-shadow: 0 8px 0 -5px rgba(140, 67, 255, 0.62);
}

.hero-button {
  justify-self: center;
  min-height: 58px;
  margin-top: 16px;
  border: 0;
  border-radius: 2px;
  background: linear-gradient(135deg, #6e22d7, #8b42ff);
  color: #fff;
  padding: 0 42px;
  cursor: pointer;
  font-weight: 850;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.portal-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 72px;
  padding: 0 clamp(24px, 7vw, 140px);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.88), rgba(23, 12, 38, 0.78), rgba(0, 0, 0, 0.88));
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.portal-nav::after {
  content: "";
  position: absolute;
  left: clamp(24px, 7vw, 140px);
  right: clamp(24px, 7vw, 140px);
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(140, 67, 255, 0.85), transparent);
}

.portal-nav-button {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 72px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  color: #fff;
  font-size: clamp(18px, 1.8vw, 30px);
  font-weight: 850;
}

.portal-nav-button + .portal-nav-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22px;
  bottom: 22px;
  width: 1px;
  background: rgba(255, 255, 255, 0.13);
}

.portal-nav-button.active,
.portal-nav-button:hover {
  border-bottom-color: #8c43ff;
  color: #f2eaff;
  text-shadow: 0 0 22px rgba(140, 67, 255, 0.42);
}

.ghost-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
}

.ghost-button:hover {
  background: rgba(140, 67, 255, 0.4);
}

.portal-panel,
.client-result {
  width: min(760px, 100%);
}

.portal-panel {
  width: min(760px, 100%);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(rgba(9, 8, 14, 0.88), rgba(9, 8, 14, 0.9)),
    url("assets/detailing-hero.png") center / cover no-repeat;
  box-shadow: var(--shadow);
  text-align: left;
}

.admin-login {
  background: rgba(9, 8, 14, 0.94);
}

.portal-panel label {
  color: #f5f0ff;
}

.portal-panel input {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.portal-panel input::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

.portal-panel small,
.public-grid span {
  color: rgba(255, 255, 255, 0.72);
}

.panel-close-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.price-items {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.price-items div,
.public-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.price-items div {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.price-items strong,
.public-grid strong {
  color: #b48cff;
}

.client-public-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(9, 8, 14, 0.9);
  box-shadow: var(--shadow);
  text-align: left;
}

.client-public-card h2 {
  margin-top: 8px;
}

.client-public-card p {
  color: rgba(255, 255, 255, 0.78);
}

.contact-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.contact-line a {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 8px;
  background: rgba(140, 67, 255, 0.24);
  color: #fff;
  padding: 0 12px;
  text-decoration: none;
  font-weight: 750;
}

.contact-card {
  display: grid;
  gap: 12px;
}

.contact-card strong {
  font-size: 24px;
}

.contact-card a {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 8px;
  background: rgba(140, 67, 255, 0.24);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.app-shell {
  display: none;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

body.crm-unlocked .auth-screen {
  display: none;
}

body.crm-unlocked .app-shell {
  display: grid;
}

body.menu-collapsed .app-shell {
  grid-template-columns: 92px 1fr;
}

.sidebar {
  background: #17221f;
  color: #fff;
  padding: 24px;
  overflow: hidden;
}

.menu-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 40px;
  margin-bottom: 18px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-text,
.nav-button {
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.brand-logo {
  width: 74px;
  height: 52px;
  border-radius: 8px;
  background: transparent;
  object-fit: contain;
  padding: 0;
}

.brand small {
  display: block;
  color: #b9c4bf;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: transparent;
  color: #d9e1de;
  text-align: left;
  cursor: pointer;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

body.menu-collapsed .sidebar {
  padding-inline: 14px;
}

body.menu-collapsed .menu-toggle {
  justify-content: center;
  padding: 0;
}

body.menu-collapsed .menu-toggle span:last-child,
body.menu-collapsed .brand-text {
  display: none;
}

body.menu-collapsed .brand {
  justify-content: center;
}

body.menu-collapsed .brand-logo {
  width: 58px;
  height: 46px;
}

body.menu-collapsed .nav-button {
  min-height: 44px;
  padding: 0;
  text-align: center;
  font-size: 0;
}

body.menu-collapsed .nav-button::first-letter {
  font-size: 18px;
}

.content {
  padding: 30px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.topbar p,
.muted {
  color: var(--muted);
  margin-top: 6px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.action-link,
.secondary-link {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #e8eee9;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 650;
}

.action-link {
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
}

.secondary-link {
  display: grid;
  place-items: center;
  background: #e8eee9;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 650;
  text-decoration: none;
}

.danger-button {
  background: #f5dddd;
  color: var(--danger);
  padding: 0 14px;
  font-weight: 650;
}

.icon-button {
  width: 36px;
  background: #edf0ec;
  font-size: 24px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.panel,
.client-card,
.message-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(26, 37, 35, 0.04);
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  color: var(--muted);
  font-size: 14px;
}

.stat-card strong {
  display: block;
  font-size: 34px;
  margin-top: 8px;
}

.two-column {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.calendar-actions {
  display: flex;
  gap: 8px;
}

.search {
  max-width: 340px;
}

.list,
.stack {
  display: grid;
  gap: 12px;
}

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.calendar-weekday,
.calendar-day {
  min-height: 112px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.calendar-weekday {
  min-height: auto;
  background: #edf0ec;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.calendar-day:nth-child(7n),
.calendar-weekday:nth-child(7n) {
  border-right: 0;
}

.day-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.calendar-day.today .day-number {
  background: var(--accent);
  color: #fff;
}

.calendar-day.outside {
  background: #f8f9f6;
}

.calendar-event {
  display: block;
  width: 100%;
  margin-top: 7px;
  border: 0;
  border-radius: 8px;
  background: #eee8ff;
  color: #4f1fb7;
  padding: 7px;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.client-card,
.message-card {
  padding: 16px;
}

.client-card {
  display: grid;
  gap: 12px;
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-title strong {
  font-size: 17px;
}

.pill {
  align-self: flex-start;
  border-radius: 999px;
  padding: 5px 9px;
  background: #edf0ec;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.pill.warn {
  background: #fff1df;
  color: var(--warn);
}

.pill.ok {
  background: #e0f2e9;
  color: var(--accent-strong);
}

.details {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
}

.card-actions,
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card-actions button,
.card-actions a,
.form-row button {
  flex: 1;
}

.send-help {
  display: grid;
  grid-template-columns: repeat(3, max-content) 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #f7f3ff;
  color: #4f1fb7;
}

.send-help span {
  color: #34403d;
}

.send-help small {
  color: var(--muted);
}

.loyalty-dots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.dot {
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f5f6f1;
}

.dot.filled {
  background: #f0c36a;
  border-color: #d7a643;
}

label {
  display: grid;
  gap: 7px;
  color: #34403d;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 111, 99, 0.12);
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(18, 28, 26, 0.48);
}

.client-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-head,
.dialog-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.dialog-actions {
  grid-template-columns: auto 1fr auto auto;
}

.empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.message-text {
  white-space: pre-wrap;
  color: #34403d;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .auth-screen {
    align-items: start;
    padding: 78px 16px 28px;
  }

  .portal-nav {
    display: flex;
    justify-content: flex-start;
    min-height: 62px;
    padding: 0 10px;
    overflow-x: auto;
  }

  .portal-nav-button {
    flex: 0 0 auto;
    min-height: 62px;
    font-size: 17px;
    white-space: nowrap;
    padding: 0 18px;
  }

  .portal-nav-button + .portal-nav-button::before {
    top: 18px;
    bottom: 18px;
  }

  .auth-logo {
    width: min(560px, 96vw);
    height: 230px;
  }

  .service-view {
    gap: 18px;
  }

  .service-view h1 {
    font-size: clamp(36px, 11vw, 58px);
  }

  .service-view > p {
    font-size: 18px;
  }

  .portal-panel {
    padding: 16px;
  }

  .price-items div,
  .public-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  body.menu-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    grid-template-columns: repeat(4, 1fr);
  }

  body.menu-collapsed .brand,
  body.menu-collapsed .nav {
    display: none;
  }

  body.menu-collapsed .menu-toggle {
    margin-bottom: 0;
  }

  body.menu-collapsed .menu-toggle span:last-child {
    display: inline;
  }

  .nav-button {
    text-align: center;
    padding: 10px 8px;
  }

  .content {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .calendar-actions,
  .panel-head,
  .form-row,
  .two-column {
    display: grid;
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .send-help {
    grid-template-columns: 1fr;
  }

  .calendar-weekday {
    display: none;
  }

  .calendar-day {
    min-height: auto;
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .auth-screen {
    padding-inline: 12px;
  }

  .auth-logo {
    width: min(460px, 98vw);
    height: 190px;
  }

  .hero-input {
    font-size: 17px;
    padding: 15px 6px;
  }

  .hero-button {
    width: 100%;
    padding: 0 18px;
    min-height: 54px;
    letter-spacing: 0.5px;
  }

  .portal-nav {
    min-height: 58px;
  }

  .portal-nav-button {
    min-height: 58px;
    font-size: 15px;
    padding: 0 14px;
  }

  .panel-close-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .client-grid,
  .nav {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }
}
