:root {
  --bg-a: #f4fbff;
  --bg-b: #dff3ff;
  --card: rgba(255, 255, 255, 0.76);
  --line: rgba(95, 179, 232, 0.18);
  --text: #16344d;
  --muted: #6f8da8;
  --blue: #1f9cff;
  --blue-soft: rgba(110, 203, 255, 0.18);
  --shadow: 0 18px 50px rgba(73, 135, 179, 0.14);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-a), var(--bg-b));
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

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

button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #45b8ff, #7ad8ff);
  cursor: pointer;
  font-weight: 750;
}

button.ghost,
a {
  color: var(--blue);
  background: var(--blue-soft);
  text-decoration: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  outline: 0;
}

input {
  height: 44px;
  padding: 0 14px;
}

select {
  height: 44px;
  padding: 0 38px 0 14px;
}

textarea {
  min-height: 92px;
  padding: 12px 14px;
  resize: vertical;
}

.hidden { display: none !important; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.login-card,
.card,
.table-card,
.form-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.login-card {
  width: min(460px, 100%);
  padding: 36px;
}

.login-card h1,
.topbar h1,
.sidebar h2 {
  margin: 0;
}

.login-card input {
  margin: 22px 0 14px;
}

.tip,
.muted,
.eyebrow {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tip {
  margin: 14px 0 0;
  font-size: 13px;
}

.admin-view {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 20px;
  border-right: 1px solid var(--line);
  background: rgba(232, 247, 255, 0.86);
}

.sidebar nav {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.tab {
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 0 16px;
  border-radius: 16px;
  color: #42627c;
  cursor: pointer;
  font-weight: 700;
}

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, #45b8ff, #7ad8ff);
}

.workspace {
  position: relative;
  min-width: 0;
  padding: 30px;
}

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

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions a {
  display: flex;
  min-height: 42px;
  align-items: center;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 750;
}

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

.card {
  padding: 22px;
}

.stat-num {
  font-size: 34px;
  font-weight: 850;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  padding: 22px;
  border: 1px solid rgba(255, 107, 95, 0.22);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.danger-zone h3 {
  margin: 0 0 8px;
}

.danger-zone p:last-child {
  margin-bottom: 0;
}

.solid-danger {
  flex: 0 0 auto;
  color: #fff !important;
  background: linear-gradient(135deg, #ff7c70, #ffb16f) !important;
}

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

.toolbar input {
  max-width: 320px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-group select {
  min-width: 180px;
}

.table-card {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

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

.row-actions button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.danger {
  color: #ff6b5f !important;
  background: rgba(255, 138, 92, 0.14) !important;
}

.busy-mask {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(242, 248, 255, 0.52);
  backdrop-filter: blur(6px);
  z-index: 40;
}

.busy-card {
  display: flex;
  min-width: 180px;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 28px;
  border: 1px solid rgba(95, 179, 232, 0.18);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 20px 60px rgba(73, 135, 179, 0.16);
}

.busy-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(31, 156, 255, 0.16);
  border-top-color: #1f9cff;
  border-radius: 50%;
  animation: busy-spin 0.8s linear infinite;
}

.busy-text {
  color: #16344d;
  font-size: 15px;
  font-weight: 700;
}

.admin-toast {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 18px;
  border: 1px solid rgba(95, 179, 232, 0.2);
  border-radius: 18px;
  color: #12344d;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 50px rgba(73, 135, 179, 0.2);
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(18px);
}

.admin-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.admin-toast.error {
  border-color: rgba(255, 107, 95, 0.25);
  color: #b73a30;
}

@keyframes busy-spin {
  to { transform: rotate(360deg); }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.field-heading {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.service-hours-field {
  display: grid;
}

.service-hours-card {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px 0 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.service-hours-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.service-hours-card button {
  min-height: 34px;
  padding: 0 14px;
  flex: 0 0 auto;
  font-size: 13px;
}

.span-2 {
  grid-column: 1 / -1;
}

.form-card {
  padding: 22px;
}

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

.upload-tools {
  display: flex;
  align-items: end;
  gap: 10px;
}

.upload-tools button {
  min-height: 38px;
}

.asset-empty {
  padding: 12px 14px;
  border: 1px dashed rgba(95, 179, 232, 0.32);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.46);
  font-size: 13px;
}

.asset-preview,
.banner-preview,
.material-editor {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
}

.asset-preview img,
.banner-preview img {
  width: 128px;
  height: 76px;
  border-radius: 14px;
  object-fit: cover;
  background: #fff;
}

#serviceQrPreview .asset-preview img {
  width: 112px;
  height: 112px;
}

.asset-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.asset-preview-actions a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
}

.material-editor,
.banner-preview {
  margin-top: 10px;
}

.chapter-editor {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.5fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
}

.chapter-editor button {
  min-height: 42px;
  white-space: nowrap;
}

.chapter-tools {
  margin-top: 10px;
}

.field-hint {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.chapter-actions button,
.chapter-actions a {
  min-height: 42px;
}

.chapter-actions a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
}

.material-editor input:first-child {
  flex: 0 0 220px;
}

.material-editor input:nth-child(2) {
  flex: 1 1 auto;
}

.material-editor input[data-material-price] {
  flex: 0 0 110px;
}

.inline-check {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
  min-height: 0;
}

.material-editor button,
.banner-preview button {
  flex: 0 0 auto;
}

.banner-preview > div {
  min-width: 0;
  flex: 1 1 auto;
}

.banner-text-preview {
  display: grid;
  width: 128px;
  height: 76px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #45b8ff, #87ddff);
  font-size: 18px;
  font-weight: 850;
}

.banner-course-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.banner-course-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 10px;
  margin-bottom: 10px;
}

.banner-course-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.banner-course-option {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.62);
  cursor: pointer;
}

.banner-course-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--blue);
}

.banner-course-option span {
  min-width: 0;
}

.banner-course-option strong,
.banner-course-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banner-course-option small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.banner-course-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.banner-course-pager button {
  min-height: 34px;
  padding: 0 13px;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .admin-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .toolbar,
  .danger-zone {
    align-items: flex-start;
    flex-direction: column;
  }

  .banner-course-tools,
  .banner-course-picker {
    grid-template-columns: 1fr;
  }

  .banner-course-pager {
    align-items: stretch;
    flex-direction: column;
  }

  .chapter-editor {
    grid-template-columns: 1fr;
  }
}
