:root {
  --bg-light: #f4f6f4;
  --surface: #ffffff;
  --surface-muted: #e7ece8;
  --line: #cbd5cf;
  --color-primary: #3a6053;
  --color-secondary: #6b827a;
  --color-text: #2c3531;
  --color-muted: #66726d;
  --color-danger: #b85a5c;
  --focus: #24483d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-light);
  color: var(--color-text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

button.secondary {
  background: var(--color-secondary);
}

button.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--color-text);
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--color-muted);
  font-size: 0.86rem;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 76px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px 16px;
  gap: 16px;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 1.05rem;
}

.brand span {
  color: var(--color-muted);
  font-size: 0.82rem;
}

.role-pill {
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--color-primary);
  padding: 7px 10px;
  font-size: 0.84rem;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 8px;
  min-width: 0;
}

button.compact {
  min-height: 34px;
  padding: 0 10px;
}

.main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 16px 32px;
}

.view {
  display: grid;
  gap: 16px;
}

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

.section-head h1,
.section-head h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.section-head p {
  margin: 4px 0 0;
  color: var(--color-muted);
}

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

.summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

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

.summary strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

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

.card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.card-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.card-title h3 {
  margin: 0;
  font-size: 1rem;
}

.meta {
  color: var(--color-muted);
  font-size: 0.86rem;
}

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

.tag {
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--color-primary);
  padding: 5px 8px;
  font-size: 0.78rem;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

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

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

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

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

th {
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.84rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(720px, 100%);
  margin: 0 auto;
}

.nav-button {
  display: grid;
  gap: 3px;
  place-items: center;
  min-height: 58px;
  border-radius: 0;
  background: transparent;
  color: var(--color-muted);
  padding: 6px 4px;
  font-size: 0.76rem;
}

.nav-button.active {
  color: var(--color-primary);
  font-weight: 700;
}

.nav-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--color-muted);
  padding: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 84px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgb(38 51 45 / 12%);
  padding: 12px 14px;
}

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

.auth-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
}

.auth-panel h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
}

.auth-error {
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--color-danger) 45%, white);
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-danger) 10%, white);
  color: var(--color-danger);
  padding: 10px 12px;
}

@media (min-width: 840px) {
  .app-shell {
    padding-bottom: 0;
  }

  .bottom-nav {
    top: 74px;
    right: auto;
    bottom: 0;
    width: 96px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .bottom-nav-inner {
    grid-template-columns: 1fr;
  }

  .nav-button {
    min-height: 70px;
  }

  .main {
    padding-left: 116px;
  }
}

@media (max-width: 520px) {
  .topbar-inner {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}
