/* Nexus Sync – Weboberfläche (Farben wie im Desktop-Client Nexus SSH) */
:root {
  --bg: #11131f;
  --sidebar: #0b0d17;
  --card: #1a1d2e;
  --hover: #22263a;
  --border: #2a2e44;
  --text: #e8eaf2;
  --dim: #8a90a8;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --success: #3ecf8e;
  --danger: #ff5c69;
  --warning: #f5b041;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.noscript { padding: 24px; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: 12px; }

/* ------------------------------------------------------------ Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; }
.brand .diamond { color: var(--accent); font-size: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--dim);
  font-weight: 500; transition: background 0.12s, color 0.12s;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--hover); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .icon { width: 18px; text-align: center; opacity: 0.9; }
.sidebar-footer { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); }
.userchip { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 700; color: #fff; flex: 0 0 32px;
}
.userchip .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--dim); }

.topbar { display: none; }

/* ------------------------------------------------------------ Karten */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--dim); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 22px; font-weight: 650; margin-top: 6px; word-break: break-word; }
.stat .sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }

/* ------------------------------------------------------------ Formulare */
label { display: block; font-size: 13px; color: var(--dim); margin: 0 0 6px; font-weight: 500; }
.field { margin-bottom: 14px; }
input[type=text], input[type=password], input[type=search] {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: inherit; outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18); }
input.code-input { font-family: var(--mono); font-size: 20px; letter-spacing: 0.3em; text-align: center; }
.checkbox { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px;
  cursor: pointer; transition: background 0.12s, border-color 0.12s, opacity 0.12s; white-space: nowrap;
}
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { width: 100%; padding: 11px 16px; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: transparent; border-color: rgba(255, 92, 105, 0.45); color: var(--danger); }
.btn.danger:hover { background: rgba(255, 92, 105, 0.12); }
.btn.danger-solid { background: var(--danger); }
.btn.danger-solid:hover { background: #ff7580; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

select.role-select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 28px 5px 10px; font: inherit; font-size: 13px; cursor: pointer; outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
select.role-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18); }

/* Kennzahlen innerhalb einer Karte */
/* Benutzerliste: viele Aktionen dürfen umbrechen statt die Tabelle zu verbreitern */
table.users td.actions { white-space: normal; min-width: 220px; }
table.users td.actions .btn { margin: 2px 0 2px 4px; }
table.members { table-layout: fixed; }
table.members .col-role { width: 200px; }
table.members .col-actions { width: 150px; }
.kv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.kv { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.kv .label { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.kv .value { font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ Tabellen */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
th { color: var(--dim); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; border-top: 0; }
tbody tr:hover { background: var(--hover); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 4px; }
.nowrap { white-space: nowrap; }
.empty { color: var(--dim); text-align: center; padding: 26px 10px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--border); color: var(--dim); margin-right: 4px; white-space: nowrap;
}
.badge.ok { color: var(--success); border-color: rgba(62, 207, 142, 0.4); background: rgba(62, 207, 142, 0.08); }
.badge.warn { color: var(--warning); border-color: rgba(245, 176, 65, 0.4); background: rgba(245, 176, 65, 0.08); }
.badge.bad { color: var(--danger); border-color: rgba(255, 92, 105, 0.4); background: rgba(255, 92, 105, 0.08); }
.badge.accent { color: var(--accent); border-color: rgba(91, 140, 255, 0.45); background: rgba(91, 140, 255, 0.1); }

/* ------------------------------------------------------------ Hinweise */
.alert { border-radius: 8px; padding: 11px 14px; margin-bottom: 14px; border: 1px solid; font-size: 13px; }
.alert.error { color: #ffc2c7; border-color: rgba(255, 92, 105, 0.45); background: rgba(255, 92, 105, 0.1); }
.alert.info { color: #cfdcff; border-color: rgba(91, 140, 255, 0.4); background: rgba(91, 140, 255, 0.08); }
.alert.warn { color: #ffe0a8; border-color: rgba(245, 176, 65, 0.45); background: rgba(245, 176, 65, 0.08); }
.alert.success { color: #bdf3d9; border-color: rgba(62, 207, 142, 0.45); background: rgba(62, 207, 142, 0.08); }

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--success); border-radius: 8px;
  padding: 11px 14px; min-width: 240px; max-width: 360px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.toast.error { border-left-color: var(--danger); }

/* ------------------------------------------------------------ Anmeldung */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box.wide { max-width: 580px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .logo { font-size: 26px; font-weight: 700; }
.auth-brand .logo .diamond { color: var(--accent); }
.auth-brand p { color: var(--dim); margin: 6px 0 0; }
.auth-box .card { padding: 26px; }
.auth-foot { text-align: center; color: var(--dim); margin-top: 16px; font-size: 13px; }

/* ------------------------------------------------------------ 2FA */
.qr-box { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.qr { background: #fff; border-radius: 10px; padding: 10px; width: 196px; height: 196px; flex: 0 0 196px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { font-family: var(--mono); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; font-family: var(--mono); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.steps { margin: 0 0 14px; padding-left: 20px; color: var(--dim); }
.steps li { margin-bottom: 4px; }

/* ------------------------------------------------------------ Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 6, 12, 0.7); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.modal h2 { margin-bottom: 10px; }
.modal p { color: var(--dim); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 10px; flex-wrap: wrap; }
.details { color: var(--dim); font-family: var(--mono); font-size: 12px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting .text { max-width: 560px; }
.setting .text p { margin: 2px 0 0; color: var(--dim); font-size: 13px; }

.switch { position: relative; width: 44px; height: 24px; flex: 0 0 44px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: background 0.15s; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.35); }

/* ------------------------------------------------------------ Mobil */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--sidebar);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  }
  .topbar .brand { padding: 0; }
  .menu-btn { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer; }
  .sidebar { display: none; position: fixed; top: 57px; left: 0; right: 0; bottom: 0; width: auto; height: auto; z-index: 30; border-right: 0; }
  .sidebar .brand { display: none; }
  .layout.menu-open .sidebar { display: flex; }
  .main { padding: 20px 16px 40px; }
  .stats { gap: 10px; }
  .stat .value { font-size: 18px; }
  th, td { padding: 10px 14px; }
  .table-wrap { margin: 0 -20px -20px; }
  .hide-mobile { display: none; }
  td.actions { white-space: normal; }
  td.actions .btn { margin: 2px 0 2px 4px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px -16px; }
  .setting { flex-direction: row; }
  /* Tabellen mit vielen Aktionen als Karten darstellen */
  table.stack thead { display: none; }
  table.members { table-layout: auto; }
  table.stack tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
  table.stack tbody tr:first-child { border-top: 0; }
  table.stack td { border: 0; padding: 0; }
  table.stack td.actions { grid-column: 1 / -1; text-align: left; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
  table.stack td.actions .btn { margin: 0; }
}
