/* =============================================================
   LDAP Manager — refined utilitarian aesthetic
   - IBM Plex Sans for UI, IBM Plex Mono for technical data
   - Dark sidebar (deep ink navy), warm off-white content
   - Hairline borders, dense layout, single warm-amber accent
   ============================================================= */

:root {
  --bg:           #fafaf7;
  --bg-card:      #ffffff;
  --bg-sidebar:   #161628;
  --bg-sidebar-2: #1f1f35;
  --text:         #0f0f1a;
  --text-muted:   #6b6b78;
  --text-faint:   #94949f;
  --text-onDark:  #e8e8f0;
  --text-onDark-muted: #8888a0;
  --border:       #e6e6dd;
  --border-strong:#d4d4c8;
  --accent:       #b65809;        /* burnt amber */
  --accent-soft:  #fdebd3;
  --accent-text:  #5e2d04;
  --danger:       #a51b1b;
  --danger-soft:  #fde4e4;
  --ok:           #1b6c3b;
  --ok-soft:      #d8efe2;
  --warn:         #8a5b00;
  --warn-soft:    #fbeec2;
  --shadow-sm:    0 1px 0 rgba(15,15,26,.04);
  --shadow:       0 1px 2px rgba(15,15,26,.04), 0 0 0 1px var(--border);
  --radius:       4px;
  --radius-lg:    6px;
  --sidebar-w:    260px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 12.5px;
  font-weight: 400;
}
code.dn {
  background: #f3f3eb;
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--text);
  word-break: break-all;
}
.small { font-size: 12px; }
.muted { color: var(--text-muted); }
.muted.warn { color: var(--warn); }

/* ---------- Shell ------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------------------------------------------- */

.sidebar {
  background: var(--bg-sidebar);
  color: var(--text-onDark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 22px;
  border-bottom: 1px solid var(--bg-sidebar-2);
}
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
}
.brand-mark.big { width: 40px; height: 40px; font-size: 18px; }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: .01em; }
.brand-sub  { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-onDark-muted); }

nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-onDark-muted);
  padding: 4px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  color: var(--text-onDark);
  border-radius: var(--radius);
  font-size: 13.5px;
  margin: 1px 0;
  transition: background 80ms;
}
.nav-item:hover { background: var(--bg-sidebar-2); text-decoration: none; }
.nav-item.is-active {
  background: var(--bg-sidebar-2);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-icon {
  display: inline-block; width: 16px; text-align: center;
  color: var(--text-onDark-muted); font-size: 13px;
}
.nav-item.is-active .nav-icon { color: var(--accent); }

.user-card {
  border-top: 1px solid var(--bg-sidebar-2);
  padding: 14px 20px 18px;
  background: rgba(0,0,0,.2);
}
.user-name { font-weight: 500; font-size: 13px; }
.user-dn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--text-onDark-muted);
  margin: 2px 0 8px;
  word-break: break-all;
}
.user-roles { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.badge-role { background: rgba(255,255,255,.08); color: var(--text-onDark); border-color: rgba(255,255,255,.12); }
.logout {
  display: inline-block;
  font-size: 12px;
  color: var(--text-onDark-muted);
}
.logout:hover { color: #fff; }

/* ---------- Main ------------------------------------------------- */

.main {
  padding: 28px 36px 60px;
  max-width: 1400px;
  position: relative;
  min-height: 100vh;
}
.app-footer {
  margin-top: 60px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-faint);
}
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* ---------- Toolbar / actions ----------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar > * { flex-shrink: 0; }
.toolbar > .filter-form { flex: 1; }
.dn-readout { color: var(--text-muted); font-size: 12px; margin-left: auto; }

.link-back { color: var(--text-muted); font-size: 13px; }
.link-back:hover { color: var(--text); text-decoration: none; }

/* ---------- Cards ------------------------------------------------ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card.narrow { max-width: 560px; }
.card.card-danger { border-color: #f0c0c0; }
.card h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}
.card h2 + p, .card h2 + .muted { margin-top: 0; margin-bottom: 18px; }
.card h3 { margin: 24px 0 8px; font-size: 13.5px; font-weight: 600; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Forms ------------------------------------------------ */

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  font-size: 13px;
}
label > span {
  font-weight: 500;
  color: var(--text);
}
label > small { color: var(--text-muted); font-size: 11.5px; }

