:root {
  --bg: #f3f5f1;
  --ink: #18221f;
  --muted: #66736e;
  --line: #d9ded8;
  --panel: #ffffff;
  --brand: #be2d31;
  --brand-dark: #8d1d22;
  --accent: #23746c;
  --soft: #e7f0ed;
  --warn: #b7791f;
  --shadow: 0 18px 45px rgba(31, 42, 38, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Arial, Helvetica, sans-serif;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover { background: var(--brand-dark); }

button.ghost {
  background: #eef1ee;
  color: var(--ink);
  border: 1px solid var(--line);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
}

label {
  display: grid;
  gap: 6px;
  color: #36413d;
  font-size: 13px;
  font-weight: 700;
}

.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(190,45,49,.14), transparent 38%),
    linear-gradient(315deg, rgba(35,116,108,.18), transparent 42%),
    var(--bg);
}

.login-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.3fr .8fr;
  gap: 32px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
  box-shadow: var(--shadow);
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 34px; line-height: 1.08; margin-bottom: 12px; }
h2 { font-size: 20px; margin-bottom: 16px; }

.eyebrow {
  margin-bottom: 8px;
  color: var(--brand);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.muted { color: var(--muted); }
.error { color: var(--brand); min-height: 20px; }
.stack { display: grid; gap: 14px; }

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 18px 0 16px;
}

.topbar h1 { margin-bottom: 0; }

.userbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

#userBadge {
  background: var(--soft);
  color: #143e39;
  border: 1px solid #c8dfd9;
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  min-width: 104px;
}

.tab.active {
  background: var(--ink);
  color: white;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 14px;
  min-height: 90px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 25px;
}

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

.panel {
  padding: 18px;
  box-shadow: 0 10px 24px rgba(31, 42, 38, .06);
}

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

.grid-form .wide { grid-column: 1 / -1; }

.form-actions, .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

button.danger {
  background: #7f1d1d;
}

button.danger:hover {
  background: #5f1515;
}

.hint {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff7e8;
  color: #6e4a0d;
  min-height: 42px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: 14px 0;
}

.section-head input { max-width: 420px; }

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  position: sticky;
  top: 0;
  background: #f8faf7;
  color: #35413c;
  font-size: 12px;
  text-transform: uppercase;
}

td small {
  display: block;
  color: var(--muted);
  max-width: 560px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--soft);
  color: #174640;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .login-panel, .work-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar, .section-head { align-items: stretch; flex-direction: column; }
  .userbar { justify-content: space-between; }
}

@media (max-width: 560px) {
  .app { padding: 14px; }
  .login-panel { padding: 22px; }
  h1 { font-size: 28px; }
  .metrics, .grid-form { grid-template-columns: 1fr; }
}
