/* Same look as the other internal tools (sellcenter KOL Info / zktime-report):
   gradient header bar, white rounded cards on a light-gray page. */

:root {
  --brand: #2a62b8;
  --brand-dark: #1d4688;
  --page-bg: #eef1f6;
  --card-bg: #ffffff;
  --border: #e4e8f0;
  --text: #202433;
  --text-muted: #767d8c;
  --radius: 14px;
  --ok-bg: #e0f5ec; --ok-text: #0d6b49;
  --warn-bg: #fff4d6; --warn-text: #6b4a00;
  --err-bg: #fdecea; --err-text: #9b2c1f;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans Thai", "Leelawadee UI", Arial, sans-serif;
  color: var(--text);
  background: var(--page-bg);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.pad { padding: 16px 18px; }
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Header bar ---- */
.header-bar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.title-group { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; color: #fff; }
.title-group:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.tabs a {
  color: rgba(255, 255, 255, .88);
  padding: 7px 14px; border-radius: 20px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
}
.tabs a:hover { background: rgba(255, 255, 255, .14); text-decoration: none; }
.tabs a.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who { font-weight: 600; white-space: nowrap; }
.logout-link { color: #fff; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .16); }
.logout-link:hover { background: rgba(255, 255, 255, .3); text-decoration: none; }
.banner { padding: 10px 24px; font-weight: 600; }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); border-bottom: 1px solid #f3dc9b; }

/* ---- Page ---- */
.page { padding: 20px 24px 8px; flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 2px 2px 16px; }
.page-head h1 { font-size: 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-width: 0; overflow-wrap: anywhere; }
.page-head h1 small { font-size: 13px; font-weight: 400; }
.back { color: var(--text-muted); font-size: 16px; }
.page-foot { text-align: center; color: var(--text-muted); font-size: 12.5px; padding: 6px 16px 22px; }

/* ---- Card ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(20, 30, 60, .06);
  overflow: hidden;
  margin-bottom: 18px;
}
.card-head {
  background: #f8f9fc;
  border-left: 3px solid var(--brand);
  border-bottom: 1px solid var(--border);
  padding: 11px 18px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px;
}
.card-head h2 { color: var(--brand-dark); font-size: 13px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }

/* ---- Alerts ---- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.alert > i { margin-top: 3px; }
.alert.ok { background: var(--ok-bg); color: var(--ok-text); }
.alert.warn { background: var(--warn-bg); color: var(--warn-text); }
.alert.error { background: var(--err-bg); color: var(--err-text); }
.form .alert { margin-bottom: 4px; }

/* ---- Toolbar, inputs ---- */
.toolbar { padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin: 0; border-bottom: 1px solid var(--border); }
input[type=text], input[type=search] {
  font: inherit; color: var(--text);
  border: 1px solid #cfd6e2; border-radius: 10px; padding: 8px 11px; background: #fff;
  min-height: 40px; width: 100%;
}
input[type=text]:focus, input[type=search]:focus { outline: 2px solid rgba(42, 98, 184, .3); border-color: var(--brand); }
input[readonly] { background: #f6f8fb; }
.search { position: relative; display: inline-flex; align-items: center; flex: 0 1 340px; }
.search i { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.search input { padding-left: 34px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef1f8; color: var(--text); border-radius: 20px; padding: 5px 13px; font-weight: 600; font-size: 13px; }
.chip:hover { text-decoration: none; background: #e3e9f4; }
.chip.active { background: var(--brand); color: #fff; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 7px 15px; border-radius: 10px;
  background: #fff; border: 1px solid #cfd6e2; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f4f7fb; }
.btn small { font-weight: 400; color: var(--text-muted); }
.btn.icon { width: 40px; padding: 0; flex: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary small { color: rgba(255, 255, 255, .8); }
.btn.ghost { border-color: transparent; background: #eef1f8; }
.btn.danger { color: var(--err-text); border-color: #efc2bb; }
.btn.danger:hover { background: var(--err-bg); }
.btn.copied { color: var(--ok-text); border-color: #9fd8bf; }

/* ---- Pills ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 11px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.on { background: var(--ok-bg); color: var(--ok-text); }
.pill.off { background: #eceef2; color: #5b6170; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th {
  background: #eef2f9; color: #495057; font-size: 12px; font-weight: 700; text-align: left;
  border-bottom: 2px solid var(--border); padding: 9px 12px; white-space: nowrap; vertical-align: bottom;
}
table.data th.r { text-align: right; }
table.data th small { display: block; font-weight: 500; color: var(--text-muted); font-size: 11px; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: #f8faff; }
table.links tr.off td { color: var(--text-muted); }
table.links tr.off img { opacity: .4; }
.qr-cell { width: 76px; }
.qr-cell img { display: block; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.link-name { font-weight: 700; font-size: 15px; color: var(--text); overflow-wrap: anywhere; }
.short { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
td.target { max-width: 340px; }
td.target, td.target a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.target a { display: block; }
.empty { text-align: center; padding: 46px 20px; }
.empty > i { font-size: 40px; color: #b7c0cf; margin-bottom: 10px; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-card { max-width: 720px; }
.form-card .form { padding: 20px 22px 22px; }
.field-row { display: flex; flex-direction: column; gap: 5px; }
.field-row > span:first-child { font-weight: 700; }
.field-row > span:first-child small { font-weight: 400; margin-left: 4px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
details.custom-code summary { cursor: pointer; color: var(--brand); font-weight: 600; margin-bottom: 8px; }
.code-input { display: flex; align-items: stretch; }
.code-input .prefix {
  display: inline-flex; align-items: center; padding: 0 10px; background: #f1f4f9; color: var(--text-muted);
  border: 1px solid #cfd6e2; border-right: none; border-radius: 10px 0 0 10px; font-size: 13px; white-space: nowrap;
  max-width: 70%; overflow: hidden; text-overflow: ellipsis;
}
.code-input .prefix { flex: none; }
.code-input input { border-radius: 0 10px 10px 0; min-width: 0; flex: 1; }

/* ---- One link ---- */
.link-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0 18px; align-items: start; }
.qr-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.qr-preview { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.qr-preview img { display: block; width: 100%; height: auto; }
.off-qr .qr-preview img { opacity: .35; }
.short-url { display: flex; gap: 6px; }
.short-url input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qr-card p { margin: 0; }
.meta { margin: 0; }
.toggle-zone { border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.toggle-zone form { margin: 0; }

/* scans per day */
.scan-sum { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding: 26px 18px 0; }
.bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar span { display: block; width: 100%; max-width: 26px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.zero span { background: #dfe4ee; }
.bar b { position: absolute; font-size: 11px; color: var(--brand-dark); transform: translateY(-100%); padding-bottom: 2px; }
.bar-labels { display: flex; gap: 3px; padding: 4px 18px 14px; }
.bar-labels span { flex: 1; min-width: 0; text-align: center; font-size: 10.5px; color: var(--text-muted); white-space: nowrap; overflow: visible; }

/* ---- Login & public pages ---- */
.login-body, .public-body { min-height: 100vh; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); display: flex; }
.login-wrap { margin: auto; padding: 24px 16px; width: 100%; max-width: 440px; }
.login-card, .public-card { background: #fff; border-radius: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .22); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-head { display: flex; gap: 14px; align-items: center; }
.login-logo { width: 56px; height: 56px; }
.login-head h1 { font-size: 22px; }
.login-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.login-btn { min-height: 48px; font-size: 16px; border-radius: 12px; }
.login-note { margin: 0; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.login-msg { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #eef5fb; color: #24425a; line-height: 1.5; }
.login-msg.warn { background: var(--warn-bg); color: #5c4300; }
.login-msg > i { margin-top: 3px; }
.public-card { margin: auto; width: calc(100% - 32px); max-width: 400px; align-items: center; text-align: center; }
.public-card img { width: 64px; height: 64px; }
.public-card h1 { font-size: 21px; }
.public-card p { margin: 0; color: var(--text-muted); }

@media (max-width: 860px) {
  .link-grid { grid-template-columns: minmax(0, 1fr); }
  .qr-card .qr-preview { max-width: 300px; margin: 0 auto; width: 100%; }
}
@media (max-width: 640px) {
  .header-bar { padding: 10px 16px; }
  .page { padding: 16px 16px 8px; }
  .banner { padding: 10px 16px; }
  .search { flex-basis: 100%; }
  .hide-sm { display: none; }
  td.target { max-width: 180px; }
}
