/* Signage Store — light/dark theming via CSS variables on <html data-theme>. */
:root, [data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #d8dce2;
  --primary: #c8102e;          /* retail red */
  --primary-text: #ffffff;
  --ok-bg: #e7f6ec;  --ok-text: #14683a;
  --err-bg: #fdeaea; --err-text: #a11a1a;
  --warn-bg: #fff4e0; --warn-text: #8a5a00;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1e2127;
  --surface-2: #282c34;
  --text: #e6e8eb;
  --muted: #9aa1ab;
  --border: #363b44;
  --primary: #e5324e;
  --primary-text: #ffffff;
  --ok-bg: #143223;  --ok-text: #6fd39a;
  --err-bg: #3a1a1a; --err-text: #f08a8a;
  --warn-bg: #38290e; --warn-text: #e8b45c;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* ---- nav ---- */
.topnav {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .6rem 1rem; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.navlinks { display: flex; gap: .25rem; }
.navlinks a {
  text-decoration: none; padding: .35rem .7rem; border-radius: 6px; color: var(--muted);
}
.navlinks a:hover { background: var(--surface-2); color: var(--text); }
.navlinks a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.navright { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.navright a { text-decoration: none; color: var(--muted); }
.navright a:hover { color: var(--text); }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: var(--text); text-decoration: underline; }

/* ---- flash ---- */
.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-err { background: var(--err-bg); color: var(--err-text); }

/* ---- buttons & inputs ---- */
.btn {
  display: inline-block; padding: .45rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { filter: brightness(1.1); background: var(--primary); }
.btn-danger { border-color: var(--err-text); color: var(--err-text); background: transparent; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: .2rem .55rem; font-size: .85rem; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"],
select, textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
label { display: block; margin-bottom: .8rem; font-weight: 600; font-size: .9rem; }
label input, label select, label textarea { margin-top: .25rem; font-weight: 400; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.opt { color: var(--muted); font-weight: 400; }
.hint { display: block; color: var(--muted); font-weight: 400; font-size: .82rem; margin-top: .25rem; }

/* ---- auth ---- */
.auth-card {
  max-width: 380px; margin: 8vh auto 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem; box-shadow: var(--shadow); text-align: center;
}
.auth-card form { text-align: left; margin-top: 1.25rem; }
.auth-card .btn { width: 100%; margin-top: .5rem; }
.auth-card h1 { margin-bottom: .25rem; }

/* ---- search ---- */
.searchbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .9rem; }
.searchbar input[type="search"] { flex: 1 1 260px; }
.searchbar select { width: auto; }
.result-count { margin: .25rem 0 .9rem; font-size: .88rem; }

.tagcloud { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.tag {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  font-size: .82rem; text-decoration: none; cursor: pointer; color: var(--text);
}
.tag:hover { border-color: var(--primary); }
.tag-active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.tag-n { color: var(--muted); font-size: .75rem; }
.tag-active .tag-n { color: var(--primary-text); opacity: .8; }
.tag-sm { font-size: .75rem; padding: .05rem .45rem; }
.tag-suggest { font: inherit; font-size: .82rem; }
.tag-suggest:disabled { opacity: .45; cursor: default; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem;
}
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; text-decoration: none; box-shadow: var(--shadow);
  transition: transform .1s ease, border-color .1s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--primary); }
.card-thumb {
  aspect-ratio: 4 / 3; background: var(--surface-2); display: flex;
  align-items: center; justify-content: center; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.card-body { padding: .65rem .8rem .8rem; display: flex; flex-direction: column; gap: .35rem; }
.card-title {
  font-weight: 600; font-size: .92rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; }
.card-tags { display: flex; flex-wrap: wrap; gap: .3rem; }

.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: .75rem;
  background: var(--surface-2); border: 1px solid var(--border); width: fit-content;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.badge-err { background: var(--err-bg); color: var(--err-text); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }

.pager { display: flex; gap: .35rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.page {
  padding: .25rem .65rem; border: 1px solid var(--border); border-radius: 6px;
  text-decoration: none; background: var(--surface);
}
.page.current { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.empty { text-align: center; color: var(--muted); padding: 3rem 0; }

/* ---- forms/cards ---- */
.form-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.25rem; box-shadow: var(--shadow); max-width: 640px; margin-bottom: 1.25rem;
}
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row label { flex: 1 1 160px; }
.form-row .btn { align-self: end; margin-bottom: .8rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 420px)); gap: 1.25rem; }
.settings-grid .form-card { margin-bottom: 0; }

/* ---- detail ---- */
.detail { display: grid; grid-template-columns: minmax(260px, 420px) 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 800px) { .detail { grid-template-columns: 1fr; } }
.detail-preview img {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; background: #fff;
  box-shadow: var(--shadow);
}
.detail-actions { display: flex; gap: .5rem; margin: .75rem 0; }
.meta-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.meta-table th { text-align: left; color: var(--muted); font-weight: 500; padding: .3rem .6rem .3rem 0; white-space: nowrap; vertical-align: top; }
.meta-table td { padding: .3rem 0; word-break: break-word; }
.suggest { margin: -.4rem 0 .8rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.suggest .hint { width: 100%; margin: 0 0 .2rem; }

/* ---- tables ---- */
.data-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.data-table th, .data-table td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--surface-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table select { width: auto; padding: .2rem .4rem; font-size: .85rem; }
.data-table .actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: .4rem; align-items: center; }
.inline-form input { width: auto; min-width: 160px; }
.reset-pw summary { cursor: pointer; font-size: .85rem; color: var(--muted); list-style: none; }
.reset-pw summary:hover { color: var(--text); text-decoration: underline; }
.reset-form { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; flex-wrap: wrap; }
.reset-form input[type="text"] { width: 150px; }