input[type="text"],
input[type="email"],
input[type="password"],
input:not([type]),
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color 80ms, box-shadow 80ms;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(182, 88, 9, .15);
}
input:disabled {
  background: #f6f6f0;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid > .span-2 { grid-column: span 2; }
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.form-actions:first-child { padding-top: 0; border-top: 0; }
.filter-form { display: inline-flex; gap: 12px; align-items: end; }
.filter-form select { width: auto; min-width: 200px; }
.filter-label { margin: 0; }

/* ---------- Buttons --------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 80ms, border-color 80ms;
}
.btn:hover { background: #f6f6f0; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #99490a; border-color: #99490a; }
.btn-danger {
  background: #fff;
  border-color: #d4a4a4;
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-tiny { padding: 4px 9px; font-size: 12px; }

.link-danger {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--danger);
  font: inherit;
  font-size: 12.5px;
}
.link-danger:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

/* ---------- Tables --------------------------------------------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table.compact th, .data-table.compact td { padding: 7px 12px; }
.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  background: #fbfbf6;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fbfbf3; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions a + form, .row-actions form + form { margin-left: 10px; }
.empty-row { text-align: center; color: var(--text-muted); padding: 24px; font-style: italic; }

/* ---------- Badges --------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: #f6f6f0;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0;
}
.badge-accent { background: var(--accent-soft); border-color: #ecc89a; color: var(--accent-text); }
.badge-warn   { background: var(--warn-soft);  border-color: #e0c277; color: var(--warn); }

/* ---------- Flash --------------------------------------------- */

.flash-stack { margin-bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  font-size: 13px;
}
.flash-ok   { background: var(--ok-soft);     border-color: #b1d3bf; color: var(--ok); }
.flash-err  { background: var(--danger-soft); border-color: #e0bfbf; color: var(--danger); }
.flash-info { background: var(--accent-soft); border-color: #ecc89a; color: var(--accent-text); }

/* ---------- DNS records --------------------------------------- */

.record-line {
  display: flex; gap: 8px; align-items: baseline;
  margin: 1px 0;
}
.rec-type {
  display: inline-block;
  width: 50px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .04em;
}

.record-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 12px;
  margin: 0 0 12px 0;
}
.record-fieldset legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.record-fieldset legend small { font-weight: 400; margin-left: 6px; }
.multi { display: flex; flex-direction: column; gap: 6px; }
.multi-row { display: flex; gap: 6px; align-items: center; }
.multi-row input { flex: 1; }

/* ---------- Empty states -------------------------------------- */

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty h2, .empty h3 { color: var(--text); margin: 0 0 8px; }

/* ---------- Login --------------------------------------------- */

.login-body {
  background: var(--bg);
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}
.login-wrap {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 18px;
}
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(15,15,26,.06), 0 0 0 1px var(--border);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-form label { margin-bottom: 16px; }
.login-footnote {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Photos / Avatars ----------------------------------- */

.avatar-sm {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  display: inline-block;
  vertical-align: middle;
}
.avatar-lg {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  display: block;
}
.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 18px;
}

.photo-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.photo-current {
  flex: 0 0 auto;
}
.photo-forms {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.photo-forms .inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-tiny {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-link-danger {
  background: transparent;
  border: none;
  color: var(--danger);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
  font-size: 13px;
}

.link-action {
  background: transparent;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  font-family: inherit;
}

.hidden { display: none !important; }

/* ---------- Mobile --------------------------------------------- */

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .photo-row { flex-direction: column; }
}
