/* ============================================================
   AdsVine Design System — base components
   Brand palette defaults; overridden at runtime by Settings → Branding.
   ============================================================ */

:root {
    --navy: #123B72;
    --blue: #1677D2;
    --green: #18B878;
    --green-bright: #35C96B;
    --bg: #F7FAFC;
    --white: #FFFFFF;
    --text: #142033;
    --muted: #667085;
    --line: #E4ECF3;
    --line-strong: #CBD8E4;
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --warn: #D97706;
    --warn-bg: #FFFBEB;
    --info: #0E7490;
    --info-bg: #ECFEFF;
    --ok: #18B878;
    --ok-bg: #E7F8F0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(20, 32, 51, .05);
    --shadow: 0 4px 16px rgba(20, 32, 51, .07);
    --shadow-lg: 0 18px 44px rgba(9, 27, 60, .16);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 { margin: 0 0 .4em; color: var(--navy); line-height: 1.25; font-weight: 700; }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 17px; } h4 { font-size: 15px; }
p { margin: 0 0 1em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code { font-family: var(--mono); background: #EEF4FA; padding: 2px 6px; border-radius: 5px; font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; line-height: 1.2;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(.93); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { filter: brightness(1.12); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(.94); }
.btn-outline { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--navy); background: rgba(18,59,114,.05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 14px 26px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
label .req { color: var(--danger); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-control, select.form-control, textarea.form-control {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,119,210,.14); }
textarea.form-control { min-height: 110px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.form-check input { margin-top: 3px; }
.form-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; }
input[type="checkbox"].switch { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
input[type="checkbox"].switch:checked { background: var(--green); }
input[type="checkbox"].switch::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .15s; box-shadow: var(--shadow-sm); }
input[type="checkbox"].switch:checked::after { left: 21px; }

/* ---------------- Cards ---------------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-body { padding: 20px; }

/* ---------------- Stat cards ---------------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--blue); }
.stat-card.green::before { background: var(--green); }
.stat-card.navy::before { background: var(--navy); }
.stat-card.muted::before { background: var(--line-strong); }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 750; color: var(--navy); margin-top: 4px; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------------- Badges & alerts ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.badge-success { background: var(--ok-bg); color: #0B7A4E; }
.badge-warning { background: var(--warn-bg); color: #92400E; }
.badge-danger { background: var(--danger-bg); color: #991B1B; }
.badge-info { background: var(--info-bg); color: #0E7490; }
.badge-muted { background: #EEF2F6; color: var(--muted); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; border: 1px solid transparent; line-height: 1.5; }
.alert-success { background: var(--ok-bg); color: #0B7A4E; border-color: #BEEBD6; }
.alert-error, .alert-danger { background: var(--danger-bg); color: #991B1B; border-color: #FECACA; }
.alert-warning { background: var(--warn-bg); color: #92400E; border-color: #FDE68A; }
.alert-info { background: var(--info-bg); color: #0E7490; border-color: #A5F3FC; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.table th {
    text-align: left; padding: 11px 14px; font-size: 11.5px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); background: #F9FBFD;
    border-bottom: 1px solid var(--line); white-space: nowrap; font-weight: 700;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFCFE; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }
.table tfoot td { font-weight: 700; background: #F9FBFD; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 6px; align-items: center; margin: 16px 0 0; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
    font-size: 13.5px; color: var(--navy); font-weight: 600;
}
.pagination .current { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination a:hover { border-color: var(--blue); text-decoration: none; }
.pagination .disabled { color: var(--line-strong); pointer-events: none; }

/* ---------------- Misc ---------------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }
.empty-state h3 { color: var(--navy); }
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .form-group { margin: 0; min-width: 150px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: .92em; }
.mt-1{margin-top:6px}.mt-2{margin-top:12px}.mt-3{margin-top:18px}.mt-4{margin-top:24px}
.mb-1{margin-bottom:6px}.mb-2{margin-bottom:12px}.mb-3{margin-bottom:18px}.mb-4{margin-bottom:24px}
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.copy-box { display: flex; gap: 8px; align-items: center; background: #0E2E5C; color: #8FE6BC; border-radius: var(--radius-sm); padding: 10px 14px; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.copy-box button { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 12px; font-family: var(--font); }

/* Definition rows (detail views) */
.dl { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; font-size: 13.5px; }
.dl dt { color: var(--muted); font-weight: 600; margin: 0; }
.dl dd { margin: 0; }

/* Modal + confirm */
.modal-backdrop { position: fixed; inset: 0; background: rgba(9,27,60,.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-close { background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; }

/* Toasts */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast { padding: 12px 16px; border-radius: 10px; color: #fff; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: slideIn .25s ease; line-height: 1.45; }
.toast-success { background: #0F9D63; }
.toast-error { background: #DC2626; }
.toast-warning { background: #D97706; }
.toast-info { background: var(--blue); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 16px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a:hover { color: var(--navy); text-decoration: none; }
.tabs a.active { color: var(--blue); border-color: var(--blue); }

/* Avatar */
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--navy)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }

@media (max-width: 720px) {
    .form-row, .form-row-3, .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .dl { grid-template-columns: 1fr; gap: 2px 0; }
    .dl dt { margin-top: 10px; }
    h1 { font-size: 22px; }
}
