/* ============================================================
   BIBLIOTECA — Estilos globales
   Paleta: #1B1A1A (carbón), #00B147 (verde), #FAFAF7 (papel)
   Fuentes: CG Times (titulares) · Voga (subtítulos) · Helvetica/Calibri (cuerpo)
   ============================================================ */

:root {
  --ink:        #1B1A1A;
  --ink-soft:   #2A2928;
  --green:      #00B147;
  --green-deep: #028B39;
  --green-tint: #E6F6EC;
  --paper:      #FAFAF7;
  --surface:    #F2F1EC;
  --surface-2:  #E7E6E0;
  --line:       #D9D8D2;
  --line-soft:  #E9E8E2;
  --muted:      #8A8A86;
  --muted-2:    #B5B4AE;
  --warm:       #7A6E55;
  --warm-tint:  #F0EBDE;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;

  --shadow-1: 0 1px 0 rgba(27,26,26,0.04), 0 1px 2px rgba(27,26,26,0.04);
  --shadow-2: 0 2px 6px rgba(27,26,26,0.06), 0 8px 24px rgba(27,26,26,0.05);
  --shadow-pop: 0 10px 40px rgba(27,26,26,0.18);

  --font-display: "CG Times", "Tinos", "Times New Roman", "Source Serif Pro", serif;
  --font-sub:     "Voga", "Italiana", "Cormorant Garamond", "Times New Roman", serif;
  --font-body:    "Calibri", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
  --font-mono:    "JetBrains Mono", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.005em; margin: 0; }
