:root {
  --bg: #f4f1ea;
  --surface: #fffaf2;
  --surface-2: #f0e7d8;
  --text: #1f1b16;
  --muted: #665b4d;
  --line: #d8cbb8;
  --accent: #285943;
  --accent-2: #c96f3b;
  --danger: #8f2d2d;
  --ok: #2f6b3e;
  --shadow: 0 18px 40px rgba(31, 27, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(201, 111, 59, 0.12), transparent 30%),
    linear-gradient(180deg, #f6f0e6 0%, #efe5d6 100%);
  color: var(--text);
}

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

a:hover {
  text-decoration: underline;
}

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

.sidebar {
  padding: 28px 20px;
  background: rgba(255, 250, 242, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #173c2c);
  color: white;
  font-weight: 700;
}

.brand small {
  display: block;
  color: var(--muted);
}

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

.nav a {
  padding: 12px 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

.nav a:hover {
  background: rgba(40, 89, 67, 0.08);
  text-decoration: none;
}

.main-content {
  padding: 28px;
  min-width: 0;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(216, 203, 184, 0.65);
}

.page-header-split {
  align-items: start;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 2rem;
}

.page-header p,
.muted {
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metrics-grid,
.panel-grid,
.form-grid {
  display: grid;
  gap: 16px;
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 24px;
}

.panel-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.metric-card,
.panel-card,
.login-card {
  background: rgba(255, 250, 242, 0.9);
  border: 1px solid rgba(216, 203, 184, 0.8);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 20px 20px 0 0;
}

.metric-card strong {
  display: block;
  font-size: 2rem;
  margin-top: 8px;
}

.metric-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

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

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(216, 203, 184, 0.65);
  border-radius: 16px;
  background: rgba(255, 250, 242, 0.9);
}

.responsive-table {
  min-width: 760px;
}

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

.responsive-table th {
  position: sticky;
  top: 0;
  background: rgba(255, 250, 242, 0.96);
  z-index: 1;
}

th {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.8rem;
}

.priority-1 {
  background: rgba(201, 111, 59, 0.18);
}

.priority-2 {
  background: rgba(40, 89, 67, 0.12);
}

.priority-3 {
  background: rgba(102, 91, 77, 0.15);
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fffdf9;
}

button,
.button-link,
.button-link-light {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  text-decoration: none;
}

.button-secondary,
.button-link-light {
  background: var(--surface-2);
  color: var(--text);
}

.button-danger {
  background: rgba(143, 45, 45, 0.12);
  color: var(--danger);
}

.button-small {
  padding: 8px 10px;
  font-size: 0.86rem;
}

.action-list,
.form-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-form input {
  min-width: 190px;
}

.flash {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 12px;
}

.flash-success {
  background: rgba(47, 107, 62, 0.16);
  color: var(--ok);
}

.flash-error {
  background: rgba(143, 45, 45, 0.12);
  color: var(--danger);
}

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

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

.wide-form {
  max-width: 980px;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

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

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.toolbar-card {
  position: sticky;
  top: 14px;
  z-index: 2;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(auto-fit, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.toolbar-field {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.toolbar-field-wide {
  min-width: 0;
}

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

.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.record-tile {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(216, 203, 184, 0.8);
  background: rgba(255, 250, 242, 0.85);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.record-tile:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 22px 46px rgba(31, 27, 22, 0.12);
}

.record-tile-kicker,
.record-tile-count,
.record-tile-desc {
  color: var(--muted);
}

.record-tile strong {
  font-size: 1.05rem;
}

.record-tile-count {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}

.empty-state {
  display: grid;
  gap: 12px;
  padding: 24px 0 10px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.cell-wrap {
  display: inline-block;
  max-width: 340px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    position: static;
    height: auto;
  }

  .main-content {
    padding: 20px;
  }

  .page-header,
  .section-head,
  .toolbar-grid {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .page-header,
  .page-header-split {
    align-items: start;
  }

  .page-actions,
  .toolbar-actions,
  .action-list,
  .form-actions,
  .table-actions,
  .inline-form,
  .pagination {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .table-actions,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .table-wrap {
    border-radius: 14px;
  }

  .responsive-table {
    min-width: 0;
    border: 0;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table tr {
    margin-bottom: 14px;
    border: 1px solid rgba(216, 203, 184, 0.7);
    border-radius: 16px;
    overflow: hidden;
    background: rgba(255, 250, 242, 0.96);
  }

  .responsive-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    flex: 0 0 42%;
  }

  .record-meta {
    flex-direction: column;
  }

  .toolbar-card {
    position: static;
  }
}
