/* Servermeister Beheer. No inline styles anywhere (CSP: style-src 'self'). */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --border: #e3e2de;
  --text: #1f1f1d;
  --muted: #6f6e69;
  --accent: #f5a623;
  --accent-strong: #d98a06;
  --accent-text: #1a1a1a;
  --link: #1f6feb;
  --red: #d93025;   --red-bg: #fdecea;
  --orange: #c26a00; --orange-bg: #fff3e0;
  --green: #1e7f3c; --green-bg: #e6f4ea;
  --blue: #1f5fbf;  --blue-bg: #e8f0fe;
  --sidebar-bg: #1c1c1b;
  --sidebar-text: #d6d5d1;
  --sidebar-muted: #8b8a85;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 1px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --surface: #202020;
    --surface-2: #2a2a2a;
    --border: #333331;
    --text: #e8e7e3;
    --muted: #9b9a95;
    --link: #6ea8ff;
    --red: #ff7b72;   --red-bg: #3a1f1d;
    --orange: #f0a64a; --orange-bg: #3a2a16;
    --green: #6fcf8a; --green-bg: #1b3324;
    --blue: #7fb0ff;  --blue-bg: #1c2a40;
    --sidebar-bg: #141414;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code, kbd { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------ app shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: none; background: var(--sidebar-bg); color: var(--sidebar-text);
  padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 7px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .5px;
}
.brand-text { font-weight: 700; line-height: 1.1; }
.brand-text small { display: block; font-weight: 500; color: var(--sidebar-muted); font-size: 12px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 14px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px;
  color: var(--sidebar-text); font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav-item.is-active { background: rgba(245,166,35,.16); color: #fff; }
.nav-item.is-active .icon { color: var(--accent); }
.nav-item.is-disabled { opacity: .45; cursor: default; }
.nav-item.is-disabled:hover { background: none; }
.nav-badge { margin-left: auto; font-size: 10px; border: 1px solid currentColor; border-radius: 10px; padding: 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.menu-btn { display: none; }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: var(--radius); padding: 0 10px; color: var(--muted); }
.search input[type=search] { flex: 1; border: 0; background: transparent; padding: 9px 0; font: inherit; color: var(--text); outline: none; min-width: 0; }
.search kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 11px; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 4px 8px; border-radius: var(--radius); }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.user-name { line-height: 1.15; font-weight: 600; }
.user-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 7px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; }

/* ------------------------------------------------ components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-narrow { max-width: 560px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 10px; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-info { background: var(--blue-bg); color: var(--blue); }
.alert-warning { background: var(--orange-bg); color: var(--orange); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; background: var(--surface-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-blue { background: var(--blue-bg); color: var(--blue); }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 600; font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; border-color: var(--accent); }
.search input[type=search]:focus { outline: none; }
select:disabled, input:disabled { opacity: .6; }
.input-code { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
.form-actions { display: flex; gap: 8px; }
.role-help strong { color: var(--text); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 0; }
.filters .input-sm { width: 110px; }

/* tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-muted td { color: var(--muted); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.detail-cell code { font-size: 12px; color: var(--muted); word-break: break-all; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 16px 0; }

/* properties list */
.props { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0 0 12px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 1.6rem; font-weight: 700; }
.tile-note { font-size: 11px; color: var(--muted); }
.phases { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.phases li.is-done::marker { color: var(--green); }
.phases li.is-done strong::after { content: " ✓"; color: var(--green); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed-time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* secrets */
.secret { font-family: var(--mono); background: var(--surface-2); padding: 6px 10px; border-radius: 6px; font-size: 15px; letter-spacing: .04em; word-break: break-all; }
.copy-field { display: flex; gap: 8px; align-items: center; margin: 10px 0 16px; flex-wrap: wrap; }

/* errors */
.error-page { text-align: center; padding: 60px 20px; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--accent); line-height: 1; }

/* ------------------------------------------------ guest pages (login / 2FA) */
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.guest-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.brand-guest { padding: 0 0 18px; }
.brand-guest .brand-text small { color: var(--muted); }
.guest-title { font-size: 1.3rem; margin-bottom: 8px; }
.guest-foot { text-align: center; margin: 16px 0 0; font-size: 13px; }
.qr { width: 220px; height: 220px; margin: 16px auto; background: #fff; border-radius: 8px; }
.qr svg { width: 100%; height: 100%; display: block; }
.manual-secret { margin-bottom: 16px; }
.manual-secret summary { cursor: pointer; color: var(--link); font-size: 13px; }
.manual-secret .secret { display: block; margin-top: 8px; text-align: center; }

/* ------------------------------------------------ responsive */
.sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
  .menu-btn { display: grid; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .content { padding: 16px 12px; }
  .user-name, .search kbd { display: none; }
}
@media (max-width: 700px) {
  h1 { font-size: 1.3rem; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 8px 12px; border-bottom: 1px solid var(--border); }
  .table td { border: 0; padding: 3px 0; display: flex; gap: 10px; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); min-width: 110px; flex: none; font-size: 12.5px; }
  .row-actions { justify-content: flex-start; }
  .props { grid-template-columns: 1fr; gap: 2px; }
  .props dd { margin-bottom: 8px; }
  .filters select, .filters input { flex: 1 1 140px; }
}
