:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --panel: #ffffff;
  --line: #dfe8df;
  --text: #1c2a22;
  --muted: #66746b;
  --primary: #1f7a4d;
  --primary-strong: #155c39;
  --danger: #b42318;
  --warning: #a15c07;
  --soft: #edf4ee;
  --shadow: 0 18px 44px rgba(28, 42, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.login-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 360px);
  gap: 32px;
  width: min(840px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1,
.section-head h2,
.dialog h2,
.brand-block h2 {
  margin: 0;
}

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

label {
  display: grid;
  gap: 6px;
}

label span {
  color: #334239;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd8ce;
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.14);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.nav-btn,
.icon-btn {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 13px;
  font-weight: 700;
}

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

.primary-btn:hover {
  background: var(--primary-strong);
}

.secondary-btn {
  background: #fff;
  border-color: #cbd8ce;
  color: var(--text);
}

.ghost-btn {
  width: 100%;
  background: transparent;
  border-color: #d5e1d7;
  color: #315241;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  padding: 24px 16px;
  background: #0f261b;
  color: #fff;
}

.sidebar .eyebrow {
  color: #9bd1b2;
}

.sidebar nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  background: transparent;
  color: #d7eadc;
  text-align: left;
}

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

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.metrics-grid article {
  min-height: 82px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics-grid span {
  color: var(--muted);
  font-size: 13px;
}

.metrics-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel-section {
  display: grid;
  gap: 16px;
}

.compact-head {
  margin-bottom: 10px;
}

.compact-head h3 {
  margin: 0;
  font-size: 16px;
}

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

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

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

th {
  background: #f8fbf8;
  color: #435348;
  font-weight: 800;
}

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

.cell-title {
  display: grid;
  gap: 3px;
}

.cell-title strong {
  font-size: 14px;
}

.pill-row,
.row-actions,
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--soft);
  color: #28513a;
  font-size: 12px;
  font-weight: 700;
}

.pill.warning {
  background: #fff4df;
  color: var(--warning);
}

.pill.danger {
  background: #fff0ee;
  color: var(--danger);
}

.small-btn {
  min-height: 30px;
  border: 1px solid #cbd8ce;
  border-radius: 6px;
  padding: 5px 9px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.small-btn.danger {
  border-color: #f0b8b2;
  color: var(--danger);
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  padding: 12px 14px 0;
  color: var(--muted);
  font-size: 13px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.wide-dialog {
  width: min(960px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgba(15, 38, 27, 0.32);
}

.dialog-body {
  padding: 20px;
}

.dialog header,
.dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog footer {
  justify-content: flex-end;
}

.icon-btn {
  min-width: 36px;
  padding: 0;
  background: #f6faf7;
  border-color: #dce7df;
  color: var(--text);
  font-size: 20px;
}

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

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

.switch-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-line input {
  width: 18px;
}

.checks label {
  display: flex;
  align-items: center;
  width: auto;
  min-height: 32px;
  border: 1px solid #d8e3da;
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
}

.checks input {
  width: 16px;
}

.upload-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbf8;
}

.upload-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fbf8;
}

.upload-inline input {
  width: auto;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.image-item {
  display: grid;
  gap: 8px;
  border: 1px solid #d8e3da;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.image-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #eef4ef;
}

td .image-thumb {
  width: 86px;
}

.error-text {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  border-radius: 8px;
  padding: 12px 14px;
  background: #163b29;
  color: #fff;
  box-shadow: var(--shadow);
}

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

  .app-shell {
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }

  .brand-block h2 {
    font-size: 20px;
  }

  .sidebar .eyebrow {
    margin-bottom: 2px;
  }

  .nav-btn,
  .ghost-btn {
    width: auto;
    min-height: 36px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }
}
