:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --secondary: #06b6d4;
  --secondary-light: #22d3ee;
  --accent: #ec4899;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  --bg: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  --surface: #1e293b;
  --surface-light: #334155;
  --surface-soft: #1e293b;
  --line: #475569;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 25px 80px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  font-size: 20px;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 900;
  font-size: 18px;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

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

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
}

.button:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.button.primary:hover {
  box-shadow: 0 6px 25px rgba(79, 70, 229, 0.4);
}

.button.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: var(--danger);
}

.button.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.button.ghost {
  background: transparent;
}

.button.small {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13px;
}

.main {
  width: min(1200px, calc(100% - 40px));
  margin: 32px auto 48px;
  flex: 1;
}

.admin-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel,
.survey-card,
.response-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(51, 65, 85, 0.4));
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.muted {
  color: var(--muted);
}

.survey-list {
  display: grid;
  gap: 12px;
}

.survey-row {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(71, 85, 105, 0.1);
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
}

.survey-row:hover {
  background: rgba(79, 70, 229, 0.15);
  border-color: var(--primary);
  transform: translateX(4px);
}

.survey-row.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(6, 182, 212, 0.1));
  box-shadow: inset 0 0 20px rgba(79, 70, 229, 0.1);
}

.survey-row-title {
  font-weight: 800;
  color: var(--text);
  font-size: 14px;
}

.survey-row-meta {
  font-size: 12px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  border-color: var(--primary);
  color: var(--secondary-light);
}

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

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

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(51, 65, 85, 0.4);
  color: var(--text);
  padding: 12px 14px;
  transition: all 0.3s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.question-list {
  display: grid;
  gap: 18px;
}

.question-editor {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background: rgba(51, 65, 85, 0.2);
  transition: all 0.3s ease;
}

.question-editor:hover {
  background: rgba(79, 70, 229, 0.1);
  border-color: var(--primary);
}

.question-editor.required::before {
  content: "*";
  color: var(--accent);
  margin-right: 4px;
}

.question-editor-header {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.question-editor-type {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(79, 70, 229, 0.2);
  color: var(--secondary-light);
  font-weight: 600;
}

.question-editor-text {
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px;
}

.question-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

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

.question-number {
  display: inline-flex;
  min-width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.options-editor {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.public-page {
  min-height: 100vh;
  background: var(--bg);
  background-attachment: fixed;
}

.survey-wrap {
  width: min(860px, calc(100% - 28px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.banner {
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(6, 182, 212, 0.2));
}

.banner img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
}

.banner-fallback {
  display: grid;
  min-height: 200px;
  place-items: center;
  padding: 32px 24px;
  background:
    linear-gradient(135deg, rgba(79, 70, 229, 0.5), rgba(6, 182, 212, 0.5)),
    url("https://images.unsplash.com/photo-1576091160550-2173dba999ef?auto=format&fit=crop&w=1400&q=80");
  background-position: center;
  background-size: cover;
  color: white;
  text-align: center;
}

.banner-fallback h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.12;
  font-weight: 900;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.survey-card {
  border-radius: 0 0 16px 16px;
  padding: 32px;
}

.survey-title {
  margin: 0 0 12px;
  text-align: center;
  color: var(--secondary-light);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.16;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 900;
}

.survey-description {
  margin: 0 auto 24px;
  max-width: 700px;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.6;
}

.question-block {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.question-text {
  margin: 0 0 14px;
  font-weight: 800;
  line-height: 1.45;
  color: var(--text);
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(71, 85, 105, 0.2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.choice:hover {
  background: rgba(79, 70, 229, 0.15);
  border-color: var(--primary);
}

.choice input {
  width: auto;
  margin-top: 3px;
  cursor: pointer;
}

.rating-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.rating-choice {
  display: flex;
  min-height: 50px;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(71, 85, 105, 0.2);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
}

.rating-choice:hover {
  background: rgba(79, 70, 229, 0.15);
  border-color: var(--primary);
  transform: translateX(4px);
}

.rating-choice input {
  width: auto;
  margin-top: 3px;
  cursor: pointer;
}

.footer-box {
  margin-top: 28px;
  padding: 20px 24px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(6, 182, 212, 0.1));
  border: 1px solid var(--line);
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: center;
  white-space: pre-line;
}

.status {
  display: none;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  font-weight: 800;
}

.status.show {
  display: block;
}

.status.success {
  background: rgba(16, 185, 129, 0.15);
  color: #86efac;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.response-list {
  display: grid;
  gap: 12px;
}

.response-card {
  padding: 14px;
  box-shadow: none;
}

.response-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.answer-list {
  display: grid;
  gap: 8px;
}

.answer-item {
  padding: 10px;
  border-radius: 8px;
  background: #f7f9fc;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.share-box {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  background-attachment: fixed;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(51, 65, 85, 0.4));
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 6px;
}

.account-form {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 190px minmax(130px, 180px) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.survey-assignment {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.assignment-choice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.assignment-choice input {
  width: auto;
  margin-top: 2px;
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px 18px;
  }

  .topbar-actions,
  .actions {
    width: 100%;
  }

  .topbar-actions .button,
  .actions .button {
    flex: 1;
  }

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

  .main {
    width: calc(100% - 20px);
    margin-top: 20px;
  }

  .survey-card {
    padding: 24px;
  }

  .panel {
    padding: 18px;
  }

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

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