:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --soft: #fafafa;
  --line: #d8d8d8;
  --ink: #000000;
  --muted: #666666;
  --brand: #7d1919;
  --silver: #c0c0c0;
  --green: #1f6f43;
  --amber: #8a6d1d;
  --red: #9b1c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Montserrat, Arial, Helvetica, sans-serif;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 11px 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.danger { color: var(--red); }
.plain { width: 100%; margin-top: 22px; }

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

aside {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 22px;
}

.brand-logo {
  width: 190px;
  max-width: 100%;
  display: block;
  margin-bottom: 34px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-btn.active {
  background: #f7eeee;
  border-color: #ead2d2;
  color: var(--brand);
}

.side-note {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 28px;
  padding-top: 18px;
}

main {
  padding: 32px;
  overflow: auto;
}

.topbar {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
  margin: 6px 0 6px;
}

h2 {
  color: var(--brand);
  font-size: 13px;
  margin: 0 0 16px;
  text-transform: uppercase;
}

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

.status-counts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 118px;
  padding: 12px;
}

.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.view { display: none; }
.view.active { display: block; }

.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(320px, .85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.panel + .panel { margin-top: 18px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field.full { grid-column: 1 / -1; }

label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(125, 25, 25, .12);
}

.drop {
  border: 1px dashed #b8c4d2;
  border-radius: 8px;
  background: var(--soft);
  padding: 18px;
}

.drop input {
  border: 0;
  padding: 0;
  background: transparent;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.file-limit {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin-top: 10px;
  text-transform: uppercase;
}

.files {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.file-row {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 110px auto auto;
  padding: 10px 12px;
}

.file-row span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.file-row input {
  padding: 8px;
}

.file-remove, .file-view {
  font-size: 13px;
  padding: 8px 10px;
}

.actions, .link-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

progress {
  width: 100%;
  margin-top: 12px;
}

.summary {
  display: grid;
  gap: 12px;
}

.summary-row {
  border-bottom: 1px solid var(--line);
  padding-bottom: 11px;
}

.summary-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary-row b {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.link-preview {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #4b5563;
  font-size: 13px;
  margin-top: 14px;
  padding: 11px 12px;
  word-break: break-all;
}

.toast {
  background: #f7eeee;
  border: 1px solid #ead2d2;
  border-radius: 8px;
  color: var(--brand);
  display: none;
  font-weight: 800;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 220px auto;
  gap: 10px;
  margin-bottom: 14px;
}

.history-list, .audit-list {
  display: grid;
  gap: 10px;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.history-grid b {
  color: var(--muted);
  display: block;
  font-size: 11px;
  text-transform: uppercase;
}

.badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 9px;
}

.badge.pending { background: #fff7e6; color: var(--amber); }
.badge.done { background: #ecfdf3; color: var(--green); }
.badge.dead { background: #f1f1f1; color: var(--muted); }
.badge.error { background: #fef2f2; color: var(--red); }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.audit-row {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 820px;
  width: calc(100% - 40px);
}

.dialog-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-docs {
  margin: 0;
  padding-left: 18px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-card img {
  width: 190px;
  display: block;
  margin-bottom: 22px;
}

.login-card button {
  width: 100%;
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  margin-top: 14px;
}

.error {
  color: var(--red);
  margin-top: 12px;
}

.public-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.public-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 860px;
  padding: 34px;
  width: 100%;
}

.public-card img {
  display: block;
  width: 220px;
  margin-bottom: 28px;
}

.public-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.public-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.public-grid b {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.public-card form button {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 12px;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  aside {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  nav { grid-template-columns: repeat(3, 1fr); }
  main { padding: 22px; }
  .topbar { display: block; }
  .status-counts { margin-top: 16px; }
  .layout, .form-grid, .filters, .public-grid { grid-template-columns: 1fr; }
  .file-row { grid-template-columns: 1fr; }
  .history-grid { grid-template-columns: 1fr 1fr; }
}
