:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #111827;
  --muted: #64748b;
  --line: #d8e0ec;
  --accent: #2563eb;
  --accent-2: #0891b2;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
  --danger: #ef4444;
  --orange: #f97316;
  --yellow: #eab308;
  --green: #22c55e;
  --blue: #3b82f6;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1f2937;
    --text: #f8fafc;
    --muted: #9ca3af;
    --line: #2f3b4f;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  }
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1f2937;
  --text: #f8fafc;
  --muted: #9ca3af;
  --line: #2f3b4f;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

html[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 28rem),
    linear-gradient(180deg, var(--bg), var(--surface-2));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.panel-heading,
.tabs,
.theme-control,
.preset-row,
.badge-row,
.chart-legend,
.generated-actions,
.action-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1.12rem;
}

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

.theme-control,
.tabs,
.generator-menu {
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow);
}

.theme-btn,
.tab,
.mode-btn,
.ghost-btn,
.primary-btn,
.danger-btn {
  border: 0;
  border-radius: 7px;
  color: var(--text);
  background: transparent;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.theme-btn,
.tab {
  padding: 10px 13px;
}

.theme-btn.active,
.tab.active,
.mode-btn.active {
  background: var(--accent);
  color: white;
}

.tabs {
  justify-content: center;
  gap: 4px;
  margin: 20px 0;
}

.section {
  display: none;
  animation: rise 280ms ease;
}

.section.active {
  display: block;
}

.grid {
  display: grid;
  gap: 18px;
}

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

.lower-grid,
.settings-panel {
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  padding: 20px;
}

.privacy-note {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.55;
}

.privacy-note strong {
  color: var(--text);
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field select,
.password-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.field input,
.field select {
  padding: 12px;
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  overflow: hidden;
}

.password-field input {
  border: 0;
}

.password-field button {
  border: 0;
  border-left: 1px solid var(--line);
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text);
}

.strength-meter {
  height: 12px;
  margin: 18px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.strength-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--danger);
  transition: width 220ms ease, background 220ms ease;
}

.strength-label {
  font-weight: 900;
}

.action-row {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.action-row.compact {
  margin-top: 0;
  justify-content: flex-end;
}

.recommendations {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.recommendation,
.history-item,
.generated-item,
.time-item,
.metric-card,
.status-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.recommendation,
.status-box {
  padding: 10px 12px;
  color: var(--muted);
}

.status-box {
  margin-top: 12px;
  line-height: 1.45;
}

.status-box.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: #dc2626;
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

.status-box.ok {
  border-color: color-mix(in srgb, var(--green) 45%, var(--line));
  color: #047857;
  background: color-mix(in srgb, var(--green) 8%, var(--surface));
}

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

.metric-card {
  padding: 14px;
}

.metric-card.wide {
  grid-column: 1 / -1;
}

.metric-value {
  margin-top: 5px;
  font-size: 1.25rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.metric-label,
.time-label,
.template-help {
  color: var(--muted);
  font-size: 0.9rem;
}

.badge-row,
.preset-row {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.badge,
.preset-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
}

.badge.ok {
  color: #047857;
}

.badge.bad {
  color: #dc2626;
}

.time-list,
.generated-list,
.history-list {
  display: grid;
  gap: 10px;
}

.time-item,
.generated-item,
.history-item {
  padding: 13px;
}

.time-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.time-value {
  font-weight: 900;
}

.chart-panel canvas {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: crosshair;
}

.chart-legend {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
}

.current { background: var(--accent); }
.recommended { background: var(--green); }
.corporate { background: var(--orange); }
.high { background: var(--blue); }

.generator-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  margin-top: 18px;
}

.generator-menu {
  align-self: start;
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow);
}

.mode-btn {
  padding: 12px;
  text-align: left;
}

.generator-workspace {
  display: grid;
  gap: 18px;
}

.generator-mode {
  display: none;
}

.generator-mode.active {
  display: block;
}

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

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

.checks-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.checks-grid label {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.primary-btn,
.ghost-btn,
.danger-btn {
  padding: 10px 14px;
  font-weight: 900;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
}

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

.generated-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.generated-value,
.history-value {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-weight: 800;
}

.generated-value.hidden {
  letter-spacing: 0.12em;
}

.generated-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.generated-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.icon-btn {
  min-width: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-2);
  color: var(--text);
}

.history-item {
  display: grid;
  gap: 5px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  transform: translateY(20px);
  opacity: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 200ms ease, opacity 200ms ease;
}

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

.chart-tooltip {
  position: fixed;
  z-index: 15;
  display: none;
  max-width: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  pointer-events: none;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 860px) {
  .topbar,
  .grid.two,
  .generator-layout,
  .form-grid,
  .checks-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .theme-control,
  .tabs {
    overflow-x: auto;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .panel {
    padding: 14px;
  }

  .metric-grid,
  .time-item,
  .generated-item {
    grid-template-columns: 1fr;
  }

  .action-row.compact {
    justify-content: flex-start;
  }
}
