:root {
  --ink: #111;
  --paper: #f5f5f2;
  --red: #111;
  --gold: #3a3a36;
  --muted: #66645f;
  --border: #111;
  --line: rgba(17, 17, 17, 0.22);
  --serif: Baskerville, 'Palatino Linotype', 'Book Antiqua', Garamond, serif;
  --display: 'Iowan Old Style', Baskerville, Garamond, 'Times New Roman', serif;
  --sans: 'Lucida Sans', 'Gill Sans', 'Trebuchet MS', sans-serif;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    repeating-linear-gradient(0deg, rgba(17, 17, 17, 0.025) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, #fbfbf8 0%, var(--paper) 48%, #d9d9d1 100%);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
img { display: block; max-width: 100%; }

.shell {
  width: min(1280px, calc(100% - 18px));
  margin: 16px auto 40px;
}

.topline,
.panel,
.table-shell,
.stats-grid .stat-card,
.login-card,
.preview-box {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #ecece7);
  box-shadow: var(--shadow);
}

.topline {
  padding: 10px 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
}

.topnote {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.topbrand {
  margin-top: 14px;
  font-family: var(--display);
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.92;
}

.topsub {
  margin-top: 6px;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.header {
  margin-top: 16px;
  padding: 20px 22px 22px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
}

.masthead {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 0.98;
}

.sub {
  margin: 10px 0 0;
  color: #333;
  max-width: 760px;
  line-height: 1.7;
}

.actions,
.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

.btn.primary {
  background: var(--ink);
  color: #fff;
}

.btn.danger {
  border-color: var(--red);
  color: var(--red);
}

.btn:hover { background: #ecece7; }
.btn.primary:hover { background: #222; }

.main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.form-panel,
.table-shell,
.preview-box {
  padding: 20px;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.title {
  margin: 10px 0 0;
  font-family: var(--display);
  font-size: clamp(1.9rem, 3vw, 2.5rem);
  line-height: 1.05;
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  font-weight: 600;
}

label input[type='checkbox'] {
  width: auto;
  margin-right: 8px;
}

input:not([type='checkbox']):not([type='radio']),
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

input:not([type='checkbox']):not([type='radio']):focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(17, 17, 17, 0.22);
  outline-offset: 1px;
}

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

.small-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-card {
  padding: 16px 18px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-family: var(--display);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  line-height: 1;
}

.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  vertical-align: top;
  border-top: 1px solid var(--line);
}

thead th {
  border-top: 0;
  border-bottom: 2px solid var(--border);
  font-size: 0.76rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

tbody tr:nth-child(even) {
  background: rgba(23, 19, 17, 0.03);
}

.badge {
  display: inline-block;
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: #ecece7;
}

.message {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: #fff;
}

.message.error {
  border-color: var(--red);
  color: var(--red);
}

.message.success {
  border-color: #444;
  color: #444;
}

.message.hidden,
.hidden {
  display: none !important;
}

.stack {
  display: grid;
  gap: 16px;
}

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

.login-card {
  width: min(540px, 100%);
  padding: 28px;
}

.login-card .title {
  font-size: clamp(2.4rem, 6vw, 3.3rem);
}

.preview-box {}

.preview-image {
  margin-top: 12px;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 8px),
    linear-gradient(135deg, #d8d8d2 0%, #aaa 100%);
  overflow: hidden;
}

.preview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92rem;
}

.link-cell { word-break: break-word; }
.top-bar { margin-top: 16px; }

@media (max-width: 980px) {
  .shell { width: min(1280px, calc(100% - 24px)); }
  .main-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .shell {
    width: min(1280px, calc(100% - 20px));
    margin-top: 10px;
  }
  .field-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .topline,
  .header {
    align-items: flex-start;
  }
  .topbrand,
  .masthead {
    font-size: 2.35rem;
    line-height: 1;
  }
  .topline,
  .header,
  .form-panel,
  .table-shell,
  .preview-box,
  .login-card {
    padding: 16px;
  }
  .inline-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .actions {
    width: 100%;
  }
  .btn { width: 100%; text-align: center; }
  input:not([type='checkbox']):not([type='radio']),
  textarea,
  select {
    font-size: 16px;
  }
  table {
    min-width: 760px;
  }
  th,
  td {
    padding: 10px 8px;
  }
}

@media (max-width: 420px) {
  .topbrand,
  .masthead,
  .title {
    font-size: 1.85rem;
  }
  .stat-card strong {
    font-size: 2.1rem;
  }
}
