:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #dbe1ea;
  --text: #16202f;
  --muted: #607086;
  --accent: #0f62fe;
  --accent-soft: #e8f0ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #101829;
  color: #eef3fb;
  padding: 24px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 700;
}

.brand-title {
  font-weight: 700;
}

.brand-subtitle {
  color: #a9b7ca;
  font-size: 13px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-link {
  padding: 10px 12px;
  border-radius: 8px;
  color: #d6dfec;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.content {
  padding: 28px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
}

.muted {
  color: var(--muted);
  margin-top: 6px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card,
.panel,
.sequence-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-card {
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  margin-top: 8px;
}

.panel {
  padding: 18px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.two-col,
.grid-wide {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr;
  gap: 20px;
  margin-bottom: 20px;
}

.grid-wide {
  grid-template-columns: 1.4fr 0.9fr;
}

.stack-col {
  display: grid;
  gap: 20px;
  align-content: start;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label,
.sequence-card label {
  display: grid;
  gap: 8px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
}

textarea {
  resize: vertical;
}

select {
  appearance: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.subtle {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.button.danger {
  background: #fff2f2;
  border-color: #ffcaca;
  color: #a82626;
}

.inline-form {
  display: inline-flex;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
  padding: 24px 12px;
}

.sequence-card {
  padding: 14px;
}

.sequence-card legend {
  padding: 0 6px;
  font-weight: 700;
}

.code-editor {
  min-height: 220px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.html-preview-wrap {
  display: grid;
  gap: 8px;
}

.html-preview-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.html-preview {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.text-preview {
  min-height: 160px;
  margin: 0;
  white-space: pre-wrap;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  color: var(--text);
  font: inherit;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.apply-template-row {
  margin-bottom: 12px;
}

.inline-template-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.inline-template-form .button {
  white-space: nowrap;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding-top: 24px;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.lang-button {
  height: 28px;
  min-width: 38px;
  border: 0;
  border-radius: 6px;
  color: #c8d3e3;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.lang-button.active {
  color: #0f172a;
  background: #ffffff;
}

.user-mini {
  color: #d6dfec;
  font-size: 13px;
}

.user-email {
  font-weight: 700;
  word-break: break-word;
}

.user-role {
  color: #a9b7ca;
  margin-top: 4px;
  text-transform: capitalize;
}

.logout-button {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #eef3fb;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f7;
}

.auth-shell {
  width: min(420px, calc(100vw - 32px));
}

.auth-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
}

.auth-brand {
  color: var(--text);
}

.simple-title {
  margin: 20px 0 8px;
  font-size: 24px;
}

.auth-language {
  margin: 18px 0;
  border-color: var(--border);
  background: #f5f7fb;
}

.auth-language .lang-button {
  color: var(--muted);
}

.auth-language .lang-button.active {
  color: #ffffff;
  background: var(--primary);
}

.notice {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
}

.notice.error {
  color: #8a1f1f;
  background: #ffecec;
  border: 1px solid #ffd0d0;
}

.secret-box {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.qr-box {
  width: 196px;
  padding: 12px;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.qr-box img {
  display: block;
  width: 100%;
  height: auto;
}

.secret-box code,
.recovery-grid code {
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

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

.recovery-grid code {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.import-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.details-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  background: #f8fafc;
}

.details-list summary {
  cursor: pointer;
  font-weight: 700;
}

.details-list ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .stats-grid,
  .two-col,
  .grid-wide {
    grid-template-columns: 1fr;
  }
}
