:root {
  color-scheme: dark;
  --bg: #1f1f1f;
  --panel: #2a2a2a;
  --panel-soft: #323232;
  --field: #242424;
  --ink: #f2f2f2;
  --muted: #b7b7b7;
  --line: #444444;
  --brand: #d7d7d7;
  --brand-dark: #ffffff;
  --good: #8fd8ae;
  --warn: #f0c36d;
  --bad: #ff9b90;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(16px, 4vw, 48px);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: #d0d0d0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

h2 {
  font-size: 1.15rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 48px;
}

.panel,
.table-wrap,
.stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-panel {
  align-self: start;
  padding: 20px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #cfcfcf;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: #838383;
}

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

.actions,
.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 7px;
  background: #e7e7e7;
  color: #202020;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 14px;
}

button:hover {
  background: #ffffff;
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

button.secondary:hover {
  background: #3b3b3b;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--bad);
  font-weight: 700;
}

.workspace {
  min-width: 0;
}

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

.stats article {
  padding: 16px;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.65rem;
}

.stats span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.search-label {
  flex: 1 1 300px;
}

.table-wrap {
  overflow: auto;
  position: relative;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: 0;
}

.company-cell strong,
.muted-line {
  display: block;
}

.muted-line {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.company-link {
  display: block;
  width: fit-content;
  max-width: 260px;
  margin-top: 4px;
  color: #dcdcdc;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-link:hover {
  color: #ffffff;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #3a3a3a;
  color: #eeeeee;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.good {
  background: #183d29;
  color: var(--good);
}

.badge.warn {
  background: #493718;
  color: var(--warn);
}

.badge.bad {
  background: #4a2421;
  color: var(--bad);
}

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

.row-actions button {
  padding: 7px 9px;
}

.empty {
  display: none;
  margin: 0;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.table-wrap.is-empty table {
  display: none;
}

.table-wrap.is-empty .empty {
  display: block;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .entry-panel {
    padding: 16px;
  }
}
