:root {
  --navy-1: #020b3a;
  --navy-2: #01052a;
  --navy-3: #06114f;
  --purple: #4318ff;
  --purple-2: #601cff;
  --purple-soft: #f2edff;
  --text: #09114a;
  --text-soft: #5c689a;
  --line: #e8ebf4;
  --panel: #ffffff;
  --bg: #fbfcff;
  --green: #16a34a;
  --green-soft: #ebf8ef;
  --orange: #ff6900;
  --orange-soft: #fff1e8;
  --pink: #ff2f67;
  --pink-soft: #ffeef4;
  --blue: #2367f7;
  --blue-soft: #ebf2ff;
  --teal: #0aa6b8;
  --teal-soft: #e9fbfd;
  --red: #ef1d33;
  --shadow: 0 12px 28px rgba(13, 19, 64, 0.04);
  --sidebar-w: 224px;
  --sidebar-collapsed: 92px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; border: 0; background: transparent; }
input { outline: none; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

.settings-app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
body.sidebar-collapsed .settings-app { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
.settings-sidebar {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 16px 14px 18px;
  background: radial-gradient(circle at 22px 22px, rgba(96, 32, 255, 0.3), transparent 84px), linear-gradient(180deg, var(--navy-3) 0%, var(--navy-2) 54%, #000b33 100%);
  box-shadow: 18px 0 44px rgba(4, 11, 51, 0.16);
}
.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px 18px; }
.sidebar-brand-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #3200ef 0%, #651dff 100%); box-shadow: 0 12px 24px rgba(68, 24, 255, 0.32); flex: 0 0 44px; }
.sidebar-brand-icon svg { width: 24px; height: 24px; stroke-width: 2; }
.brand-copy strong { display: block; color: #fff; font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.brand-copy small { display: block; margin-top: 2px; color: rgba(255,255,255,0.92); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; }
.sidebar-toggle { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; color: rgba(255,255,255,0.86); border-radius: 10px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.06); }
.sidebar-toggle svg { width: 18px; height: 18px; stroke-width: 2.2; transition: transform .2s ease; }
.settings-nav { padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-item, .logout-link {
  height: 46px; display: flex; align-items: center; gap: 14px; padding: 0 12px; margin-bottom: 5px; border-radius: 10px;
  color: rgba(255,255,255,0.96); font-size: 14px; font-weight: 600; transition: background .2s ease, color .2s ease;
}
.nav-item:hover, .logout-link:hover { background: rgba(255,255,255,0.05); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5e1cff 100%); box-shadow: 0 14px 26px rgba(67, 14, 255, 0.26); }
.nav-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 28px; }
.nav-icon svg { width: 21px; height: 21px; stroke-width: 1.9; }
.nav-text { white-space: nowrap; }
.assist-card { margin: 18px 4px 18px; padding: 18px 16px 16px; border-radius: 12px; background: linear-gradient(180deg, rgba(81, 20, 255, 0.28) 0%, rgba(63, 18, 180, 0.66) 100%); border: 1px solid rgba(255,255,255,0.08); color: #fff; }
.assist-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 800; line-height: 1.35; }
.assist-card p { margin: 0 0 18px; color: rgba(255,255,255,0.96); font-size: 14px; line-height: 1.45; }
.assist-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.assist-bottom-row button { min-width: 114px; height: 38px; padding: 0 14px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); font-size: 13px; font-weight: 700; }
.assist-bot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,0.12); }
.assist-bot svg { width: 22px; height: 22px; stroke-width: 1.8; }
.logout-link { margin-top: 8px; }

