/* VaktB – gränssnitt (responsivt, tabeller blir kort på mobil). Version: 20261026-1737 */
:root {
  --bg: #f3f5f8; --surface: #fff; --text: #1d2433; --muted: #5f6b7d; --line: #dfe4ec;
  --brand: #1f4e8c; --brand-dark: #163a69; --brand-soft: #e7eef9;
  --ok: #1e7b4a; --ok-soft: #e3f4ea; --warn: #9a6200; --warn-soft: #fff3d6; --bad: #b42318; --bad-soft: #fde8e6;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.55rem; margin: .2rem 0 1rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: #f0f2f6; padding: .05em .35em; border-radius: 4px; }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid #8fb3ec; outline-offset: 2px; }

/* Topp */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .55rem 1.25rem; background: var(--brand-dark); color: #fff; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--brand-dark); font-weight: 800; }
.mainnav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.mainnav a { color: #dbe6f7; text-decoration: none; padding: .4rem .65rem; border-radius: 7px; font-size: .93rem; }
.mainnav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.mainnav a.is-active { background: rgba(255, 255, 255, .18); color: #fff; font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.usermenu-name { color: #fff; text-decoration: none; font-weight: 600; }
.usermenu-name:hover { color: #fff; text-decoration: underline; }
.nav-toggle { display: none; margin-left: auto; background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .4); border-radius: 7px; padding: .35rem .7rem; font: inherit; }
.container { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem 2rem; }

/* Kort och rutnät */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-head h1 { margin-bottom: .5rem; }
.breadcrumb { margin: 0 0 .25rem; font-size: .88rem; color: var(--muted); }
.section-title { margin-top: 1.5rem; }
.danger-zone { border-color: #f3c3bd; }

/* Statistik */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: .85rem 1rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--brand); color: var(--text); }
.stat.is-ok { border-left-color: var(--ok); }
.stat.is-warn { border-left-color: #e0a100; }
.stat.is-bad { border-left-color: var(--bad); }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-value.small { font-size: 1rem; }
.stat-label { color: var(--muted); font-size: .88rem; }

/* Formulär */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }
label small { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=number], input[type=date], select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: #fff; border: 1px solid #c9d1dd; border-radius: 8px; padding: .55rem .65rem; width: 100%; min-height: 42px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid #cfe0f7; outline-offset: 0; }
input[readonly], input:disabled, select:disabled, textarea:disabled { background: #f3f5f8; color: var(--muted); }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; font-size: .95rem; padding: .2rem 0; }
label.check input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem .8rem; margin: 0; min-width: 0; }
legend { font-weight: 700; font-size: .9rem; padding: 0 .3rem; }
.form-stack { display: flex; flex-direction: column; gap: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.2rem; align-items: start; }
.form-grid.inner { margin-bottom: .3rem; }
.form-grid > h2 { margin-bottom: 0; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }
.form-row { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin-top: .75rem; }
.form-row > h2 { flex-basis: 100%; margin: 0; }
.form-row label { flex: 1 1 180px; }
.input-unit { display: flex; align-items: center; gap: .4rem; }
.input-unit span { color: var(--muted); font-weight: 400; white-space: nowrap; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 1rem 0 .5rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem 1rem; align-items: end; }
.filters .filter-actions { display: flex; gap: .5rem; flex-wrap: wrap; grid-column: 1 / -1; }
.log-filters .span-2 { grid-column: span 2; }
form.inline { display: inline; }

/* Knappar */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600; font-size: .92rem; padding: .5rem .95rem; min-height: 40px; border-radius: 8px; border: 1px solid #c3ccd9; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f2f5f9; color: var(--text); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #8f1c13; color: #fff; }
.btn-light { background: #f6f8fb; }
.btn-small { min-height: 32px; padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--brand); text-decoration: underline; padding: .3rem; min-height: 0; font-weight: 500; }
.btn-link:hover { background: none; color: var(--brand-dark); }
.topbar .btn-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.topbar .btn-light:hover { background: rgba(255, 255, 255, .12); }

/* Meddelanden och märken */
.notice { padding: .7rem .95rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid transparent; word-break: break-word; }
.notice-ok { background: var(--ok-soft); border-color: #b5e0c6; color: #14532d; }
.notice-error { background: var(--bad-soft); border-color: #f5b8b1; color: #7a1a12; }
.notice-info { background: var(--brand-soft); border-color: #c4d6f2; color: #173e70; }
.notice-warn { background: var(--warn-soft); border-color: #f1d18a; color: #6a4300; }
.secret-box code { display: inline-block; margin: .4rem 0; padding: .4rem .6rem; font-size: .95rem; background: #fff; user-select: all; word-break: break-all; cursor: copy; }
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef1f5; color: #3d4757; white-space: nowrap; vertical-align: middle; }
.badge-ok, .status-active { background: var(--ok-soft); color: var(--ok); }
.badge-warn, .status-password_change, .status-pending { background: var(--warn-soft); color: var(--warn); }
.badge-bad, .status-locked, .status-disabled { background: var(--bad-soft); color: var(--bad); }
.status-archived { background: #e9ebef; color: #59606b; }

/* Tabeller */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
.card .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { background: #f7f9fc; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table tr.is-fail td { background: #fff7f6; }
.table .group-row th { background: var(--brand-soft); color: var(--brand-dark); font-size: .88rem; }
.table.compact th, .table.compact td { padding: .35rem .5rem; }
.ua { color: var(--muted); font-size: .82rem; max-width: 280px; }
.diff { font-size: .82rem; max-width: 320px; word-break: break-word; }
.event-type { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; background: #eef1f5; padding: .05rem .4rem; border-radius: 4px; white-space: nowrap; }

/* Listor */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.event-list li:last-child { border-bottom: 0; }
.event-list li.is-fail { border-left: 3px solid var(--bad); padding-left: .5rem; }
.event-list.compact li { padding: .35rem 0; font-size: .85rem; }
.event-time { color: var(--muted); font-size: .82rem; margin-right: .4rem; }
.plain-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.plain-list li { padding: .3rem 0; }
.plain-list.cols { columns: 2 260px; }
.app-list { list-style: none; padding: 0; margin: 0; }
.app-list li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.checklist { list-style: none; padding: 0; margin: 0 0 1rem; }
.checklist li { padding: .3rem 0; }
.checklist .is-ok span { color: var(--ok); font-weight: 700; }
.checklist .is-fail span { color: var(--bad); font-weight: 700; }
.group-title { color: var(--brand-dark); border-bottom: 1px solid var(--line); padding-bottom: .2rem; }

/* Flikar och sidor */
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 2px solid var(--line); margin-bottom: 1rem; scrollbar-width: thin; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a:hover { color: var(--text); }
.tabs a.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.pager { display: flex; gap: .3rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.pager a, .pager span { display: inline-block; min-width: 36px; text-align: center; padding: .35rem .55rem; border-radius: 7px; border: 1px solid var(--line); background: #fff; text-decoration: none; }
.pager .is-current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Inloggningssidor */
body.is-bare { background: linear-gradient(160deg, #e9eff8 0%, #f6f8fb 60%); min-height: 100vh; }
.auth-wrap { max-width: 440px; margin: 0 auto; padding: 8vh 16px 2rem; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; font-size: 1.35rem; font-weight: 700; color: var(--brand-dark); margin-bottom: 1.25rem; }
.auth-brand .brand-mark { background: var(--brand-dark); color: #fff; width: 38px; height: 38px; font-size: 1.2rem; }
.auth-card { padding: 1.5rem 1.6rem; }
.auth-card.wide { max-width: none; }
.auth-wrap:has(.wide) { max-width: 760px; }
.auth-links { text-align: center; margin: 1rem 0 0; font-size: .92rem; }
.code-input { font-size: 1.5rem !important; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.form-inline-center { text-align: center; margin-top: .4rem; }

/* Mobil */
@media (max-width: 960px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .container { padding: 1rem 16px; }
  .topbar { padding: .55rem 16px; }
  .nav-toggle { display: inline-block; }
  .mainnav, .usermenu { display: none; width: 100%; }
  .topbar.is-open .mainnav { display: flex; flex-direction: column; }
  .topbar.is-open .usermenu { display: flex; justify-content: space-between; padding: .5rem 0 .2rem; border-top: 1px solid rgba(255, 255, 255, .2); }
  .mainnav a { padding: .6rem .5rem; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .log-filters .span-2 { grid-column: auto; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: .5rem; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .7rem; padding: .35rem .2rem; box-shadow: var(--shadow); }
  .table.responsive tr.group-row { background: var(--brand-soft); padding: .1rem; }
  .table.responsive tr.group-row th { display: block; background: transparent; }
  .table.responsive td { border: 0; padding: .3rem .75rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .5rem; overflow-wrap: anywhere; }
  .table.responsive td::before { flex: 0 0 8.5rem; }
  .table.responsive td > form { display: inline; }
  .table.responsive code { word-break: break-all; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; }
  .table.responsive td[data-label=""]::before { content: none; }
  .table.responsive td[data-label=""] { display: block; }
  .ua, .diff { max-width: none; }
  .btn { min-height: 44px; }
  .btn-small { min-height: 38px; }
  .auth-wrap { padding-top: 4vh; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print { .topbar, .footer, .filters, .form-actions, .tabs, .pager { display: none !important; } body { background: #fff; } }
/* Loggtabeller: kompakta, tid och händelse på en rad */
.log-table { font-size: .86rem; }
.log-table td:first-child, .log-table td:nth-child(4), .log-table td:nth-child(7) { white-space: nowrap; }
@media (max-width: 760px) { .log-table td:first-child, .log-table td:nth-child(4), .log-table td:nth-child(7) { white-space: normal; } }
