:root {
  --bg: #f3f6fa;
  --card: #fff;
  --ink: #152033;
  --muted: #5b6b82;
  --line: #e2e8f0;
  --brand: #0f4c81;
  --brand-2: #1663a8;
  --ok: #0f7a4a;
  --danger: #b42318;
  --warn: #b45309;
  --shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
  --radius: 14px;
  --sidebar: 240px;
  --topbar: 56px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
img {
  max-width: 100%;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f4c81, #1b6ca8);
}
.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.brand h1,
.page-head h1 {
  margin: 0;
  font-size: 1.35rem;
}
.brand p {
  margin: 0;
  color: var(--muted);
}

.logo-old {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  vertical-align: middle;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar);
  background: #0f4c81;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
}
.topbar a,
.topbar .link {
  color: #fff;
}
.brand-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #fff;
}
.brand-mini .logo {
  width: 32px;
  height: 32px;
  background: #fff;
  color: var(--brand);
  border-top-left-radius: 35%;
  border-bottom-right-radius: 35%;
}
.topbar-user {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.9rem;
}
.nav-toggle {
  background: transparent;
  color: #fff;
  border: 0;
  font-size: 1.3rem;
  padding: 6px 8px;
}
.sidebar {
  position: fixed;
  inset: var(--topbar) auto 0 0;
  width: min(var(--sidebar), 86vw);
  background: #10243d;
  color: #d7e6f5;
  padding: 16px 12px;
  transform: translateX(-105%);
  transition: transform 0.2s ease;
  z-index: 30;
  overflow: auto;
}
.sidebar.open {
  transform: translateX(0);
}
.sidebar-brand {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar a {
  color: #d7e6f5;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
}
.sidebar a.active,
.sidebar a:hover {
  background: #1a3b61;
  text-decoration: none;
}
.main {
  padding: 16px 14px 48px;
  max-width: 1100px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-tight label,
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
}
input,
select,
textarea {
  font: inherit;
  padding: 12px 12px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  background: #fff;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #b9d4ee;
  border-color: var(--brand);
}
.hint,
.muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-ghost {
  background: #eaf2fb;
  border-color: transparent;
  color: var(--brand);
}
.btn-block {
  width: 100%;
}
.btn-lg {
  padding: 14px;
  font-size: 1.05rem;
}
.btn:disabled {
  opacity: 0.5;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.alert-success {
  background: #e8f7ee;
  color: #0b5e38;
}
.alert-error {
  background: #fde8e6;
  color: #8a1c14;
}

.seg {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  gap: 8px;
}
.seg-opt {
  flex: 1;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #f7fafc;
  border-radius: 8px;
}
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.pill,
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8eef5;
  font-size: 0.8rem;
  font-weight: 650;
}
.pill-ok {
  background: #d9f2e4;
  color: var(--ok);
}
.pill-off {
  background: #fde8e6;
  color: var(--danger);
}
.ok-badge {
  background: #d9f2e4;
}
.ok {
  color: var(--ok);
  font-weight: 700;
}
.bad {
  color: var(--danger);
  font-weight: 700;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--line);
}
.stat span {
  color: var(--muted);
  font-size: 0.85rem;
}
.stat strong {
  display: block;
  font-size: 1.4rem;
}
.stat.warn {
  border-color: #f3d19e;
}
.stat.danger {
  border-color: #f2b4ae;
}
.grid-2 {
  display: grid;
  gap: 14px;
}

.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.filters {
  display: grid;
  gap: 8px;
}
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  margin-bottom: 12px;
}
.tabs a {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.tabs a.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  text-decoration: none;
}
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pager {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pager a {
  padding: 6px 10px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.pager a.active {
  background: var(--brand);
  color: #fff;
}
.thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.thumbs img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
}
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-weight: 500;
}
.user-row {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}
.plain {
  margin: 0;
  padding-left: 18px;
}
.section-title {
  margin: 22px 0 10px;
  font-size: 1.05rem;
}
.previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.previews img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}
.tpl-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }
  .sidebar {
    transform: none;
  }
  .has-sidebar .main {
    margin-left: var(--sidebar);
    padding: 24px;
  }
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-stats {
    grid-template-columns: repeat(5, 1fr);
  }
  .filters {
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
    align-items: end;
  }
}

/* ---------- Quick Add form (mobile/tablet first) ---------- */
.qa-hero {
  margin: 4px 0 14px;
}
.qa-hero h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}
.qa-hero p {
  margin: 0 0 10px;
  color: var(--muted);
}
.qa-form {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qa-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.qa-optional {
  background: #fafcfe;
  border-style: dashed;
  box-shadow: none;
}
.qa-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
}
.qa-section-label small {
  font-weight: 400;
  color: var(--muted);
}
.qa-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
}
.qa-dot-soft {
  background: #cfdcec;
  color: #35516f;
}
.qa-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.qa-label {
  font-size: 0.9rem;
  font-weight: 650;
  color: #24344d;
}
.qa-label i {
  color: var(--danger);
  font-style: normal;
}
.qa-form input,
.qa-form select,
.qa-form textarea {
  font-size: 1rem;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #d3dce8;
  width: 100%;
}
.qa-form textarea {
  min-height: 76px;
  resize: vertical;
}
.qa-form input:focus,
.qa-form select:focus,
.qa-form textarea:focus {
  outline: 3px solid #cfe2f6;
  border-color: var(--brand);
}
.qa-cats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.qa-cat {
  position: relative;
  display: block !important;
}
.qa-cat input {
  position: absolute;
  opacity: 0;
  inset: 0;
  min-height: 0;
  cursor: pointer;
}
.qa-cat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 1.5px solid #d3dce8;
  border-radius: 14px;
  background: #f7fafc;
  font-weight: 650;
  font-size: 0.9rem;
  text-align: center;
  transition: 0.15s;
}
.qa-cat-box b {
  font-size: 1.35rem;
}
.qa-cat input:checked + .qa-cat-box {
  border-color: var(--brand);
  background: #e8f1fb;
  color: var(--brand);
  box-shadow: 0 0 0 3px #cfe2f6;
}
.qa-cat input:focus-visible + .qa-cat-box {
  outline: 3px solid #cfe2f6;
}
.qa-phone {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 8px;
}
.qa-submit {
  position: sticky;
  bottom: 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.qa-submit .btn {
  min-height: 54px;
  border-radius: 14px;
  font-size: 1.1rem;
}
@media (min-width: 700px) {
  .qa-card {
    padding: 24px;
  }
  .qa-hero h1 {
    font-size: 1.9rem;
  }
}

/* ---------- shared bits for new admin pieces ---------- */
.btn-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
}
.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #f2b4ae;
}
.btn-danger:hover {
  background: #fde8e6;
}
.row-actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
}
.pager-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 20px;
}
.pager-info {
  color: var(--muted);
  font-size: 0.9rem;
}
.pager-size label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.9rem;
}
.pager-size select {
  padding: 6px 8px;
}
.log-filters {
  grid-template-columns: 1fr;
  align-items: end;
}
.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.thumb-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}
.thumb-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.folder-active {
  border-color: var(--ok);
  background: #f2fbf6;
}
code {
  background: #eef3f9;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.85em;
  word-break: break-all;
}
@media (min-width: 900px) {
  .log-filters {
    grid-template-columns: 1fr 1fr 1.5fr auto auto auto;
  }
}

/* ---------- customer export ---------- */
.export-card { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.export-card > strong { flex: 1 0 100%; }
.export-card label { flex: 1 1 150px; }
.export-card .hint { flex: 1 0 100%; }