.settings-main { min-width: 0; padding: 22px 20px 18px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.page-head p { margin: 6px 0 0; color: var(--text-soft); font-size: 14px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.ghost-btn, .primary-btn {
  height: 46px; padding: 0 18px; border-radius: 12px; font-size: 14px; font-weight: 700;
}
.ghost-btn { color: #1b265f; border: 1px solid #dde2f0; background: #fff; }
.primary-btn { color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); box-shadow: 0 14px 30px rgba(67, 14, 255, 0.18); }

.settings-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.overview-card {
  min-height: 116px; display: flex; gap: 16px; align-items: center; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.overview-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; flex: 0 0 54px; }
.overview-icon svg { width: 24px; height: 24px; stroke-width: 2; }
.accent-purple .overview-icon { color: #fff; background: linear-gradient(135deg, #4318ff 0%, #6621ff 100%); }
.accent-green .overview-icon { color: #fff; background: linear-gradient(135deg, #16a34a 0%, #2cc663 100%); }
.accent-blue .overview-icon { color: #fff; background: linear-gradient(135deg, #2367f7 0%, #4d84ff 100%); }
.overview-label { display: block; color: #6672a3; font-size: 13px; font-weight: 600; }
.overview-card strong { display: block; margin-top: 5px; font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.overview-card p { margin: 6px 0 0; color: var(--text-soft); font-size: 13px; }

.category-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.category-card {
  min-height: 158px; display: flex; flex-direction: column; gap: 16px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.category-card.active { border-color: #d8d2ff; box-shadow: 0 18px 34px rgba(67, 14, 255, 0.08); }
.category-icon { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; }
.category-icon svg { width: 22px; height: 22px; stroke-width: 2; }
.category-icon.purple { color: #4318ff; background: #f2edff; }
.category-icon.blue { color: #2367f7; background: #ebf2ff; }
.category-icon.indigo { color: #5b36ff; background: #efebff; }
.category-icon.orange { color: #ff6900; background: #fff1e8; }
.category-icon.green { color: #16a34a; background: #ebf8ef; }
.category-icon.pink { color: #ff2f67; background: #ffeef4; }
.category-icon.teal { color: #0aa6b8; background: #e9fbfd; }
.category-icon.violet { color: #7e3cff; background: #f4efff; }
.category-icon.sky { color: #2d67ff; background: #eef4ff; }
.category-icon.red { color: #ef1d33; background: #fff0f2; }
.category-card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.category-card p { margin: 0 0 12px; color: #5f6b9b; font-size: 13px; line-height: 1.55; }
.status-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-chip.done { color: #168f42; background: #ebf8ef; }
.status-chip.progress { color: #ff6900; background: #fff1e8; }

.details-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.detail-card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 18px;
}
.detail-card.span-2 { grid-column: span 2; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.detail-head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.detail-head p { margin: 6px 0 0; color: var(--text-soft); font-size: 13px; }
.detail-head button {
  min-width: 92px; height: 38px; padding: 0 14px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); font-size: 13px; font-weight: 700;
}
.detail-head.simple button { background: #fff; color: #3e22ff; border: 1px solid #dfe4f1; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid label { display: block; }
.form-grid span { display: block; margin-bottom: 8px; color: #4e5a8d; font-size: 13px; font-weight: 650; }
.form-grid input {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid #dde2f0; border-radius: 12px; background: #fbfcff; color: #16225b;
}
.stack-list { display: flex; flex-direction: column; gap: 12px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; padding: 0 14px; border-radius: 12px; background: #fbfcff; border: 1px solid #eef1f7;
}
.list-row strong { font-size: 14px; font-weight: 700; }
.list-row span { flex: 1 1 auto; color: #6571a3; font-size: 13px; }
.list-row b { color: #1a255f; font-size: 13px; font-weight: 800; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.mini-stats div { padding: 14px; border-radius: 12px; background: #fbfcff; border: 1px solid #eef1f7; }
.mini-stats span { display: block; color: #6672a3; font-size: 12px; }
.mini-stats strong { display: block; margin-top: 8px; font-size: 14px; font-weight: 800; }
.toggle-list { display: flex; flex-direction: column; gap: 10px; }
.toggle-row { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border-radius: 12px; background: #fbfcff; border: 1px solid #eef1f7; color: #19235c; font-size: 14px; font-weight: 650; }
.switch { position: relative; width: 46px; height: 26px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: #d7ddef; transition: all .2s ease; }
.switch i::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.12); transition: all .2s ease; }
.switch input:checked + i { background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); }
.switch input:checked + i::before { transform: translateX(20px); }
.compact .list-row { min-height: 44px; }
.backup-box { display: flex; flex-direction: column; gap: 14px; }
.backup-pill { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; width: fit-content; font-size: 12px; font-weight: 700; }
.backup-pill.success { color: #168f42; background: #ebf8ef; }
.backup-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: #fbfcff; border: 1px solid #eef1f7; }
.backup-meta span { color: #6672a3; font-size: 13px; }
.backup-meta strong { font-size: 14px; font-weight: 800; }
.pill-list { display: flex; flex-wrap: wrap; gap: 10px; }
.pill-list span { min-height: 34px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; background: #f4f6fd; color: #223065; font-size: 13px; font-weight: 700; }
.appearance-box { display: flex; flex-direction: column; gap: 16px; }
.theme-swatch-row { display: flex; gap: 12px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; display: inline-block; border: 3px solid transparent; }
.swatch.active { border-color: #d6d0ff; box-shadow: 0 0 0 3px rgba(67,24,255,0.08); }
.swatch.purple { background: linear-gradient(135deg, #4318ff 0%, #6424ff 100%); }
.swatch.blue { background: linear-gradient(135deg, #2367f7 0%, #60a0ff 100%); }
.swatch.green { background: linear-gradient(135deg, #16a34a 0%, #2fc86b 100%); }
.swatch.dark { background: linear-gradient(135deg, #0d143f 0%, #26325d 100%); }
.compact-stats { grid-template-columns: repeat(3, minmax(0,1fr)); }
.log-table { border: 1px solid #eef1f7; border-radius: 14px; overflow: hidden; }
.log-row { display: grid; grid-template-columns: 1.1fr 1.7fr .8fr .7fr; gap: 12px; align-items: center; min-height: 48px; padding: 0 16px; border-bottom: 1px solid #eef1f7; font-size: 13px; }
.log-row:last-child { border-bottom: 0; }
.log-row.head { background: #fbfcff; color: #506093; font-weight: 800; }
.log-row b { color: #168f42; }
.log-row b.ok { color: #2367f7; }

body.sidebar-collapsed .settings-sidebar { padding-left: 10px; padding-right: 10px; }
body.sidebar-collapsed .brand-copy, body.sidebar-collapsed .nav-text, body.sidebar-collapsed .assist-copy, body.sidebar-collapsed .assist-bottom-row button, body.sidebar-collapsed .logout-link .nav-text { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-right: 0; padding-left: 0; }
body.sidebar-collapsed .sidebar-brand-row { flex-direction: column; align-items: center; gap: 12px; }
body.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .nav-item, body.sidebar-collapsed .logout-link { justify-content: center; padding: 0; }
body.sidebar-collapsed .assist-card { padding: 12px; display: grid; place-items: center; }
body.sidebar-collapsed .assist-bottom-row { justify-content: center; }

@media (max-width: 1520px) {
  .category-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1320px) {
  .details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-card.span-2 { grid-column: span 2; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .settings-overview { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; align-items: stretch; }
  .head-actions { justify-content: flex-end; }
}
@media (max-width: 980px) {
  .settings-app, body.sidebar-collapsed .settings-app { grid-template-columns: 1fr; }
  .settings-sidebar { min-height: auto; }
  .settings-main { padding: 16px; }
  .head-actions { flex-direction: column; align-items: stretch; }
  .ghost-btn, .primary-btn { width: 100%; }
  .category-grid, .details-grid { grid-template-columns: 1fr; }
  .detail-card.span-2 { grid-column: auto; }
  .form-grid, .mini-stats, .compact-stats { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 1fr; min-height: auto; padding-top: 12px; padding-bottom: 12px; }
}
