:root {
  --bg: #f4f5f3;
  --panel: #ffffff;
  --panel-alt: #f8f9f7;
  --line: #d7ddd5;
  --line-strong: #c3cbc1;
  --text: #151a18;
  --muted: #68736d;
  --accent: #2c6556;
  --accent-soft: #e7eee9;
  --danger: #9d2d24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.42 "Segoe UI", Arial, sans-serif;
}

a {
  color: #175f87;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.nav a {
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.nav a.active {
  background: var(--accent-soft);
  border-color: #cedbd2;
  color: var(--accent);
  font-weight: 600;
}

.nav a:hover {
  background: var(--panel-alt);
  text-decoration: none;
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.role,
.muted {
  color: var(--muted);
}

.content {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 24px 44px;
}

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

.login-panel {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 22px;
  box-shadow: 0 10px 28px rgba(20, 24, 22, 0.06);
}

.login-title {
  margin-bottom: 18px;
}

.login-title h1,
.page-header h1,
.surface h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-title h1 {
  font-size: 20px;
}

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

.page-header h1 {
  font-size: 22px;
  font-weight: 650;
}

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

.surface {
  margin-bottom: 14px;
  padding: 16px 18px;
  overflow-x: auto;
}

.surface h2 {
  font-size: 17px;
  font-weight: 650;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metrics.compact {
  grid-template-columns: repeat(2, minmax(150px, 220px));
}

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

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 7px;
}

.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
}

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

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

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--panel-alt);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 8px 9px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(44, 101, 86, 0.18);
  border-color: var(--accent);
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--panel-alt);
  text-decoration: none;
}

button:disabled,
.button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.58;
}

button:disabled:hover,
.button:disabled:hover {
  background: #fff;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: #224f43;
}

.danger-button {
  color: var(--danger);
}

.link-button {
  color: var(--muted);
}

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

.grid-form {
  display: grid;
  grid-template-columns: 1.4fr 150px 210px;
  gap: 12px;
  align-items: end;
}

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

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

.inline-form {
  display: flex;
  gap: 6px;
}

.inline-form input {
  width: 150px;
}

dialog.modal {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  background: transparent;
}

dialog.modal::backdrop {
  background: rgba(18, 24, 22, 0.44);
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 24px 60px rgba(18, 24, 22, 0.22);
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 650;
}

.category-create input {
  width: 260px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.checks label,
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.checks input,
.inline-check input {
  width: auto;
}

.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #cbd8cf;
  border-radius: 4px;
  background: #edf4ef;
}

.alert.danger {
  border-color: #e2b4ae;
  background: #fff0ee;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 11px;
}

code {
  display: inline-block;
  max-width: 640px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .top-nav {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 16px;
  }

  .account {
    justify-content: space-between;
  }

  .content {
    padding: 16px;
  }

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