/* ─── Reset & Base ─────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100dvh;
}
a { color: #007aff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ───────────────────────────────────────────────────────────── */

.app { max-width: 1320px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.content { flex: 1; padding: 16px 20px 60px; }

.header {
  background: #fff; padding: 14px 20px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid #e5e5e5;
  position: sticky; top: 0; z-index: 10;
}
.header h1 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.header .meta { font-size: 11px; color: #86868b; }

.tabs { display: flex; gap: 4px; background: #fff; padding: 0 20px; border-bottom: 1px solid #e5e5e5; position: sticky; top: 53px; z-index: 9; }
.tab {
  padding: 10px 14px; font-size: 13px; font-weight: 500; color: #6e6e73;
  border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: #1d1d1f; }
.tab.active { color: #007aff; border-bottom-color: #007aff; }

/* ─── Buttons / inputs ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border: 1px solid #d1d1d6; border-radius: 8px;
  background: #fff; color: #1d1d1f; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.btn:hover { background: #f0f0f2; }
.btn-primary { background: #007aff; color: #fff; border-color: #007aff; }
.btn-primary:hover { background: #0066d6; }
.btn-danger { color: #ff3b30; border-color: #ffc9c6; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

input[type="text"], input[type="number"], select, textarea {
  padding: 7px 10px; border: 1px solid #d1d1d6; border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; color: #1d1d1f;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #007aff33; border-color: #007aff; }

/* ─── Filter bar ───────────────────────────────────────────────────────── */

.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: #fff; padding: 12px; border-radius: 12px; margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.filters .grow { flex: 1; min-width: 160px; }
.filters label { font-size: 12px; color: #6e6e73; display: flex; align-items: center; gap: 5px; }

/* ─── Cards grid ───────────────────────────────────────────────────────── */

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

.card {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); display: flex; flex-direction: column;
  border: 1px solid transparent; cursor: pointer; transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.card.standout { border-color: #ffb020; box-shadow: 0 0 0 1px #ffb020 inset, 0 1px 4px rgba(0,0,0,.06); }

.card-thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: #ececf0; display: block; }
.card-thumb.empty { display: flex; align-items: center; justify-content: center; color: #b0b0b8; font-size: 28px; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-adv { font-size: 12px; font-weight: 600; color: #1d1d1f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-lead { font-size: 12px; line-height: 1.5; color: #3a3a3c; white-space: pre-wrap; max-height: 5.4em; overflow: hidden; }
.card-foot { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: auto; padding-top: 4px; }

/* ─── Badges ───────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-days { background: #eef2ff; color: #3b4cca; }
.badge-days.warm { background: #fff3e0; color: #b45309; }
.badge-days.hot  { background: #ffe8cc; color: #a04000; }
.badge-standout { background: #ffb020; color: #4a2c00; }
.badge-stopped { background: #f1f1f4; color: #86868b; }
.badge-media { background: #f1f1f4; color: #5a5a5f; }
.badge-cta { background: #e7f7ee; color: #1a7f47; }
.badge-tag { background: #f1f1f4; color: #3a3a3c; }

/* ─── Tables ───────────────────────────────────────────────────────────── */

table.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
table.tbl th { background: #f9f9fb; padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; color: #6e6e73; border-bottom: 1px solid #e5e5e5; white-space: nowrap; }
table.tbl td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #f0f0f2; vertical-align: top; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fafafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── Bar (matrix) ─────────────────────────────────────────────────────── */

.bar { height: 8px; border-radius: 4px; background: #007aff; min-width: 2px; }
.bar-wrap { background: #f0f0f2; border-radius: 4px; overflow: hidden; width: 100%; min-width: 60px; }

/* ─── Panels ───────────────────────────────────────────────────────────── */

.panel { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.04); margin-bottom: 14px; }
.panel h2 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.panel .hint { font-size: 12px; color: #6e6e73; line-height: 1.6; margin-bottom: 12px; }

.empty { text-align: center; padding: 48px 20px; color: #86868b; font-size: 13px; line-height: 1.8; }

/* ─── Modal ────────────────────────────────────────────────────────────── */

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 720px; padding: 20px; }
.modal h2 { font-size: 16px; margin-bottom: 12px; }
.modal-row { display: flex; gap: 16px; }
.modal-row img { width: 240px; border-radius: 10px; background: #ececf0; object-fit: cover; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: #6e6e73; white-space: nowrap; }
.kv dd { color: #1d1d1f; word-break: break-all; }
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tagpick button { border: 1px solid #d1d1d6; background: #fff; border-radius: 20px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.tagpick button.on { background: #007aff; color: #fff; border-color: #007aff; }

/* ─── Loading ──────────────────────────────────────────────────────────── */

.loading { display: flex; align-items: center; justify-content: center; min-height: 60dvh; }
.spinner { width: 28px; height: 28px; border: 3px solid #e5e5e5; border-top-color: #007aff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d1d1f; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 200; }

@media (max-width: 640px) {
  .modal-row { flex-direction: column; }
  .modal-row img { width: 100%; }
  .tabs { overflow-x: auto; }
}
