:root {
  --bg: #dfeaf4;
  --panel: #eef3f7;
  --primary: #0f172a;
  --accent: #1d5fe8;
  --accent-soft: #e8eefc;
  --muted: #52657b;
  --success: #0f766e;
  --danger: #d64545;
  --border: #d6dfe8;
  --shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #dfeaf4, #dfeaf4);
  color: var(--primary);
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 32px);
}

.auth-card, .admin-panel {
  width: min(100%, 980px);
  max-width: 100%;
  background: rgba(244, 247, 250, 0.94);
  border: 1px solid rgba(166, 177, 190, 0.28);
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.otp-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
}

.otp-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 12px;
}

.auth-card {
  max-width: 480px;
  padding: 32px;
}

h1, h2, h3, p { margin-top: 0; }

#login-form {
  display: grid;
  gap: 16px;
}

.editor-form {
  display: none;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  border: 1px solid #c8d2de;
  border-radius: 10px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--primary);
  min-height: 44px;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-color: var(--accent);
}

button {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

button:hover { opacity: 0.96; }

button:disabled,
button[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-loading {
  opacity: 0.85;
  cursor: wait !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
  flex-shrink: 0;
}

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

.ghost-btn {
  background: #e4e9ef;
  color: var(--primary);
  border: 1px solid #d0d7df;
}

.ghost-btn.small {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.open-form-btn {
  white-space: nowrap;
}

.status {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
}

.admin-panel {
  padding: clamp(18px, 3vw, 22px);
}

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

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

.empty-state {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed #c0cdd9;
  border-radius: 12px;
  font-size: 0.95rem;
}

.eyebrow {
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  background: #e7ebf0;
  border-radius: 12px;
  border: 1px solid #d8dde3;
  overflow: hidden;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1 1 140px;
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  padding: 10px 18px;
  min-width: 0;
}

.tab-btn.active {
  background: #0f172a;
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.panel {
  display: block;
}

.hidden, .hidden-panel {
  display: none !important;
}

.active-panel {
  display: block;
}

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

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

.modal-header h4 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: #1a2433;
}

.close-form-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 2rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

.row {
  display: grid;
  gap: 14px;
}

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

label,
.list-item,
.list-stack,
.item-actions {
  min-width: 0;
}

.list-stack {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.list-item {
  border: 1px solid rgba(194, 204, 214, 0.8);
  border-radius: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.list-item h4 {
  margin: 0 0 8px;
}

.list-item p {
  margin: 0 0 8px;
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.meta span {
  background: #e2e8f0;
  padding: 5px 8px;
  border-radius: 999px;
}

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

.editor-form.modal-open {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  display: grid;
  width: min(92vw, 760px);
  max-height: 86vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(161, 174, 188, 0.7);
  border-radius: 18px;
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.18);
  padding: 20px 20px 18px;
}

.editor-form.modal-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(28, 36, 46, 0.12);
  z-index: -1;
}

.danger-btn {
  background: #fee2e2;
  color: var(--danger);
}

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

  .editor-form.modal-open {
    width: min(94vw, 640px);
    padding: 18px;
  }

  .auth-card {
    padding: 24px 20px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 16px 12px;
  }

  .auth-card,
  .admin-panel {
    border-radius: 16px;
  }

  .topbar,
  .panel-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar > * + *,
  .panel-head > * + * {
    margin-top: 8px;
  }

  .otp-row {
    grid-template-columns: 1fr;
  }

  .tab-btn {
    flex-basis: 50%;
  }

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

  .item-actions button {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }

  .editor-form.modal-open {
    width: min(96vw, 520px);
    padding: 16px;
  }
}

@media (max-width: 420px) {
  .auth-card {
    padding: 20px 14px;
  }

  .admin-panel {
    padding: 16px 12px;
  }

  .tab-btn {
    flex-basis: 100%;
  }

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