:root {
  --sidebar: #0a0a0a;
  --sidebar-text: #f5f5f0;
  --sidebar-muted: rgba(245, 245, 240, 0.55);
  --accent: #ffd700;
  --accent-ink: #0a0a0a;
  --accent-soft: rgba(255, 215, 0, 0.16);
  --page: #eef0f3;
  --card: #ffffff;
  --ink: #142033;
  --muted: #6b7280;
  --line: #e2e6ee;
  --line-strong: #c9d0db;
  --danger: #c0392b;
  --ok: #1f7a4d;
  --shadow: 0 10px 30px rgba(20, 32, 51, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font: Arial, Helvetica, sans-serif;
  --display: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { padding: 0.25rem 0.55rem 0.1rem; }
.sidebar-brand strong {
  display: block;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.sidebar-brand span {
  display: block;
  margin-top: 0.2rem;
  color: var(--sidebar-muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.52rem 0.75rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.86);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-left {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.nav-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  fill: var(--accent);
}
.nav-link.active .nav-icon {
  fill: var(--accent-ink);
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-link.active {
  background: var(--accent);
  color: var(--accent-ink);
}
.nav-badge {
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.18);
}
.nav-link:not(.active) .nav-badge {
  background: var(--accent);
  color: var(--accent-ink);
}
.sidebar-user {
  margin-top: auto;
  padding: 0.85rem 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-user strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
}
.sidebar-user span {
  display: block;
  margin-top: 0.15rem;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  word-break: break-all;
}
.sidebar-user form { margin-top: 0.75rem; }

.workspace {
  min-width: 0;
  padding: 1rem 1.15rem 1.75rem;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.page-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.page-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--card);
  border: 1px solid rgba(226, 230, 238, 0.95);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  min-height: 86px;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.stat-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 215, 0, 0.55);
  box-shadow: 0 12px 28px rgba(20, 32, 51, 0.1);
}
.stat-card-alert {
  border-color: rgba(255, 215, 0, 0.65);
  background: linear-gradient(180deg, #fffdf3 0%, #ffffff 70%);
}
.stat-icon {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.stat-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: var(--accent-ink);
}
.stat-body {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stat-sub {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

@media (max-width: 920px) {
  .stats-grid { grid-template-columns: 1fr; }
}

.flash-wrap { display: grid; gap: 0.55rem; margin-bottom: 1rem; }
.flash {
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  background: #fff;
  box-shadow: var(--shadow);
}
.flash-ok { border-color: rgba(31, 122, 77, 0.25); color: var(--ok); }
.flash-error { border-color: rgba(192, 57, 43, 0.25); color: var(--danger); }

.card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 230, 238, 0.9);
  padding: 0.85rem 0.95rem;
}
.card + .card { margin-top: 0.75rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.toolbar-left, .toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.search-input {
  min-width: min(100%, 220px);
  width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.42rem 0.65rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
}
.search-input:focus {
  outline: 2px solid rgba(255, 215, 0, 0.55);
  border-color: var(--accent);
}
.link-filter {
  border: 0;
  background: none;
  color: var(--danger);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.2rem 0.15rem;
}
.link-filter:hover { text-decoration: underline; }
.link-filter.is-open { color: #8a2e24; }
.page-size {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.page-size select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.3rem 0.4rem;
  background: #fff;
  font-size: 0.82rem;
}

.filter-panel {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem 0.65rem;
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}
.filter-panel.is-open { display: grid; }
.filter-panel[hidden] { display: none !important; }
.filter-panel .field { margin: 0; }
.filter-panel label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.filter-panel input,
.filter-panel select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.38rem 0.5rem;
  background: #fff;
  font-size: 0.84rem;
}
.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  grid-column: 1 / -1;
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.55rem;
  min-height: 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  background: var(--accent-soft);
  color: #7a6200;
  font-size: 0.74rem;
  font-weight: 700;
}
.filter-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}

.table-wrap { overflow-x: auto; margin: 0 -0.1rem; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 720px;
  font-size: 0.78rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table th {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  user-select: none;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--ink); }
.data-table th .sort-ind {
  display: inline-block;
  margin-left: 0.2rem;
  opacity: 0.35;
  font-size: 0.65rem;
}
.data-table th.sort-asc .sort-ind,
.data-table th.sort-desc .sort-ind { opacity: 1; color: #b8860b; }
.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr:hover { background: #fafbfd; }

.data-table .col-journal { width: 72px; }
.data-table .col-title { width: 28%; }
.data-table .col-authors { width: 18%; }
.data-table .col-issue { width: 12%; }
.data-table .col-date { width: 88px; }
.data-table .col-cert { width: 110px; }
.data-table .col-actions { width: 72px; text-align: right; }

.data-table .title-cell {
  font-weight: 700;
  color: var(--ink);
}
.data-table .authors-cell {
  color: var(--muted);
  font-weight: 500;
}
.data-table .issue-cell,
.data-table .date-cell,
.data-table .cert-cell {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table .cert-cell {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}
.data-table .clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.3;
  word-break: break-word;
}
.data-table .meta {
  color: var(--muted);
  font-weight: 500;
}
.data-table .col-actions {
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
}
.action-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}
.action-edit {
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.05rem 0.15rem;
}
.action-edit:hover { text-decoration: underline; }

.sticky-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--card);
  margin: -0.85rem -0.95rem 0.55rem;
  padding: 0.85rem 0.95rem 0.55rem;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 16px rgba(20, 32, 51, 0.04);
}
.table-card { overflow: visible; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: #f3f4f6;
  color: var(--ink);
}
.pill-gold { background: var(--accent-soft); color: #7a6200; }
.pill-pending { background: #fff4d6; color: #8a6500; }
.pill-issued { background: #e8f7ee; color: #1f7a4d; }

.table-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.pager { display: inline-flex; gap: 0.3rem; }
.pager button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.8rem;
}
.pager button:disabled { opacity: 0.45; cursor: not-allowed; }
.pager button:not(:disabled):hover { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.48rem 0.9rem;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: #e6c200;
}
.btn-primary:hover { filter: brightness(0.97); }
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { border-color: #9aa3b2; }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: rgba(192, 57, 43, 0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, 0.18);
  width: 100%;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn-sm { padding: 0.28rem 0.7rem; font-size: 0.78rem; }

.form-grid { display: grid; gap: 1rem; }
.field label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
.field .hint {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  background: #fff;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(255, 215, 0, 0.55);
  border-color: var(--accent);
}
.check-list {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
}
.check-list label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-weight: 600;
  margin: 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.15rem;
}
.split-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}
.meta-box {
  display: grid;
  gap: 0.55rem;
  font-size: 0.92rem;
}
.meta-box div {
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}
.meta-box strong { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.file-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.empty {
  padding: 1.1rem 0.75rem;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}
.alert-list {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: #fff7e8;
  border: 1px solid #f0d9a0;
  color: #7a5a00;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Login (no sidebar) */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 420px at 15% 0%, rgba(255, 215, 0, 0.18), transparent 55%),
    linear-gradient(180deg, #111 0%, #0a0a0a 55%, #050505 100%);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 1.6rem 1.5rem 1.4rem;
}
.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.55rem;
  font-weight: 800;
}
.login-card .lede {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.login-brand {
  display: inline-block;
  margin-bottom: 0.9rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .split-2 { grid-template-columns: 1fr; }
  .workspace { padding: 1.1rem 1rem 2rem; }
  .search-input { width: 100%; }
}
