:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #d9dee7;
  --text: #111827;
  --muted: #64748b;
  --blue: #1769e0;
  --blue-dark: #0f54b8;
  --danger: #dc2626;
  --green: #059669;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a {
  color: var(--blue);
  text-decoration: none;
}

.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 64px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.brand {
  color: #000;
  font-size: 18px;
  font-weight: 700;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-actions a,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--blue);
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.nav-actions a {
  border-color: var(--border);
  background: #fff;
  color: #334155;
}

.nav-actions a.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.button.secondary,
button.secondary {
  border-color: var(--border);
  background: #fff;
  color: #334155;
}

button:hover,
.button:hover {
  background: var(--blue-dark);
}

.button.secondary:hover,
button.secondary:hover {
  background: #f8fafc;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 26px;
  font-weight: 500;
}

h2 {
  font-size: 18px;
  font-weight: 500;
}

.muted {
  color: var(--muted);
}

.messages {
  margin-bottom: 16px;
}

.alert {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

.alert.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.alert.danger {
  border-color: #fecaca;
  background: #fef2f2;
}

.alert.warning {
  border-color: #fed7aa;
  background: #fff7ed;
}

.login-panel,
.panel,
.card,
.upload-panel {
  background: var(--panel);
  border: 1px solid #edf0f4;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.login-panel {
  max-width: 380px;
  margin: 80px auto;
  padding: 28px;
}

.auth-link {
  margin: 14px 0 0;
  color: var(--muted);
}

.first-admin-note {
  margin: 10px 0 0;
  font-size: 12px;
}

.form {
  display: grid;
  gap: 10px;
}

input,
select {
  min-height: 34px;
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font: inherit;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px auto auto;
  gap: 8px;
  margin-bottom: 16px;
}

.panel {
  padding: 14px;
}

.panel.narrow {
  max-width: 560px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  font-weight: 700;
}

.file-name {
  font-weight: 600;
  word-break: break-word;
}

.actions-col {
  width: 92px;
  text-align: right;
}

.menu {
  position: relative;
  display: inline-block;
}

.menu summary {
  width: 32px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  list-style: none;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu-list {
  position: absolute;
  right: 0;
  z-index: 10;
  min-width: 140px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  text-align: left;
}

.menu-list a,
.menu-list button {
  width: 100%;
  justify-content: flex-start;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.menu-list a:hover,
.menu-list button:hover {
  background: #f1f5f9;
}

.menu-list form {
  margin: 0;
}

.danger-text {
  color: var(--danger) !important;
}

dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
}

.dialog-form {
  padding: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.upload-panel {
  padding: 28px;
}

.upload-box {
  display: grid;
  gap: 14px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  border: 2px dashed #b8c3d4;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone.drag-over {
  border-color: var(--blue);
  background: #eff6ff;
}

.drop-title {
  display: block;
  font-size: 22px;
  font-weight: 700;
}

.drop-subtitle {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.selected-files {
  max-height: 160px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  padding: 16px;
}

.big {
  font-size: 24px;
  margin-bottom: 4px;
}

.ok {
  color: var(--green);
}

.bad {
  color: var(--danger);
}

.disk-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.progress {
  margin-top: 12px;
  height: 18px;
  overflow: hidden;
  border-radius: 4px;
  background: #e5e7eb;
}

.progress div {
  height: 100%;
  min-width: 36px;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.terminal {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #111;
  color: #00ff66;
  font-family: Consolas, monospace;
  font-size: 13px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

.badge.admin,
.badge.approved {
  background: #dcfce7;
  color: #166534;
}

.badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.badge.rejected {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }

  .page {
    padding: 20px 16px;
  }

  .toolbar,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
