:root {
  --bg: #0b1020;
  --bg-soft: #121a30;
  --panel: #161f3a;
  --panel-2: #1c2747;
  --border: #26324f;
  --text: #e8edf7;
  --muted: #93a0bd;
  --accent: #6c8cff;
  --accent-2: #8b5cf6;
  --active: #22c55e;
  --development: #f59e0b;
  --suspended: #ef4444;
  --inactive: #64748b;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 700px at 15% -10%, #1b2750 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }

/* ============ LOGIN ============ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 32px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop 0.35s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 24px; margin-top: 8px; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 14px; margin-top: 8px; }
.login-field {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}
.login-field input {
  flex: 1;
  background: #0d1428;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--accent); }
.login-field button {
  border: none;
  border-radius: 12px;
  padding: 0 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s, filter 0.15s;
}
.login-field button:hover { filter: brightness(1.08); }
.login-field button:active { transform: scale(0.97); }
.login-error { color: #fca5a5; font-size: 13px; margin-top: 14px; }
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ============ APP ============ */
.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand-icon { font-size: 34px; }
.brand h1 { font-size: 26px; letter-spacing: -0.02em; }
.brand-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.updated { color: var(--muted); font-size: 13px; }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ghost-btn:hover { background: var(--panel-2); border-color: var(--accent); }
.ghost-btn.danger { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.ghost-btn.danger:hover { background: rgba(239, 68, 68, 0.12); border-color: var(--suspended); }
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(0.97); }

/* ============ STATS ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 28px 0 22px;
}
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat .num { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.accent .num { color: var(--accent); }
.stat.active .num { color: var(--active); }
.stat.dev .num { color: var(--development); }
.stat.susp .num { color: var(--suspended); }

/* ============ CONTROLS ============ */
.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}
.search-wrap {
  position: relative;
  flex: 1 1 280px;
  min-width: 220px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.7;
}
.search-wrap input {
  width: 100%;
  background: #0d1428;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 12px 36px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.select-wrap { display: flex; flex-direction: column; gap: 6px; }
.select-wrap span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.select-wrap select {
  background: #0d1428;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  min-width: 170px;
  outline: none;
  cursor: pointer;
}
.select-wrap select:focus { border-color: var(--accent); }

.result-meta { color: var(--muted); font-size: 13px; margin: 4px 2px 16px; }

/* ============ GRID ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card h3 { font-size: 17px; letter-spacing: -0.01em; line-height: 1.3; }
.card-folder {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  word-break: break-all;
}
.card-summary {
  color: #c3cde4;
  font-size: 13.5px;
  line-height: 1.55;
  flex: 1;
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.dept {
  background: rgba(108, 140, 255, 0.14);
  color: #a9bcff;
  border-color: rgba(108, 140, 255, 0.3);
}
.badge.status { color: #fff; }
.badge.status.Active { background: rgba(34, 197, 94, 0.16); color: #6ee7a0; border-color: rgba(34, 197, 94, 0.35); }
.badge.status.Development { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }
.badge.status.Suspended { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }
.badge.status.Inactive { background: rgba(100, 116, 139, 0.18); color: #cbd5e1; border-color: rgba(100, 116, 139, 0.4); }
.tech-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px;
  color: var(--muted);
  background: #0d1428;
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 8px;
}
.card-actions { margin-top: 2px; }
.read-more {
  background: transparent;
  border: 1px solid var(--accent);
  color: #b9c8ff;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.read-more:hover { background: var(--accent); color: #fff; }
.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.view-btn:hover { filter: brightness(1.08); }
.view-btn:active { transform: scale(0.97); }
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.admin-btn:hover { filter: brightness(1.08); }
.admin-btn:active { transform: scale(0.97); }
.modal-section a.open-link.admin { color: #fcd34d; border-color: rgba(245, 158, 11, 0.5); }
.modal-section a.open-link.admin:hover { background: rgba(245, 158, 11, 0.12); }

/* ============ EMPTY ============ */
.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 10px; }

/* ============ FOOTER ============ */
.footer { margin-top: 44px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ============ MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 8, 18, 0.72); backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 20px;
  max-width: 680px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: pop 0.25s ease;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #0d1428;
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.modal-close:hover { border-color: var(--accent); }
.modal-head { padding: 28px 28px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 12px; padding-right: 30px; }
.modal-body { padding: 22px 28px 30px; }
.modal-section { margin-bottom: 22px; }
.modal-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-bottom: 8px;
}
.modal-section p { color: #cfd8ec; font-size: 14.5px; line-height: 1.65; }
.modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-bottom: 0;
}
.modal-meta > div { display: flex; flex-direction: column; gap: 5px; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.modal-meta code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: #c3cde4;
  word-break: break-all;
}

/* ============ EDITING ============ */
.badge.edited {
  background: rgba(139, 92, 246, 0.16);
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.4);
}
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.open-link {
  color: #7ee0a4;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 10px;
  transition: background 0.15s;
}
.open-link:hover { background: rgba(34, 197, 94, 0.12); }
.modal-section a.open-link { word-break: break-all; }

.edit-hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  background: #0d1428;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #1c2747;
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 90;
  max-width: 90vw;
  text-align: center;
  animation: pop 0.25s ease;
}

@media (max-width: 560px) {
  .app { padding: 20px 14px 50px; }
  .brand h1 { font-size: 21px; }
  .grid { grid-template-columns: 1fr; }
  .modal-card { max-height: 92vh; }
  .field-row { grid-template-columns: 1fr; }
}
