* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: #EEF0F6;
  color: #2D3448;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: #CE373A; }

/* Login */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  background: #1B1F2D;
}
.login-box {
  background: #fff;
  padding: 2rem;
  border-radius: 16px;
  width: min(400px, 100%);
}
.login-box .btn { width: 100%; min-height: 48px; }

/* App layout */
.admin-app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* Mobile menu button */
.admin-menu-btn {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 201;
  background: #CE373A;
  color: #fff;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(206, 55, 58, 0.4);
  align-items: center;
  justify-content: center;
}
.admin-menu-btn.active { background: #2D3448; }

.admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(27, 31, 45, 0.6);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.3s;
}
.admin-overlay.is-visible {
  display: block;
  opacity: 1;
}
body.admin-menu-open { overflow: hidden; }

.sidebar {
  width: 260px;
  background: #1B1F2D;
  color: #fff;
  padding: 1.25rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 160;
}
.sidebar__brand {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 1rem;
}
.sidebar__brand h1 { font-size: 1rem; color: #f5a5a6; }
.sidebar__brand p { font-size: 0.75rem; opacity: 0.7; margin-top: 0.25rem; }
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  min-height: 48px;
}
.sidebar__nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar__nav a.active {
  background: rgba(206, 55, 58, 0.2);
  color: #fff;
  border-left-color: #CE373A;
}
.sidebar__foot {
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  line-height: 1.8;
}
.sidebar__foot a { color: #f5a5a6; min-height: 44px; display: inline-flex; align-items: center; }

.main {
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
  min-width: 0;
  width: 100%;
}
.main__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.main__head h2 { font-size: clamp(1.2rem, 4vw, 1.5rem); color: #1B1F2D; line-height: 1.3; }
.main__head p { color: #62697C; font-size: 0.9rem; margin-top: 0.35rem; }
.preview-btn {
  background: #2D3448;
  color: #fff;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.alert-ok {
  background: #e8f5ee;
  color: #1a7f4e;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.alert-err {
  background: #fdeaea;
  color: #CE373A;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.section-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #CDD1DE;
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.section-card__head {
  background: #F8F9FC;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #EEF0F6;
}
.section-card__head h3 {
  font-size: 0.95rem;
  color: #CE373A;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.4;
  flex-wrap: wrap;
}
.section-card__head h3::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #CE373A;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.35rem;
}
.section-card__head p {
  font-size: 0.82rem;
  color: #62697C;
  margin-top: 0.35rem;
  line-height: 1.5;
}
.section-card__body { padding: 1.25rem; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
  color: #2D3448;
}
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid #CDD1DE;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  margin-bottom: 1rem;
}
textarea { min-height: 100px; resize: vertical; }

.btn {
  background: #CE373A;
  color: #fff;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 48px;
  touch-action: manipulation;
}
.btn:hover { background: #a82e30; }
.btn--dark { background: #2D3448; }
.btn--sm { padding: 0.55rem 1rem; font-size: 0.85rem; min-height: 44px; }

.save-bar {
  position: sticky;
  bottom: max(0px, env(safe-area-inset-bottom));
  background: #fff;
  border: 1px solid #CDD1DE;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
  margin-top: 1rem;
  z-index: 10;
}
.save-bar span { flex: 1 1 200px; font-size: 0.85rem; color: #62697C; }
.save-bar .btn { flex: 1 1 auto; min-width: 140px; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.media-item {
  border: 1px solid #EEF0F6;
  border-radius: 10px;
  overflow: hidden;
}
.media-item img { width: 100%; height: 90px; object-fit: cover; }
.media-item .meta { padding: 0.45rem; font-size: 0.7rem; word-break: break-all; }
.media-item a.del {
  color: #CE373A;
  font-weight: 600;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.upload-box {
  background: #EEF0F6;
  border: 2px dashed #CDD1DE;
  border-radius: 10px;
  padding: 1rem;
  margin-top: 0.5rem;
}
.upload-box input[type="file"] { margin-bottom: 0.75rem; }
.upload-box .btn { width: 100%; }

.leads { list-style: none; }
.leads li {
  background: #fff;
  border: 1px solid #EEF0F6;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  font-family: ui-monospace, monospace;
  word-break: break-word;
  line-height: 1.5;
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.dash-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #CDD1DE;
}
.dash-card strong { font-size: 1.75rem; color: #CE373A; display: block; }
.dash-card span { font-size: 0.85rem; color: #62697C; }

.help-steps {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #CDD1DE;
  line-height: 1.7;
  font-size: 0.9rem;
}
.help-steps ol { margin: 0.5rem 0 0 1.25rem; }
.help-steps li { margin-bottom: 0.5rem; }

/* ========== Tablet ========== */
@media (max-width: 1024px) {
  .main { padding: 1.25rem 1.5rem 2.5rem; }
}

/* ========== Mobile ========== */
@media (max-width: 768px) {
  .admin-menu-btn { display: flex; }

  .admin-app { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 88vw);
    height: 100dvh;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.25);
    padding-top: max(1.25rem, env(safe-area-inset-top));
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar__nav a {
    font-size: 0.95rem;
    padding: 0.85rem 1.25rem;
  }

  .main {
    padding: 4.5rem 1rem 2rem;
    padding-top: calc(4.5rem + env(safe-area-inset-top));
    max-width: none;
  }

  .main__head {
    flex-direction: column;
    align-items: stretch;
  }
  .main__head > div:first-child { padding-right: 48px; }
  .preview-btn {
    width: 100%;
    justify-content: center;
  }

  .save-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .save-bar .btn { width: 100%; }

  .dash-cards { grid-template-columns: 1fr; }

  .media-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .login-box { padding: 1.5rem; }
}

/* ========== Small phones ========== */
@media (max-width: 400px) {
  .media-grid { grid-template-columns: 1fr 1fr; }
  .section-card__body { padding: 1rem; }
  .admin-menu-btn {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}
