:root {
  --bg: #f5f7f2;
  --panel: #ffffff;
  --line: #dde6d3;
  --text: #1f2a1e;
  --muted: #6b7567;
  --green-900: #22351e;
  --green-700: #3f6a37;
  --green-500: #7eb85e;
  --green-100: #e8f4db;
  --orange-600: #d66d27;
  --orange-100: #fff0df;
  --blue-600: #3a6ea5;
  --blue-100: #e8f1fb;
  --red-600: #bd3d32;
  --red-100: #fdecea;
  --shadow: 0 16px 48px rgba(31, 42, 30, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(126, 184, 94, 0.16), rgba(58, 110, 165, 0.08)),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h2 {
  margin: 0;
  letter-spacing: 0;
}

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

.muted {
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.6;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(126, 184, 94, 0.18);
}

.primary-action,
.secondary-action,
.ghost-action,
.danger-action {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-action {
  color: #fff;
  background: var(--green-700);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.78;
}

.login-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--green-700);
  font-weight: 700;
}

.login-loading[hidden] {
  display: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(126, 184, 94, 0.28);
  border-top-color: var(--green-700);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.large {
  width: 28px;
  height: 28px;
  border-width: 4px;
}

.global-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(245, 247, 242, 0.72);
  backdrop-filter: blur(2px);
}

.global-loading[hidden] {
  display: none;
}

.global-loading-panel {
  min-width: 220px;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  color: var(--green-700);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.secondary-action {
  color: var(--green-900);
  background: var(--green-100);
  border-color: #c7dab8;
}

.ghost-action {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.danger-action {
  color: var(--red-600);
  background: var(--red-100);
  border-color: #f4c5bf;
}

.form-error {
  margin: 0;
  color: var(--red-600);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 12px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green-700);
  border-radius: 8px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-item.active {
  color: #fff;
  background: var(--green-900);
}

.sidebar .ghost-action {
  margin-top: auto;
}

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

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

.toolbar,
.button-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status-bar {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f3d1ad;
  border-radius: 8px;
  color: #6d4317;
  background: var(--orange-100);
}

.content {
  display: grid;
  gap: 18px;
}

.section {
  display: grid;
  gap: 14px;
}

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

.section-header h3 {
  margin: 0;
  font-size: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.metric {
  min-height: 106px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  letter-spacing: 0;
}

.panel {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
  background: #fbfcf8;
}

td {
  font-size: 14px;
}

.thumb {
  display: block;
  width: 76px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #edf0e7;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--green-100);
  color: var(--green-700);
}

.badge.pending {
  color: var(--orange-600);
  background: var(--orange-100);
}

.badge.failed,
.badge.revoked,
.badge.rejected {
  color: var(--red-600);
  background: var(--red-100);
}

.badge.played,
.badge.delivered,
.badge.approved {
  color: var(--blue-600);
  background: var(--blue-100);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.photo-item {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.photo-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #edf0e7;
}

.photo-meta {
  display: grid;
  gap: 8px;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
}

.photo-meta strong {
  color: var(--text);
  font-size: 15px;
}

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

.small {
  color: var(--muted);
  font-size: 12px;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

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

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

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