/* Login Audit — clean admin look, desktop-primary, yellow accent nod to the spreadsheet */
:root {
  --bg: #f5f5f3;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6b66;
  --line: #e3e3de;
  --accent: #facc15;
  --accent-ink: #3f3000;
  --danger: #b3261e;
  --focus: #2563eb;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; }

/* buttons */
.btn {
  font: inherit;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: background-color .15s ease-out, border-color .15s ease-out;
}
.btn:hover { background: #efefec; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #f0be0a; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: #efefec; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; padding: 2px 8px; }
.btn.danger:hover { background: #fbe9e7; }

input[type="text"], input[type="email"], input[type="password"], textarea {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
textarea { resize: vertical; }

/* ===== auth ===== */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 30px rgba(0,0,0,.06);
}
.auth-title { font-size: 22px; }
.auth-sub { color: var(--muted); margin: 4px 0 20px; }
.auth-note { color: var(--muted); margin: 0 0 14px; }
.auth-card form label { display: block; margin-bottom: 14px; font-weight: 500; }
.auth-card form label input { margin-top: 4px; font-weight: 400; }
.auth-card form .btn { width: 100%; margin-top: 4px; }
.auth-card form .btn.ghost { margin-top: 8px; }
.auth-error { color: var(--danger); margin: 14px 0 0; }
.dev-code {
  background: #fff8db;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 16px;
  letter-spacing: 2px;
  text-align: center;
}
.dev-code small { display: block; font-family: inherit; font-size: 11px; letter-spacing: 0; color: var(--muted); }

/* ===== app frame ===== */
.app-wrap { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
}
.brand { font-weight: 700; font-size: 16px; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--accent); border-radius: 3px; margin-right: 8px; }
.spacer { flex: 1; }
.who { color: var(--muted); }

.main { flex: 1; display: flex; min-height: 0; }

/* sidebar */
.sidebar {
  width: 260px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
}
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.side-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .client > .row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 8px; font-weight: 600;
}
.tree .client > .row:hover { background: #f0f0ed; }
.tree .dbs { list-style: none; margin: 2px 0 6px; padding: 0 0 0 14px; }
.tree .dbs .row { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.tree .dbs .row:hover { background: #f0f0ed; }
.tree .dbs .row.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tree .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .mini {
  font: inherit; font-size: 12px; line-height: 1;
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; padding: 3px 5px; border-radius: 6px;
}
.tree .mini:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.tree .add-db { margin: 0 0 8px 22px; }

/* content */
.content { flex: 1; padding: 24px; overflow-y: auto; }
.empty { color: var(--muted); padding: 40px; text-align: center; }

.db-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 10px; flex-wrap: wrap; }
.db-head h2 { font-size: 18px; }
.db-meta {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.db-meta .chk { display: flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.db-meta .chk input { width: 17px; height: 17px; accent-color: var(--accent-ink); cursor: pointer; }
.db-meta-field { display: flex; align-items: flex-start; gap: 8px; }
.db-meta-field label { color: var(--muted); white-space: nowrap; padding-top: 8px; }
.db-meta-field input { width: 240px; }
.db-meta-field textarea { width: 480px; min-height: 66px; }

/* grid */
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: center; }
.grid thead th {
  background: #e9e9e5;
  font-size: 12px; font-weight: 600; line-height: 1.3;
  border-left: 1px solid var(--line);
  vertical-align: bottom;
}
.grid thead th:first-child, .grid td:first-child { border-left: none; }
.grid th { border-left: 1px solid var(--line); }
.grid td { border-left: 1px solid var(--line); }
.grid td.col-user, .grid th.col-user { text-align: left; min-width: 180px; }
.grid td.col-notes, .grid th.col-notes { text-align: left; min-width: 220px; }
.grid th.col-del { width: 40px; }
.grid input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent-ink); }
.grid input.cell { border: none; background: transparent; padding: 2px 4px; width: 100%; }
.grid input.cell:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-radius: 4px; }
.grid tbody tr:hover { background: #fafaf7; }
.grid tbody tr.row-green { background: #e6f4e8; }
.grid tbody tr.row-green:hover { background: #dcefdf; }
.grid tbody tr.row-red { background: #fbe9e7; }
.grid tbody tr.row-red:hover { background: #f8e0dc; }
.grid tbody tr.flash { background: #fff8db; transition: background-color .4s ease-out; }

.add-row { display: flex; gap: 10px; margin-top: 14px; max-width: 420px; }

/* ===== modals ===== */
.modal-wrap {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(20,20,18,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 16px 50px rgba(0,0,0,.18);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  max-height: 85dvh;
  overflow-y: auto;
}
.modal-wide { max-width: 720px; }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-sub { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 10px; }
.modal form label { display: block; margin-bottom: 12px; font-weight: 500; }
.modal form label input { margin-top: 4px; font-weight: 400; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.user-list { list-style: none; margin: 0; padding: 0; }
.user-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
}
.user-list .u-email { flex: 1; font-weight: 500; }
.user-list .u-role { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.add-user { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.add-user input[type="email"] { flex: 2; min-width: 200px; }
.add-user input[type="text"] { flex: 1; min-width: 160px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.audit-table { margin-top: 4px; }
.audit-table td, .audit-table th { text-align: left; font-size: 13px; padding: 6px 8px; }

@media (max-width: 768px) {
  .main { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
  .content { padding: 16px; overflow-x: auto; }
}
