:root {
  --color-bg-page: #f0f2f5;
  --color-nav-bg: #0f172a;
  --color-nav-divider: #334155;
  --color-nav-text: #ffffff;
  --color-nav-text-hover: #e2e8f0;
  --color-nav-text-active: #ffffff;
  --color-nav-hover-bg: transparent;
  --color-brand-accent: #3b82f6;
  --color-primary-600: #2563eb;
  --shadow-nav: 0 2px 8px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg-page);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: #1e293b;
}

body {
  display: flex;
  flex-direction: column;
}

.app-navbar {
  min-height: 50px;
  flex: 0 0 auto;
  background: var(--color-nav-bg);
  box-shadow: var(--shadow-nav);
  padding: 6px 28px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-list a {
  display: inline-block;
  padding: 4px 14px;
  font-size: var(--nav-font-size, 1.4rem);
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--color-nav-text);
  background: transparent;
  text-decoration: none;
  border-radius: 6px;
  border: 1.5px solid transparent;
  transition: opacity .15s;
}

.nav-list a .brand-accent {
  color: var(--color-brand-accent);
}

.nav-list a:hover {
  opacity: .8;
}

.nav-list a.active {
  background: transparent;
}

.divider {
  width: 1px;
  height: 26px;
  background: var(--color-nav-divider);
}

#settings-btn {
  margin-left: auto;
  width: 34px;
  height: 34px;
  color: #94a3b8;
  border: 1.5px solid var(--color-nav-divider);
  border-radius: 8px;
}

#settings-btn:hover {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #475569;
}

.app-frame-wrap {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

#app-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--color-bg-page);
}

@media (max-width: 768px) {
  .app-navbar { padding: 6px 12px; }
  .nav-list { gap: 8px; }
  .nav-list a { padding: 4px 10px; }
  .rows-header,
  .row { grid-template-columns: 1fr; gap: 6px; }
  .rows-header span:nth-child(2),
  .rows-header span:nth-child(3) { display: none; }
  .row-remove { justify-self: end; }
  .modal-footer { flex-wrap: wrap; }
  .footer-password { flex: 1 1 100%; order: -1; }
}

/* Generic icon button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  color: inherit;
  transition: background .15s, color .15s, border-color .15s;
}

/* Settings modal */
body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

.modal-close {
  width: 30px;
  height: 30px;
  color: #64748b;
  border-radius: 6px;
}

.modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.setting-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.setting-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  font-weight: 600;
  color: #475569;
}

.setting-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--color-primary-600);
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .78rem;
}

.setting-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  outline: none;
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary-600);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, .4);
  transition: transform .12s;
}

.setting-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary-600);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, .4);
}

.setting-slider:hover::-webkit-slider-thumb { transform: scale(1.1); }

.setting-block-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
  margin-bottom: 8px;
}

.rows-header,
.row {
  display: grid;
  grid-template-columns: 1fr 2fr 32px;
  gap: 10px;
  align-items: center;
}

.rows-header {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
  padding: 0 4px 6px;
}

.rows {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  padding: 0;
}

.row-name,
.row-url {
  font-family: inherit;
  font-size: .85rem;
  color: #1e293b;
  padding: 7px 11px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  min-width: 0;
}

.row-name:focus,
.row-url:focus {
  outline: none;
  border-color: var(--color-primary-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.row-remove {
  width: 32px;
  height: 32px;
  color: #94a3b8;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
}

.row-remove:hover {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.btn-add-row {
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: #475569;
  background: transparent;
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  width: 100%;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-add-row:hover {
  background: #f8fafc;
  color: var(--color-primary-600);
  border-color: var(--color-primary-600);
}

.modal-error {
  margin: 12px 0 0;
  padding: 8px 12px;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 600;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.footer-password {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: .85rem;
  color: #1e293b;
  padding: 8px 11px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  transition: border-color .15s, box-shadow .15s;
}

.footer-password:focus {
  outline: none;
  border-color: var(--color-primary-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.btn-primary,
.btn-secondary {
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}

.btn-primary {
  color: #ffffff;
  background: var(--color-primary-600);
  border: 0;
  padding: 9px 22px;
}

.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  color: #475569;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  padding: 8px 18px;
}

.btn-secondary:hover {
  background: #e2e8f0;
}