.subtitle      { font-family: var(--font-sub); font-style: italic; font-weight: 400; letter-spacing: 0.005em; color: var(--ink-soft); }
.eyebrow       { font-family: var(--font-body); font-weight: 700; font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.mono          { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; color: var(--muted); }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===== App scaffold ===== */
.app-shell { display: grid; grid-template-columns: 280px 1fr; height: 100vh; background: var(--paper); }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--ink);
  color: #EFEEE8;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #000;
  overflow: hidden;
}
.sidebar-brand {
  padding: 22px 24px 18px;
  border-bottom: 1px solid #2A2928;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 38px; height: 38px;
  background: var(--green);
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.brand-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: 0.01em; line-height: 1; }
.brand-sub  { font-family: var(--font-sub); font-style: italic; font-size: 12px; color: #B5B4AE; margin-top: 2px; }

.sidebar-section { padding: 18px 16px 6px; }
.sidebar-section .eyebrow { color: #6E6D68; padding: 0 8px 8px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: #D9D8D2;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background .15s, color .15s;
}
.nav-item > span:not(.count):not(.dot) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: #2A2928; color: #FAFAF7; }
.nav-item.active { background: #2A2928; color: #FAFAF7; }
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 6px; bottom: 6px; width: 3px;
  background: var(--green);
}
.nav-item .count { margin-left: auto; font-size: 11px; color: #8A8A86; font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: var(--green); }

.subnav { padding: 4px 0 4px 28px; display: flex; flex-direction: column; gap: 2px; }
.subnav .sub {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  color: #B5B4AE;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.subnav .sub:hover { background: #232221; color: #EFEEE8; }
.subnav .sub.active { color: #FAFAF7; }
.subnav .sub .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.subnav .sub .count { margin-left: auto; font-size: 10.5px; color: #6E6D68; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid #2A2928;
  display: flex; align-items: center; gap: 12px;
  color: #D9D8D2;
}
.avatar {
  width: 34px; height: 34px;
  background: var(--green);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  border-radius: 50%;
}
.user-name { font-size: 13px; line-height: 1.1; font-weight: 600; color: #FAFAF7; }
.user-role { font-size: 11px; color: #8A8A86; }

/* ===== Main content ===== */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 18px;
  flex-shrink: 0;
}
.search {
  flex: 1;
  max-width: 560px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid transparent;
  padding: 9px 14px;
  border-radius: var(--radius);
  color: var(--ink);
  transition: background .15s, border-color .15s;
}
.search:focus-within { background: #fff; border-color: var(--ink); }
.search input {
  border: none; background: transparent; outline: none;
  font-size: 13.5px; color: var(--ink); flex: 1;
}
.search input::placeholder { color: var(--muted); }
.search .kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  background: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
}

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  position: relative;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn .dot-notif { position: absolute; top: 9px; right: 9px; width: 6px; height: 6px; background: var(--green); border-radius: 50%; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform .1s, background .15s;
}
.btn:hover { background: #000; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--surface); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: var(--green-deep); border-color: var(--green-deep); }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* ===== Content area ===== */
.content { flex: 1; overflow-y: auto; padding: 28px 36px 60px; }
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; border: 2px solid var(--paper); }
.content::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.crumbs .sep { color: var(--muted-2); }
.crumbs .now { color: var(--ink); font-weight: 600; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.page-head .h-title { font-size: 38px; line-height: 1; }
.page-head .h-sub { margin-top: 8px; font-size: 16px; max-width: 540px; }
.page-head .h-meta { display: flex; align-items: baseline; gap: 22px; color: var(--muted); font-size: 12px; }
.page-head .h-meta b { color: var(--ink); font-family: var(--font-display); font-size: 22px; font-weight: 700; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
}
.toolbar .chip:hover { border-color: var(--ink); }
.toolbar .chip.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.toolbar .chip.green.active { background: var(--green); border-color: var(--green); }
.toolbar .spacer { flex: 1; }
.toolbar .view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.toolbar .view-toggle button {
  width: 34px; height: 30px; display: grid; place-items: center;
  background: #fff; border: none; color: var(--muted);
}
.toolbar .view-toggle button.active { background: var(--ink); color: #fff; }
.toolbar .sort-select {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--ink-soft); cursor: pointer;
}

/* ===== Folder strip ===== */
.folder-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 28px; }
.folder-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  border-radius: var(--radius-sm);
}
.folder-card:hover { border-color: var(--ink); }
.folder-card.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.folder-card.active .f-count { color: var(--muted-2); }
.folder-card.active .f-bar { background: var(--green); }
.folder-card .f-bar { width: 3px; height: 38px; background: currentColor; opacity: .9; }
.folder-card .f-name { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; letter-spacing: 0; }
.folder-card .f-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== Section split ===== */
.section-label {
  display: flex; align-items: baseline; gap: 14px; margin: 6px 0 14px;
}
.section-label .lbl { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.section-label .ln { flex: 1; height: 1px; background: var(--line); }
.section-label .meta { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== Cards grid ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 18px; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  position: relative;
  overflow: hidden;
}
.card:hover { border-color: var(--ink); box-shadow: var(--shadow-2); }
.card .thumb { aspect-ratio: 4 / 3; position: relative; overflow: hidden; background: var(--surface); }
.card .thumb .badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(27,26,26,0.85);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 2px;
}
.card .thumb .actions {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity .15s;
}
.card:hover .thumb .actions { opacity: 1; }
.card .thumb .actions button {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: rgba(255,255,255,.95);
  border: none;
  border-radius: 3px;
  color: var(--ink);
}
.card .thumb .actions button:hover { background: var(--green); color: #fff; }

.card .meta { padding: 12px 14px 14px; }
.card .meta h4 {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.4em;
}
.card .meta .line {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.card .meta .line .v { color: var(--ink-soft); }
.card .meta .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }

/* Thumb backgrounds (no external assets, just composed shapes) */
.thumb-duo    { display: flex; }
.thumb-duo    > div { flex: 1; }
.thumb-stripe { background-image: repeating-linear-gradient(135deg, var(--a) 0 12px, var(--b) 12px 14px); }
.thumb-grid   { background:
  linear-gradient(var(--a),var(--a)), linear-gradient(var(--a),var(--a)),
  linear-gradient(var(--b),var(--b));
  background-size: 50% 50%, 50% 50%, 100% 100%;
  background-position: 0 0, 100% 100%, 0 0;
  background-repeat: no-repeat;
}
.thumb-doc {
  background: var(--b);
  display: grid; place-items: center;
}
.thumb-doc .sheet {
  width: 56%; height: 72%;
  background: #fff;
  border: 1px solid rgba(27,26,26,.1);
  position: relative;
  box-shadow: 0 4px 12px rgba(27,26,26,.12);
}
.thumb-doc .sheet::before, .thumb-doc .sheet::after {
  content: ""; position: absolute; left: 12%; right: 12%; height: 4px; background: var(--surface);
}
.thumb-doc .sheet::before { top: 22%; }
.thumb-doc .sheet::after  { top: 40%; }
.thumb-doc .sheet .more {
  position: absolute; left: 12%; right: 32%; top: 58%; height: 4px; background: var(--surface);
  box-shadow: 0 12px 0 var(--surface), 0 24px 0 var(--surface);
}
.thumb-doc .stamp {
  position: absolute; right: 10px; bottom: 10px;
  background: var(--a); color: #fff;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .14em;
  padding: 3px 7px; border-radius: 2px;
  text-transform: uppercase;
}

/* ===== List view ===== */
.list {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.list .row {
  display: grid;
  grid-template-columns: 36px 1.6fr 0.9fr 0.6fr 0.7fr 0.6fr 80px;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  cursor: pointer;
}
.list .row:last-child { border-bottom: none; }
.list .row:hover { background: var(--surface); }
.list .row.head { background: var(--surface); color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; padding: 10px 16px; cursor: default; }
.list .row.head:hover { background: var(--surface); }
.list .row .ico { width: 36px; height: 36px; display: grid; place-items: center; background: var(--surface); color: var(--ink-soft); border-radius: var(--radius-sm); }
.list .row .nm { font-family: var(--font-display); font-size: 13.5px; font-weight: 700; color: var(--ink); }
.list .row .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.list .row .pill { display: inline-block; padding: 2px 8px; background: var(--surface); color: var(--ink-soft); border-radius: 999px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; }
.list .row .dl { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.list .row .dl:hover { background: var(--green); color: #fff; border-color: var(--green); }
.list .row .tabular { font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* ===== Detail panel ===== */
.detail-backdrop {
  position: fixed; inset: 0; background: rgba(27,26,26,0.35);
  z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.detail-backdrop.open { opacity: 1; pointer-events: all; }
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px;
  background: var(--paper);
  border-left: 1px solid var(--line);
  z-index: 51;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
}
.detail.open { transform: translateX(0); }
.detail .d-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.detail .d-head .eyebrow { margin: 0; }
.detail .d-body { padding: 22px; overflow-y: auto; flex: 1; }
.detail .d-preview {
  aspect-ratio: 4/3; background: var(--surface);
  margin-bottom: 22px; position: relative;
  border: 1px solid var(--line);
}
.detail h2 { font-size: 28px; line-height: 1.1; margin-bottom: 6px; }
.detail .d-sub { margin-bottom: 18px; font-size: 15px; }
.detail .desc { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 22px; max-width: 50ch; }
.detail .table { display: grid; grid-template-columns: 110px 1fr; row-gap: 10px; column-gap: 14px; font-size: 12.5px; margin-bottom: 24px; }
.detail .table .k { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 10.5px; font-weight: 700; padding-top: 2px; }
.detail .table .v { color: var(--ink); }
.detail .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.detail .tags .t { padding: 4px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; color: var(--ink-soft); }
.detail .d-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; background: #fff; }
.detail .d-foot .btn { flex: 1; justify-content: center; }

/* ===== Login ===== */
.login-shell {
  position: fixed; inset: 0;
  display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--paper);
}
.login-brand {
  background: var(--ink);
  color: #EFEEE8;
  padding: 48px 56px;
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
}
.login-brand::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: var(--green);
}
.login-brand .lb-top { display: flex; align-items: center; gap: 14px; }
.login-brand .lb-mark { width: 44px; height: 44px; background: var(--green); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.login-brand .lb-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.login-brand .lb-tag  { font-family: var(--font-sub); font-style: italic; color: #B5B4AE; font-size: 13px; }

.login-brand .lb-center { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 520px; }
.login-brand .lb-eyebrow { color: var(--green); font-family: var(--font-body); font-weight: 700; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 18px; display: flex; align-items: center; gap: 12px; }
.login-brand .lb-eyebrow::before { content: ""; display: inline-block; width: 28px; height: 1px; background: var(--green); }
.login-brand h1.headline {
  font-family: var(--font-display);
  font-size: 72px;
  line-height: 0.96;
  letter-spacing: -0.015em;
  font-weight: 700;
  color: #FAFAF7;
  margin-bottom: 20px;
}
.login-brand h1.headline em { font-family: var(--font-sub); font-style: italic; color: var(--green); font-weight: 400; }
.login-brand .lb-deck { font-family: var(--font-sub); font-style: italic; font-size: 22px; color: #D9D8D2; max-width: 30ch; line-height: 1.4; }
.login-brand .lb-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 24px; margin-top: 48px; max-width: 480px; }
.login-brand .lb-stat { border-top: 1px solid #3A3937; padding-top: 14px; }
.login-brand .lb-stat .n { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: #FAFAF7; }
.login-brand .lb-stat .l { font-size: 11px; color: #8A8A86; text-transform: uppercase; letter-spacing: 0.14em; margin-top: 2px; }

.login-brand .lb-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #6E6D68; letter-spacing: 0.1em; text-transform: uppercase; }

.login-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  position: relative;
}
.login-form-wrap::before {
  content: ""; position: absolute; top: 40px; right: 40px;
  width: 8px; height: 8px; background: var(--green);
}
.login-form { width: 100%; max-width: 380px; }
.login-form .eyebrow { margin-bottom: 14px; }
.login-form h2 { font-size: 38px; line-height: 1.05; margin-bottom: 6px; }
.login-form .lf-sub { font-size: 16px; margin-bottom: 30px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; color: var(--muted); }
.field .input {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field .input:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--surface); }
.field .input input {
  border: none; outline: none; background: transparent;
  flex: 1; font-size: 14px; color: var(--ink);
}
.field .input input::placeholder { color: var(--muted-2); }
.field .input button.peek { background: transparent; border: none; color: var(--muted); padding: 0; display: grid; place-items: center; }

.checkrow { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; font-size: 12.5px; }
.checkrow label { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); cursor: pointer; }
.checkrow input[type="checkbox"] { appearance: none; width: 16px; height: 16px; border: 1.5px solid var(--line); border-radius: 3px; display: grid; place-items: center; cursor: pointer; }
.checkrow input[type="checkbox"]:checked { background: var(--ink); border-color: var(--ink); }
.checkrow input[type="checkbox"]:checked::after { content: ""; width: 8px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translateY(-1px); }
.checkrow a { color: var(--green-deep); text-decoration: none; font-weight: 600; }
.checkrow a:hover { text-decoration: underline; }

.login-form .btn-primary {
  width: 100%; justify-content: center;
  padding: 14px;
  background: var(--ink);
  color: #fff; border: 1px solid var(--ink);
  font-weight: 600; font-size: 13.5px;
  letter-spacing: 0.04em; text-transform: uppercase;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px;
  transition: background .15s;
}
.login-form .btn-primary:hover { background: var(--green); border-color: var(--green); }
.login-form .btn-primary .arr { transition: transform .2s; }
.login-form .btn-primary:hover .arr { transform: translateX(3px); }

.login-form .or-row { display: flex; align-items: center; gap: 10px; margin: 22px 0 16px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em; }
.login-form .or-row::before, .login-form .or-row::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.login-form .sso { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; color: var(--ink); font-weight: 600; width: 100%; }
.login-form .sso:hover { border-color: var(--ink); }

.login-form .footnote { margin-top: 28px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* ===== Tweaks panel custom tweaks ===== */
.tweaks-tip { color: var(--muted); font-size: 11.5px; line-height: 1.45; }

/* ===== Misc ===== */
.empty { padding: 60px; text-align: center; color: var(--muted); }
.divider-vert { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* Focus rings */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ================================================================
   ADMIN PANEL
   ================================================================ */

.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.adm-tab {
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  position: relative;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.adm-tab:hover { color: var(--ink); }
.adm-tab.active { color: var(--ink); }
.adm-tab.active::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px; height: 2px; background: var(--ink);
}
.adm-tab .badge-num {
  background: var(--surface); color: var(--ink-soft);
  font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.adm-tab.active .badge-num { background: var(--ink); color: #fff; }

/* Legend */
.legend {
  display: grid;
  grid-template-columns: auto repeat(4, minmax(0, 1fr));
  gap: 18px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  align-items: start;
}
.legend-title {
  font-family: var(--font-body); font-weight: 700; font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
  padding-top: 2px;
}
.legend-item { display: flex; gap: 10px; align-items: flex-start; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.legend-lbl { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ink); margin-bottom: 2px; }
.legend-desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* Permission pill */
.perm-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
  border-radius: 999px;
  white-space: nowrap;
}
.perm-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--green)); }
.perm-pill:hover { border-color: var(--ink); }
.perm-pill:active { transform: translateY(1px); }
.perm-pill.high { background: var(--c); border-color: var(--c); color: #fff; }
.perm-pill.high .dot { background: rgba(255,255,255,0.85); }
.perm-pill.none { background: var(--surface); color: var(--muted); border-color: var(--line); }
.perm-pill.none .dot { background: var(--muted-2); }
.perm-pill.mini { padding: 4px 10px; font-size: 11px; }
.perm-pill .inh { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; margin-left: 4px; }
.perm-pill.inherited { background: transparent; border-style: dashed; }
.perm-pill.inherited.high { background: transparent; color: var(--c); border-color: var(--c); }
.perm-pill.inherited.high .dot { background: var(--c); }

/* Permission matrix */
.perm-matrix {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pm-head, .pm-row {
  display: grid;
  grid-template-columns: 2.2fr repeat(3, 1fr) 130px;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
}
.pm-head {
  background: var(--surface);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
}
.pm-cell { padding: 14px 18px; }
.pm-corner { font-family: var(--font-body); font-weight: 700; }
.pm-col-head { display: flex; flex-direction: column; gap: 2px; }
.pm-col-count { font-size: 10px; color: var(--muted-2); text-transform: none; letter-spacing: 0.04em; }

.pm-row { transition: background .15s; }
.pm-row:hover { background: var(--paper); }
.pm-row.expanded { background: var(--paper); border-bottom-color: var(--ink); }
.pm-row:last-of-type { border-bottom: none; }

.pm-role { display: flex; gap: 14px; align-items: flex-start; }
.role-bar { width: 3px; min-width: 3px; height: 42px; background: var(--green); border-radius: 1px; }
.role-name { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; line-height: 1.25; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role-name .sys {
  font-family: var(--font-body); font-weight: 700; font-size: 9px;
  letter-spacing: 0.18em; padding: 2px 6px; background: var(--ink); color: #fff;
  border-radius: 2px;
}
.role-desc { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; line-height: 1.45; max-width: 40ch; }
.role-meta { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; margin-top: 8px; font-weight: 700; }

/* Detail */
.pm-detail {
  background: var(--paper);
  border-bottom: 1px solid var(--line-soft);
  padding: 4px 18px 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.pm-detail-block {
  background: #fff;
  border: 1px solid var(--line);
  padding: 14px 14px 12px;
}
.pm-detail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.pm-folders { display: flex; flex-direction: column; gap: 6px; }
.pm-folder {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.pm-folder-bar { width: 2px; height: 24px; background: var(--green); }
.pm-folder-name { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.pm-folder-meta { font-size: 10.5px; color: var(--muted); }

/* Popover */
.pop-backdrop { position: fixed; inset: 0; z-index: 90; }
.pop {
  position: fixed; z-index: 91;
  width: 320px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pop-title {
  padding: 12px 14px;
  font-family: var(--font-body);
  font-weight: 700; font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.pop-item {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.pop-item:last-child { border-bottom: none; }
.pop-item:hover { background: var(--paper); }
.pop-item.active { background: var(--paper); }
.pop-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.pop-lbl { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ink); }
.pop-desc { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }

/* Status pills */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.status-pill.active { background: var(--green-tint); color: var(--green-deep); }
.status-pill.pending { background: var(--warm-tint); color: var(--warm); }

/* Audit log */
.audit { display: flex; flex-direction: column; }
.audit-row {
  display: grid;
  grid-template-columns: 140px 12px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  align-items: flex-start;
}
.audit-row:last-child { border-bottom: none; }
.audit-time { padding-top: 2px; }
.audit-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  margin-top: 6px; margin-left: 2px;
  box-shadow: 0 0 0 3px var(--green-tint);
}
.audit-line { font-size: 13px; color: var(--ink); }
.audit-line b { font-family: var(--font-display); font-weight: 700; }
.audit-tgt { color: var(--ink-soft); }
.audit-change {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.audit-from { text-decoration: line-through; }
.audit-to { color: var(--green-deep); font-weight: 600; }
