/* AvernVPN web UI. No external fonts or frameworks: the page must work under
   the strict Content-Security-Policy of the server (no inline styles). */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6675;
  --border: #d9dee6;
  --border-strong: #b8c1cc;
  --primary: #1f6feb;
  --primary-hover: #1a5fcc;
  --danger: #c62828;
  --danger-hover: #a51f1f;
  --radius: 8px;
  --gap: 16px;

  color: var(--text);
  background: var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

* { box-sizing: border-box; }

/* Author rules such as `.form { display: grid }` must not defeat the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
}

a { color: var(--primary); }

h1 { font-size: 1.5rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }

/* Top bar and navigation */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 4px;
}

.nav a {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.nav a:hover { background: #eef2f7; }

.nav a[aria-current="page"] {
  background: #e8f0fe;
  color: var(--primary);
  font-weight: 600;
}

.account {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Layout */

.content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.screen,
.screen-body,
.stack {
  display: grid;
  gap: var(--gap);
}

.screen-body { gap: var(--gap); }

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

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

.card,
section.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card-narrow {
  max-width: 460px;
  margin: 32px auto;
  display: grid;
  gap: 14px;
}

.form {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 4px;
  font-size: 0.93rem;
}

.field-label { font-weight: 600; }

.field-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

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

.break { word-break: break-all; }

/* Form controls */

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

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

textarea {
  min-height: 72px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 0.9rem;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
}

input:disabled,
select:disabled {
  background: #f1f3f6;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid #8ab4f8;
  outline-offset: 1px;
}

/* Buttons */

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--primary-hover); }

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
}

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

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

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

.btn-small {
  padding: 4px 10px;
  font-size: 0.88rem;
}

/* Notices, badges and status */

.notice {
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 0.95rem;
}

.notice[hidden] { display: none; }

.notice-error {
  background: #fdecea;
  border-color: #f5c2c0;
  color: #8a1c1c;
}

.notice-success {
  background: #e7f5ec;
  border-color: #b7e1c4;
  color: #165a2c;
}

.notice-info {
  background: #eef4ff;
  border-color: #c5d8fb;
  color: #1d3d75;
}

.notice-warning {
  background: #fff6e0;
  border-color: #f3d48a;
  color: #6b4a00;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #33404f;
  font-size: 0.8rem;
  white-space: nowrap;
}

.badge-ok { background: #e7f5ec; color: #165a2c; }
.badge-warn { background: #fff6e0; color: #6b4a00; }
.badge-bad { background: #fdecea; color: #8a1c1c; }

code {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  word-break: break-all;
}

.empty,
.boot {
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
}

/* Tables */

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

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

.table th {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Details list, progress, path builder and tree */

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
}

.details dt { color: var(--muted); }
.details dd { margin: 0; }

progress {
  width: 100%;
  height: 12px;
}

.path-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.path-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfe;
}

.path-item .pos {
  min-width: 2em;
  font-weight: 700;
}

.tree {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: none;
}

.tree li { margin: 4px 0; }

/* Narrow screens */

@media (max-width: 720px) {
  .topbar { padding: 10px 12px; }
  .account { width: 100%; justify-content: space-between; }
  .content { padding: 16px 12px 36px; }
  .table th,
  .table td { padding: 6px; }
  .details { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
