:root {
  --teal: #06514c;
  --teal-deep: #043d3a;
  --gold: #d3b471;
  --ink: #10221f;
  --muted: #5b6e6a;
  --panel: rgba(255, 255, 255, 0.82);
  --line: rgba(6, 81, 76, 0.12);
  --danger: #9b2c2c;
  --ok: #0f766e;
  --shadow: 0 18px 40px rgba(16, 34, 31, 0.08);
  --radius: 18px;
  font-family: "Be Vietnam Pro", "Sarabun", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(211, 180, 113, 0.28), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(6, 81, 76, 0.18), transparent 50%),
    linear-gradient(165deg, #f4f7f6 0%, #e8efed 45%, #f7f3ea 100%);
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 18px 56px;
}

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

.brand-kicker {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.85rem;
  margin: 0 0 6px;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 42ch;
  line-height: 1.5;
}

.health {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 48px;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.health-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15); }
.health-dot.bad { background: var(--danger); box-shadow: 0 0 0 4px rgba(155, 44, 44, 0.15); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  background: var(--teal);
  color: #fff;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

label.field {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

input[type="text"],
input[type="file"] {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  min-width: 160px;
}

input[type="file"] {
  max-width: 260px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

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

.btn-ghost {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--line);
}

.btn-danger {
  background: rgba(155, 44, 44, 0.08);
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-line {
  padding: 0 16px;
  min-height: 28px;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-line.error { color: var(--danger); }
.status-line.ok { color: var(--ok); }

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

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thumb {
  aspect-ratio: 1;
  background:
    linear-gradient(45deg, #eef2f1 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #eef2f1 25%, transparent 25%) 0 0 / 16px 16px,
    #f8faf9;
  display: grid;
  place-items: center;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meta {
  padding: 10px 12px 12px;
  display: grid;
  gap: 8px;
}

.meta .name {
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.35;
}

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

.meta .actions {
  display: flex;
  gap: 8px;
}

.empty,
.loading {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

.hidden { display: none !important; }

@media (max-width: 640px) {
  .toolbar { align-items: stretch; }
  .toolbar-left,
  .toolbar-right { width: 100%; }
  input[type="file"],
  input[type="text"] { width: 100%; max-width: none; min-width: 0; }
  .btn { width: 100%; }
}
