:root {
  --ink: #17211d;
  --muted: #65716d;
  --line: #d8dfdb;
  --paper: #f7f8f6;
  --panel: #ffffff;
  --forest: #24483d;
  --forest-2: #17352d;
  --gold: #b88936;
  --rust: #8f4d2d;
  --blue: #315f78;
  --danger: #9a2f2f;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

button,
.button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: var(--forest);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--forest-2);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #edf1ed 0%, #f8f6f0 55%, #e9eef0 100%);
}

.login-panel {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 420px;
  gap: 32px;
  align-items: center;
}

.login-copy h1 {
  margin: 0 0 16px;
  max-width: 620px;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.98;
}

.login-copy p:last-child {
  max-width: 560px;
  color: var(--muted);
  font-size: 18px;
}

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

.login-card,
.record-form,
.table-panel,
.empty-state,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 55px rgba(23, 33, 29, 0.08);
}

.login-card {
  padding: 28px;
}

.login-card h2 {
  margin-top: 0;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

.alert,
.success {
  border-radius: 6px;
  margin: 0 0 16px;
  padding: 12px 14px;
  font-weight: 700;
}

.alert {
  background: #fff1f1;
  color: var(--danger);
}

.success {
  background: #edf7f1;
  color: var(--forest);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #11241f;
  color: #eef4f1;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #1d1710;
  font-weight: 900;
}

.brand small {
  display: block;
  color: #b8c6c0;
}

.entity-selector {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 12px;
}

.entity-selector label {
  color: #d9e3df;
  margin-bottom: 8px;
}

.entity-selector select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
}

.entity-selector small {
  color: #b8c6c0;
}

.entity-selector button {
  min-height: 36px;
  width: 100%;
}

.account-context {
  color: #eef4f1;
}

.account-context small {
  display: block;
  color: #b8c6c0;
}

.account-context strong {
  display: block;
}

.nav-link {
  display: block;
  border-radius: 6px;
  color: #d9e3df;
  margin-bottom: 6px;
  padding: 10px 12px;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.logout-form {
  margin-top: auto;
}

.logout-form button {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
}

.main {
  padding: 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
  font-size: 34px;
}

.page-subtitle {
  color: var(--muted);
  margin: 6px 0 0;
}

.user-pill,
.secondary-link {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-row div {
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.metric-row small,
.module-card small,
td small {
  display: block;
  color: var(--muted);
}

.metric-row strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.module-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  text-decoration: none;
}

.module-card span {
  font-size: 19px;
  font-weight: 800;
}

.module-card:hover {
  border-color: var(--blue);
}

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

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

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

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

.sort-link {
  color: inherit;
  text-decoration: none;
}

.sort-link:hover {
  color: var(--forest);
  text-decoration: underline;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.actions a,
.actions button {
  min-height: 34px;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 14px;
}

.actions a {
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.actions button {
  background: #f7eeee;
  color: var(--danger);
}

.actions form {
  margin: 0;
}

.table-empty {
  color: var(--muted);
  padding: 30px 16px;
  text-align: center;
}

.record-form {
  padding: 22px;
}

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

.form-grid label:last-child {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.form-actions a {
  color: var(--muted);
}

.form-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.form-section:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.form-section h2,
.detail-panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.checkbox-group {
  display: grid;
  gap: 10px;
}

.checkbox-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
}

.checkbox-row input {
  width: auto;
}

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

.muted-note {
  color: var(--muted);
  margin: 0;
}

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

.detail-panel {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

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

.detail-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.linked-list {
  margin-bottom: 0;
}

.empty-state {
  padding: 34px;
}

.empty-state h2 {
  margin-top: 0;
}

.empty-state p {
  color: var(--muted);
}

@media (max-width: 860px) {
  .login-panel,
  .app-shell,
  .metric-row,
  .module-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .main {
    padding: 22px;
  }
}
