:root {
    --primary: #1a66b3;
    --primary-dark: #12376a;
    --primary-soft: #e8f1fa;
    --danger: #d92d3a;
    --danger-soft: #fdecef;
    --success: #1f9d55;
    --success-soft: #e5f6ec;
    --warning-soft: #fff6e0;
    --text: #1d2939;
    --muted: #667085;
    --border: #e4e7ec;
    --bg: #f4f6fa;
    --card: #ffffff;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; color: #101828; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ---------- Topbar ---------- */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar .container { display: flex; align-items: center; height: 60px; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--primary-dark); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 8px; background: var(--primary);
    color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }

.user-menu { position: relative; }
.user-menu > button {
    display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--border);
    border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; font: inherit; color: var(--text);
}
.avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--primary-dark); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.user-menu .dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; min-width: 200px;
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(16,24,40,.12); padding: 6px;
}
.user-menu.open .dropdown { display: block; }
.dropdown a, .dropdown button {
    display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; border: 0; background: none;
    color: var(--text); font: inherit; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--bg); text-decoration: none; }
.dropdown .meta { padding: 8px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

main.container { padding-top: 24px; padding-bottom: 60px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px; }
.card-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 80px; }
@media (max-width: 980px) {
    .grid-2, .grid-3, .layout-side { grid-template-columns: 1fr; }
    .nav { display: none; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #155492; }
.btn-dark { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-dark:hover { background: #0d2a52; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #f6c7cc; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 5px 8px; }
.btn-link { border: 0; background: none; color: var(--primary); padding: 0; font-weight: 500; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.inline { display: inline; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
label, .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: #344054; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.input, select.input, textarea.input {
    width: 100%; padding: 9px 12px; border: 1px solid #d0d5dd; border-radius: 8px; font: inherit; color: var(--text);
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 102, 179, .15); }
textarea.input { min-height: 90px; resize: vertical; }
.input.is-invalid { border-color: var(--danger); }
.error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.input-lg { font-size: 16px; padding: 11px 14px; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 0; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* Toggle switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.switch:last-child { border-bottom: 0; }
.switch .text strong { display: block; font-size: 14px; }
.switch .text span { color: var(--muted); font-size: 12px; }
.toggle { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; inset: 0; background: #d0d5dd; border-radius: 999px; cursor: pointer; transition: .2s; }
.toggle .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(18px); }
.sub-settings { padding: 4px 0 12px 0; }
.sub-settings.hidden { display: none; }

/* Segmented radio */
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid #d0d5dd; border-radius: 8px; overflow: hidden; }
.segmented label { margin: 0; }
.segmented input { display: none; }
.segmented span { display: block; padding: 7px 12px; cursor: pointer; font-weight: 500; border-right: 1px solid #d0d5dd; background: #fff; }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--primary); color: #fff; }

/* Logo picker */
.logo-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.logo-option { margin: 0; cursor: pointer; }
.logo-option input { display: none; }
.logo-option .box {
    border: 2px solid var(--border); border-radius: 10px; padding: 8px; text-align: center; background: #fff; height: 100%;
    display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; transition: .15s;
}
.logo-option .box img { max-width: 100%; height: 48px; object-fit: contain; }
.logo-option .box .none { height: 48px; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.logo-option .box small { font-weight: 500; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.logo-option input:checked + .box { border-color: var(--primary); background: var(--primary-soft); }
.logo-option input:checked + .box small { color: var(--primary); }

/* Color fields */
.color-field { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.color-field:last-child { border-bottom: 0; }
.color-field .name { flex: 1; font-weight: 500; }
.color-field input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; cursor: pointer; }
.color-field input[type=text] { width: 100px; font-family: Consolas, monospace; text-transform: lowercase; }

.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.08); display: inline-block; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfcfe; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions > * { margin-left: 4px; }
.thumb { width: 56px; height: 56px; border-radius: 8px; border: 1px solid var(--border); object-fit: contain; background: #fff; display: block; }
.thumb-empty { width: 56px; height: 56px; border-radius: 8px; border: 1px dashed #d0d5dd; display: grid; place-items: center; color: #98a2b3; font-size: 11px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, monospace; }
.nowrap { white-space: nowrap; }
.price-tag { display: inline-block; background: var(--danger-soft); color: #c4202e; font-weight: 700; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.chip { display: inline-block; background: var(--primary-soft); color: var(--primary-dark); padding: 2px 8px; border-radius: 6px; font-size: 12px; margin: 2px 2px 2px 0; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-gray { background: #f2f4f7; color: #475467; }
.badge-amber { background: var(--warning-soft); color: #b54708; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.alert-success { background: var(--success-soft); border-color: #b7e4c7; color: #146c3a; }
.alert-error { background: var(--danger-soft); border-color: #f6c7cc; color: #a3151f; }
.alert-info { background: var(--primary-soft); border-color: #c5dbf1; color: var(--primary-dark); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .icon { font-size: 40px; margin-bottom: 8px; }
.empty h3 { color: var(--text); }

/* ---------- Meta list ---------- */
.meta-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.meta-list > div { padding: 14px 18px; border-right: 1px solid var(--border); }
.meta-list > div:last-child { border-right: 0; }
.meta-list .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.meta-list .v { font-weight: 600; margin-top: 2px; }
@media (max-width: 980px) { .meta-list { grid-template-columns: 1fr 1fr; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 12px; }
.tabs button {
    border: 0; background: none; padding: 12px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.pdf-frame { width: 100%; height: 900px; border: 0; display: block; background: #525659; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Product cards on list page ---------- */
.list-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.list-card { display: flex; flex-direction: column; }
.list-card .lc-head { padding: 14px 16px; border-bottom: 3px solid var(--line, var(--primary)); display: flex; align-items: center; gap: 10px; min-height: 72px; }
.list-card .lc-head img { height: 34px; max-width: 70px; object-fit: contain; }
.list-card .lc-title { flex: 1; text-align: center; font-weight: 700; color: var(--title, var(--primary-dark)); font-size: 15px; }
.list-card .lc-body { padding: 12px 16px; flex: 1; font-size: 13px; }
.list-card .lc-body .row { display: flex; justify-content: space-between; padding: 3px 0; }
.list-card .lc-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Logos page ---------- */
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.logo-card .preview { height: 120px; display: grid; place-items: center; padding: 16px; border-bottom: 1px solid var(--border);
    background: repeating-conic-gradient(#f4f6fa 0% 25%, #fff 0% 50%) 50% / 16px 16px; border-radius: var(--radius) var(--radius) 0 0; }
.logo-card .preview img { max-width: 100%; max-height: 88px; object-fit: contain; }
.logo-card .body { padding: 12px; }

/* ---------- Image upload ---------- */
.upload-box { border: 2px dashed #d0d5dd; border-radius: var(--radius); padding: 16px; text-align: center; background: #fafbfc; }
.upload-box img { max-width: 100%; max-height: 220px; object-fit: contain; display: block; margin: 0 auto 12px; }
.upload-box .placeholder { color: #98a2b3; padding: 30px 0; }

/* Extra fields */
.extra-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; }

/* ---------- Template mock (preview) ---------- */
.mock { background: color-mix(in srgb, var(--box) 28%, #fff); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 10px; }
.mock-head { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; gap: 8px; padding-bottom: 6px; border-bottom: 1.5px solid var(--line); }
.mock-logo { height: 30px; display: flex; align-items: center; }
.mock-logo.r { justify-content: flex-end; }
.mock-logo img { max-height: 30px; max-width: 70px; object-fit: contain; }
.mock-logo .ph { width: 54px; height: 24px; border: 1px dashed #c0c7d2; border-radius: 4px; display: grid; place-items: center; color: #98a2b3; font-size: 9px; }
.mock-title { text-align: center; font-weight: 800; color: var(--title); font-size: 12px; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mock-date { text-align: center; font-weight: 700; color: var(--code); font-size: 8px; margin-top: 2px; }
.mock-sub { display: flex; justify-content: space-between; align-items: center; font-size: 7px; color: var(--code); margin-top: 5px; }
.mock-pn { background: var(--box); padding: 0 5px; font-weight: 700; }
.mock-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.mock-card { background: #fff; border: 1px solid color-mix(in srgb, var(--line) 14%, #fff); border-bottom-width: 2px; border-radius: 6px; padding: 5px; display: flex; flex-direction: column; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.mock-name { background: var(--box); color: var(--title); font-weight: 800; font-size: 8px; text-align: center; padding: 3px 4px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mock-code { color: var(--code); font-size: 7px; text-align: center; margin-top: 3px; }
.mock-img { height: 38px; background: #eef1f5; margin: 4px 10px; border-radius: 3px; }
.mock-price { background: var(--pbox); color: var(--ptext); font-weight: 800; text-align: center; padding: 4px; margin-top: auto; font-size: 10px; border-radius: 4px; }
.mock-info { background: var(--info); color: var(--infotext); margin-top: 8px; padding: 6px 8px; border-radius: 6px; font-size: 8px; font-weight: 700; text-align: center; text-transform: uppercase; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(circle at 20% 20%, #dbe8f6 0, transparent 40%), radial-gradient(circle at 80% 80%, #fbe3e6 0, transparent 40%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: 20px; font-size: 20px; }
.auth-card .brand-mark { width: 44px; height: 44px; font-size: 18px; }

/* ---------- Pagination (bootstrap-5 markup) ---------- */
nav .pagination, ul.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.pagination .page-link { display: block; padding: 6px 11px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); }
.pagination .active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled .page-link { color: #c0c7d2; }
nav[role=navigation] .small.text-muted, nav .d-sm-none { display: none; }
nav .d-none.d-sm-flex > div:first-child { display: none; }

/* ---------- Log changes ---------- */
.changes { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12px; }
.changes li { padding: 2px 0; }
.changes .old { color: #a3151f; text-decoration: line-through; background: var(--danger-soft); padding: 0 4px; border-radius: 3px; }
.changes .new { color: #146c3a; background: var(--success-soft); padding: 0 4px; border-radius: 3px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 160px; }
