/* Admin UI inspired by TailAdmin: slate sidebar + white cards. */
:root {
  --sidebar: #1c2434;
  --sidebar-hover: #333a48;
  --sidebar-active: #3c50e0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #1a222c;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #3c50e0;
  --primary-hover: #3342c5;
  --success: #219653;
  --success-soft: #e8f8ef;
  --warn: #d97706;
  --warn-soft: #fff7ed;
  --danger: #d34053;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Liberation Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 0.92rem; }

/* Shell */
.admin-shell {
  min-height: 100vh;
  display: flex;
}
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #dee4ee;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3c50e0, #6366f1);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; color: #fff; font-size: 1rem; }
.brand-text span { font-size: 0.75rem; color: #8a99af; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  color: #dee4ee;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}
.nav a:hover { background: var(--sidebar-hover); }
.nav a.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.9;
  flex-shrink: 0;
}

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}
.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.content {
  padding: 24px 28px 48px;
  max-width: 1100px;
  width: 100%;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 650;
}

/* Forms */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}
.row .field { flex: 1; min-width: 160px; margin-bottom: 0; }
input[type="text"],
input[type="password"],
input[type="search"],
input:not([type]),
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  height: 44px;
  background: #fff;
  color: var(--ink);
}
.login-card .field input {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
}
input:focus, select:focus {
  outline: 2px solid rgba(60, 80, 224, 0.25);
  border-color: var(--primary);
}
.file-row { display: flex; gap: 10px; align-items: center; }
.file-name {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  font: inherit;
  background: #fff;
  color: var(--muted);
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Buttons */
button, .btn {
  font: inherit;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover, .btn:hover { background: var(--primary-hover); }
button.secondary, .btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--line);
}
button.secondary:hover, .btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--primary);
}
button.danger, .btn-danger {
  background: var(--danger);
  color: #fff;
}
button.danger:hover { filter: brightness(0.95); }
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
.actions { margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Login overlay card */
.boot-screen,
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, #e0e7ff 0%, transparent 55%),
    var(--bg);
}
.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.95rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(16, 24, 40, 0.08);
  padding: 28px;
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}
.login-card .lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.92rem;
}
.login-card .actions {
  margin-top: 8px;
}
.login-card .actions button {
  width: 100%;
}

/* Progress */
.busy {
  display: none;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: 24px;
}
.busy.visible { display: flex; }
.busy-top { display: flex; align-items: center; gap: 14px; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy h2 { margin: 0 0 4px; font-size: 1.05rem; }
.busy p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 8%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  transition: width 0.45s ease;
}
.progress-fill.indeterminate {
  width: 35%;
  animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

/* Results */
.result { display: none; }
.result.visible { display: block; }
.result.ok { border-color: #86efac; background: linear-gradient(#fff, var(--success-soft)); }
.result.warn { border-color: #fdba74; background: linear-gradient(#fff, var(--warn-soft)); }
.result h2 { margin: 0 0 8px; font-size: 1.15rem; }
.result.ok h2 { color: var(--success); }
.result.warn h2 { color: var(--warn); }
.counts { color: var(--muted); margin: 0 0 14px; }
.links { display: flex; gap: 10px; flex-wrap: wrap; }
.links a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.links a:hover { border-color: var(--primary); background: #f8fafc; }

.group {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.group-head h3 { margin: 0; font-size: 1rem; }
.group-table {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.delta { font-variant-numeric: tabular-nums; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
}
th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
tbody tr:hover { background: #f8fafc; }

.status-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.status-filters button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-weight: 500;
}
.status-filters button:hover { border-color: var(--primary); color: var(--primary); }
.status-filters button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.status-found { color: var(--success); font-weight: 600; }
.status-missing { color: var(--danger); font-weight: 600; }
.actions-cell { white-space: nowrap; }
.actions-cell button { margin-right: 6px; padding: 6px 10px; font-size: 0.82rem; }

.import-preview { margin-top: 16px; }
.import-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
  font-size: 0.92rem;
}
.import-toolbar label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check-cell { display: flex; align-items: center; }
#import-card a { color: var(--primary); font-weight: 600; }

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
  }
  .brand { border: 0; padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
