/* Simply Clean & Organized — Bin Catalog */
:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --ink: #1C1C1A;
  --ink-2: #3D3C38;
  --muted: #74726B;
  --line: #E5E2DA;
  --line-2: #D6D2C8;
  --accent: #2F5D50;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7EFEB;
  --danger: #A8402C;
  --danger-soft: #F8E9E5;
  --warn-soft: #FBF3DD;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(28,28,26,.04), 0 4px 16px rgba(28,28,26,.05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tap: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 .4em; font-weight: 650; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-size: .92em; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.i { flex: none; vertical-align: -3px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(246,245,241,.92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 18px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; }
.nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--ink-2); padding: 8px 12px; border-radius: 999px; font-size: .94rem; white-space: nowrap; }
.nav a:hover { background: #ECEAE4; text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }
@media (max-width: 720px) {
  .brand-name { display: none; }
  .topbar-inner { padding: 8px 12px; gap: 10px; }
  .nav { margin-left: 0; flex: 1; justify-content: flex-end; }
  .nav a { padding: 8px 11px; font-size: .9rem; }
}

/* ---------- Page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 22px 18px 64px; }
.page-narrow { max-width: 560px; }
@media (max-width: 720px) { .page { padding: 16px 14px 56px; } h1 { font-size: 1.4rem; } }
.back { display: inline-block; color: var(--muted); font-size: .92rem; margin-bottom: 10px; padding: 4px 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards & sections ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .section + .section { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.section { margin-top: 26px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .grid-2, .grid-main { grid-template-columns: 1fr; } }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; }
.stat .lbl { color: var(--muted); font-size: .86rem; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 16px; border-radius: 11px;
  font: 600 .95rem/1 var(--font); letter-spacing: -0.005em;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; background: #FAF9F6; border-color: #C9C4B8; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #274F44; border-color: #274F44; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #33322E; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #ECEAE4; border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #E7C9C1; }
.btn-danger:hover { background: var(--danger-soft); border-color: #DDB0A5; }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: .86rem; border-radius: 9px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link-btn.danger { color: var(--danger); }

/* ---------- Forms ---------- */
label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--ink-2); }
.field { margin-bottom: 16px; }
.field .hint { color: var(--muted); font-size: .84rem; margin-top: 5px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=number], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  font: 16px/1.4 var(--font); color: var(--ink);
  background: #fff; border: 1px solid var(--line-2); border-radius: 10px;
  appearance: none; -webkit-appearance: none;
}
textarea { min-height: 96px; resize: vertical; }
textarea.tall { min-height: 170px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2374726B' stroke-width='1.6'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,93,80,.15); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.req { color: var(--danger); }

/* Sticky save bar on long mobile forms */
.savebar { position: sticky; bottom: 0; margin: 18px -18px -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.95); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  display: flex; gap: 10px; align-items: center; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.savebar .btn-primary { flex: 1; max-width: 260px; }

/* ---------- Flash ---------- */
.flash { padding: 12px 14px; border-radius: 11px; margin-bottom: 14px; background: var(--accent-soft); color: #1F4237; border: 1px solid #CFE0D8; }
.flash-error { background: var(--danger-soft); color: #7A2C1E; border-color: #EFCFC6; }
.flash-warn { background: var(--warn-soft); color: #6B5214; border-color: #EEDFAF; }

/* ---------- Search & filters ---------- */
.searchbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 260px; }
.search .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }
.searchbar select { flex: 0 1 180px; width: auto; }
@media (max-width: 560px) { .searchbar select { flex: 1 1 calc(50% - 4px); } }
.result-count { color: var(--muted); font-size: .9rem; margin: -6px 0 12px; }

/* ---------- Bin cards ---------- */
.bin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
@media (max-width: 560px) { .bin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.bin-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); transition: transform .12s ease, box-shadow .12s ease; }
.bin-card:hover { text-decoration: none; box-shadow: 0 6px 22px rgba(28,28,26,.09); transform: translateY(-1px); }
.thumb { position: relative; aspect-ratio: 4/3; background: #EEECE6; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #B5B1A6; }
.thumb-empty .i { width: 34px; height: 34px; }
.thumb-count { position: absolute; right: 8px; bottom: 8px; display: inline-flex; gap: 4px; align-items: center; background: rgba(28,28,26,.66); color: #fff; font-size: .76rem; padding: 3px 7px; border-radius: 999px; }
.thumb-count .i { width: 13px; height: 13px; vertical-align: 0; }
.thumb-badge { position: absolute; left: 8px; top: 8px; }
.bin-card-body { padding: 11px 13px 13px; }
.bin-code { font-family: var(--mono); font-size: .8rem; color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.bin-title { font-weight: 600; margin-top: 2px; line-height: 1.3; }
.bin-meta { color: var(--muted); font-size: .84rem; margin-top: 3px; }
@media (max-width: 560px) { .bin-card-body { padding: 9px 10px 11px; } .bin-title { font-size: .92rem; } .bin-meta { font-size: .78rem; } }

/* ---------- Tables / lists ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #FBFAF8; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #FBFAF8; }
.table .tiny-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #EEECE6; }
.table .tiny-thumb.empty { display: grid; place-items: center; color: #B5B1A6; }
.table td.check-col, .table th.check-col { width: 44px; padding-right: 0; }
.table input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Mobile: tables become stacked rows */
@media (max-width: 720px) {
  .table.stack thead { display: none; }
  .table.stack tr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center; }
  .table.stack tr:last-child { border-bottom: 0; }
  .table.stack td { padding: 0; border: 0; }
  .table.stack td.hide-sm { display: none; }
  .table.stack td.primary { grid-column: 2; }
  .table.stack td.thumb-col { grid-row: span 2; }
  .table.stack td.check-col { grid-row: span 2; }
}

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); letter-spacing: .01em; }
.badge-muted { background: #ECEAE4; color: var(--muted); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-dark { background: var(--ink); color: #fff; }

/* ---------- Bin detail ---------- */
.bin-hero { margin-bottom: 18px; }
.bin-hero .bin-code-lg { font-family: var(--mono); color: var(--accent); font-weight: 600; letter-spacing: .03em; font-size: .95rem; }
.bin-hero h1 { margin: 4px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: .9rem; color: var(--ink-2); }
.chip .i { color: var(--muted); width: 16px; height: 16px; }
.contents-summary { font-size: 1.06rem; line-height: 1.55; white-space: pre-line; }
.contents-details { white-space: pre-line; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: .94rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gallery a { display: block; aspect-ratio: 1; border-radius: 11px; overflow: hidden; background: #EEECE6; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.gallery a:hover img { transform: scale(1.03); }
.gallery.lead a:first-child { grid-column: 1 / -1; aspect-ratio: 4/3; }
@media (max-width: 560px) { .gallery { grid-template-columns: repeat(3, 1fr); gap: 6px; } }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(15,15,14,.94); display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; user-select: none; -webkit-user-select: none; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; width: 46px; height: 46px; border-radius: 50%; font-size: 22px; cursor: pointer; display: grid; place-items: center; }
.lightbox .lb-close { top: calc(14px + env(safe-area-inset-top)); right: 14px; }
.lightbox .lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-count { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: rgba(255,255,255,.75); font-size: .9rem; }

/* QR panel */
.qr-box { display: flex; gap: 16px; align-items: center; }
.qr-box img { width: 132px; height: 132px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.qr-box .actions { flex-direction: column; align-items: stretch; }
pre.textblock { background: #FBFAF8; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: .84rem/1.5 var(--mono); white-space: pre-wrap; max-height: 260px; overflow: auto; margin: 0 0 12px; }

/* ---------- Photo manager (bin edit) ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-tile { position: relative; border-radius: 11px; overflow: hidden; background: #EEECE6; aspect-ratio: 1; border: 2px solid transparent; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile.is-cover { border-color: var(--accent); }
.photo-tile .cover-tag { position: absolute; left: 6px; top: 6px; }
.photo-tile .tile-actions { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 6px; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.photo-tile .tile-actions button { background: rgba(255,255,255,.92); border: 0; border-radius: 8px; font: 600 .76rem var(--font); padding: 6px 8px; cursor: pointer; color: var(--ink); }
.photo-tile .tile-actions button.danger { color: var(--danger); }
.photo-tile.removing { opacity: .35; }
.photo-tile.pending { border: 2px dashed var(--accent); }
.photo-tile.pending .pending-tag { position: absolute; left: 6px; top: 6px; }
.photo-tile .del-x { position: absolute; right: 6px; top: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(28,28,26,.7); color: #fff; display: grid; place-items: center; cursor: pointer; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 22px 16px; border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: #FBFAF8; cursor: pointer; color: var(--ink-2); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .i { width: 28px; height: 28px; color: var(--accent); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-progress { height: 6px; border-radius: 999px; background: #ECEAE4; overflow: hidden; margin-top: 10px; }
.upload-progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- Bulk bar ---------- */
.bulkbar { position: sticky; bottom: 12px; z-index: 30; margin-top: 14px; background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.bulkbar .count { font-weight: 600; margin-right: auto; padding-left: 4px; }
.bulkbar .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.16); color: #fff; min-height: 38px; }
.bulkbar .btn:hover { background: rgba(255,255,255,.2); }

/* ---------- Empty / auth ---------- */
.empty { text-align: center; padding: 48px 18px; color: var(--muted); }
.empty h1, .empty h2 { color: var(--ink); }
.empty .i { width: 40px; height: 40px; color: #B5B1A6; margin-bottom: 8px; }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; }
.auth-brand .brand-mark svg { width: 30px; height: 30px; }
.auth-brand .name { font-weight: 650; font-size: 1.15rem; letter-spacing: -0.01em; }
.auth-brand .tag { color: var(--muted); font-size: .92rem; }
body.auth-body .page { max-width: none; padding: 0; }

.activity li { font-size: .93rem; }
.activity .when { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.secret { font-family: var(--mono); font-size: 1.05rem; background: var(--warn-soft); padding: 2px 8px; border-radius: 6px; user-select: all; -webkit-user-select: all; }
.danger-zone { border-color: #EFCFC6; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .92rem; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; padding: 6px 0; }
details.more summary::-webkit-details-marker { display: none; }
.show-sm { display: none; }
@media (max-width: 720px) { .show-sm { display: block; } }
@media (max-width: 420px) { .hide-xs { display: none; } .savebar .btn { padding: 0 12px; } }
.page-narrow { margin-left: auto; margin-right: auto; }
