/* ============================================================
   Quick Business Hub — global stylesheet
   Light/dark themes per brand spec. No build process required.
   ============================================================ */

:root {
  --navy: #0B1F3A;
  --blue: #175CD3;
  --teal: #0E9384;
  --gold: #D4A72C;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --card-2: #FFFFFF;
  --text: #172B4D;
  --text-2: #5F6B7A;
  --border: #DDE3EA;
  --shadow: 0 1px 3px rgba(11,31,58,.08), 0 4px 14px rgba(11,31,58,.06);
  --shadow-lg: 0 8px 30px rgba(11,31,58,.16);
  --radius: 14px;
  --header-h: 64px;
  --ok: #12805C; --warn: #B54708; --bad: #B42318; --info: #175CD3;
  --ok-bg: #E6F4EE; --warn-bg: #FDF0E4; --bad-bg: #FBEAE9; --info-bg: #E8F0FD;
}
[data-theme="dark"] {
  --navy: #0B1220;
  --blue: #4C8DFF;
  --teal: #2DD4BF;
  --gold: #F4C95D;
  --bg: #0B1220;
  --card: #111C2E;
  --card-2: #17243A;
  --text: #F7F9FC;
  --text-2: #AAB6C5;
  --border: #223350;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.55);
  --ok: #4ADE9E; --warn: #F3A25B; --bad: #F27C74; --info: #4C8DFF;
  --ok-bg: rgba(74,222,158,.12); --warn-bg: rgba(243,162,91,.12); --bad-bg: rgba(242,124,116,.12); --info-bg: rgba(76,141,255,.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
body {
  margin: 0;
  font-family: 'Inter', 'Manrope', 'Noto Sans', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background .25s, color .25s;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1,h2,h3,h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}.mt-4{margin-top:40px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.right { margin-left: auto; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: var(--card); border-bottom: 1px solid var(--border);
  height: var(--header-h);
  -webkit-backdrop-filter: saturate(1.2) blur(6px);
  backdrop-filter: saturate(1.2) blur(6px);
}
.site-header .container { display: flex; align-items: center; gap: 18px; height: 100%; }
.logo { display: flex; align-items: center; color: var(--text); font-weight: 800; font-size: 1.05rem; }
.logo:hover { text-decoration: none; }
.logo svg { height: 34px; width: auto; }
.main-nav { display: flex; gap: 4px; margin-left: 8px; }
.main-nav a {
  color: var(--text-2); padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: .93rem;
}
.main-nav a:hover, .main-nav a.active { color: var(--blue); background: var(--info-bg); text-decoration: none; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  position: relative; background: none; border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2); font-size: 1.05rem;
}
.icon-btn:hover { border-color: var(--blue); color: var(--blue); }
.badge-dot {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--bad); color: #fff; border-radius: 9px; font-size: .68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.hamburger { display: none; }
@media (max-width: 900px) {
  .main-nav { display: none; position: fixed; inset: var(--header-h) 0 auto 0; background: var(--card);
    flex-direction: column; padding: 12px 20px 20px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); }
  .main-nav.open { display: flex; }
  .hamburger { display: inline-flex; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; font-weight: 600; font-size: .93rem; cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-outline { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-gold { background: var(--gold); color: #1d1503; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 1rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s;
}
.card.hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card h3 { font-size: 1.05rem; }
.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.company-logo {
  width: 54px; height: 54px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card-2); object-fit: contain; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--blue); font-size: 1.2rem;
}
.stat-card { text-align: left; }
.stat-card .num { font-size: 1.7rem; font-weight: 800; color: var(--blue); }
.stat-card .lbl { color: var(--text-2); font-size: .85rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.badge-role-epc { background: var(--info-bg); color: var(--info); }
.badge-role-manufacturer { background: var(--warn-bg); color: var(--warn); }
.badge-role-supplier { background: rgba(14,147,132,.12); color: var(--teal); }
.badge-role-handler { background: rgba(212,167,44,.15); color: var(--gold); }
.badge-role-admin { background: var(--navy); color: #fff; }
[data-theme="dark"] .badge-role-admin { background: var(--card-2); color: var(--gold); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.verified-badge { color: var(--teal); font-weight: 700; font-size: .8rem; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }
.offline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); display: inline-block; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .87rem; margin: 14px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=url], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-size: .93rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--info-bg); }
textarea { min-height: 96px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.field-error { color: var(--bad); font-size: .82rem; margin-top: 4px; }
.checkbox-line { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; font-size: .9rem; margin: 10px 0; }
.checkbox-line input { width: auto; margin-top: 3px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 999px; transition: .18s;
}
.switch .track::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::before { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Permission tree */
.perm-group { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.perm-group > summary {
  cursor: pointer; list-style: none; padding: 12px 16px; font-weight: 700; font-size: .92rem;
  display: flex; align-items: center; gap: 10px; background: var(--card-2);
}
.perm-group > summary::after { content: "▾"; margin-left: auto; color: var(--text-2); transition: transform .15s; }
.perm-group[open] > summary::after { transform: rotate(180deg); }
.perm-items { padding: 8px 16px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 18px; }
.perm-items .checkbox-line { margin: 4px 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
table.data th { background: var(--card-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--info-bg); }

/* ---------- Modal / drawer ---------- */
.overlay-backdrop {
  position: fixed; inset: 0; background: rgba(11,31,58,.5); z-index: 80;
  opacity: 0; transition: opacity .2s;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.overlay-backdrop.show { opacity: 1; }
.modal {
  position: fixed; z-index: 90; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px;
  pointer-events: none;
}
.modal-panel {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; padding: 26px;
  transform: translateY(14px) scale(.98); opacity: 0; transition: transform .2s, opacity .2s;
  pointer-events: auto; position: relative;
}
.modal.show .modal-panel { transform: none; opacity: 1; }
.modal-panel.wide { max-width: 900px; }
.drawer {
  position: fixed; z-index: 90; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--card); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .25s; overflow-y: auto; padding: 26px;
}
.drawer.show { transform: none; }
.drawer.wide { width: min(760px, 100vw); }
.close-x {
  position: absolute; top: 14px; right: 14px; width: 38px; height: 38px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-2);
  border-radius: 10px; font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.drawer .close-x { position: sticky; top: 0; float: right; margin: -6px -6px 0 12px; }
.close-x:hover { color: var(--bad); border-color: var(--bad); }
@media (max-width: 640px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-panel { max-height: 94vh; border-radius: 16px 16px 0 0; }
  .close-x { top: 10px; right: 10px; width: 42px; height: 42px; }
}

/* ---------- Toasts ---------- */
.toast-region { position: fixed; bottom: 20px; right: 20px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--blue);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 12px 40px 12px 16px;
  min-width: 260px; max-width: 380px; font-size: .9rem; position: relative;
  animation: toast-in .25s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }
.toast .close-x { top: 6px; right: 6px; width: 26px; height: 26px; font-size: .85rem; border: none; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Skeletons & empty states ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--card-2) 50%, var(--border) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; min-height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.empty-state { text-align: center; padding: 46px 20px; color: var(--text-2); }
.empty-state .icon { font-size: 2.2rem; margin-bottom: 8px; }

/* ---------- Hero / home ---------- */
.hero {
  background:
    radial-gradient(1000px 400px at 85% -10%, rgba(23,92,211,.25), transparent),
    radial-gradient(700px 300px at 10% 110%, rgba(14,147,132,.18), transparent),
    var(--navy);
  color: #fff; padding: 84px 0 70px;
}
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); max-width: 720px; }
.hero p.lead { font-size: 1.1rem; color: #cfd9e6; max-width: 640px; }
.hero-stats { display: flex; gap: 34px; flex-wrap: wrap; margin-top: 40px; }
.hero-stats .num { font-size: 1.6rem; font-weight: 800; color: var(--gold); }
.hero-stats .lbl { color: #aab6c5; font-size: .85rem; }
.section { padding: 60px 0; }
.section-alt { background: var(--card); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section h2 { font-size: 1.6rem; margin-bottom: 6px; }
.section .sub { color: var(--text-2); margin: 0 0 28px; max-width: 640px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 20px 38px; }
.timeline .dot {
  position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--border); background: var(--card);
}
.timeline li.done .dot { border-color: var(--ok); background: var(--ok); }
.timeline li.current .dot { border-color: var(--blue); }
.timeline li.done, .timeline li.current { color: var(--text); }
.timeline li { color: var(--text-2); }

/* Stage progress bar */
.stage-track { display: flex; gap: 4px; margin: 10px 0; flex-wrap: wrap; }
.stage-track .seg { flex: 1; min-width: 34px; height: 8px; background: var(--border); border-radius: 4px; }
.stage-track .seg.done { background: var(--teal); }
.stage-track .seg.current { background: var(--blue); }

/* ---------- Accordion / FAQ ---------- */
details.faq { border: 1px solid var(--border); border-radius: 12px; padding: 0 18px; margin-bottom: 10px; background: var(--card); }
details.faq summary { cursor: pointer; font-weight: 600; padding: 15px 0; list-style: none; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq[open] { box-shadow: var(--shadow); }
details.faq p { margin-top: 0; color: var(--text-2); }

/* ---------- Filters bar ---------- */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 20px;
}
.filters input, .filters select { width: auto; min-width: 140px; flex: 1; }
.filters input[type=search] { flex: 2; min-width: 180px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin: 26px 0; flex-wrap: wrap; }
.pagination button {
  border: 1px solid var(--border); background: var(--card); color: var(--text); min-width: 38px; height: 38px;
  border-radius: 9px; cursor: pointer; font-weight: 600;
}
.pagination button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination button:disabled { opacity: .45; cursor: default; }

/* ---------- Dashboard layout ---------- */
.dash-layout { display: grid; grid-template-columns: 230px 1fr; gap: 24px; align-items: start; padding: 26px 0 60px; }
.dash-nav { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 3px; }
.dash-nav a {
  padding: 9px 13px; border-radius: 9px; color: var(--text-2); font-weight: 500; font-size: .92rem;
  display: flex; align-items: center; gap: 9px;
}
.dash-nav a.active, .dash-nav a:hover { background: var(--info-bg); color: var(--blue); text-decoration: none; }
@media (max-width: 900px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .dash-nav a { white-space: nowrap; }
}

/* ---------- Profile page ---------- */
.profile-cover {
  height: 200px; border-radius: var(--radius); background: linear-gradient(120deg, var(--navy), var(--blue));
  background-size: cover; background-position: center; position: relative; margin-top: 22px;
}
.profile-head { display: flex; gap: 18px; align-items: flex-end; margin-top: -44px; padding: 0 24px; flex-wrap: wrap; }
.profile-head .company-logo { width: 88px; height: 88px; border-radius: 18px; font-size: 1.7rem; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 22px 0; overflow-x: auto; }
.tabs button {
  background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 16px;
  font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------- Messages ---------- */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); min-height: 560px; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 72vh; }
.chat-item { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.chat-item:hover, .chat-item.active { background: var(--info-bg); }
.chat-main { display: flex; flex-direction: column; max-height: 72vh; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 74%; padding: 10px 14px; border-radius: 14px; font-size: .92rem; }
.bubble.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--card-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .meta { font-size: .72rem; opacity: .75; margin-top: 3px; }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.chat-input textarea { min-height: 44px; max-height: 130px; }
@media (max-width: 800px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list.hide-mobile { display: none; }
}

/* ---------- Notification list ---------- */
.notif-item { display: flex; gap: 13px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-item.unread { background: var(--info-bg); }
.notif-item .t { font-weight: 600; font-size: .92rem; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy); color: #aab6c5; padding: 50px 0 26px; margin-top: 60px; }
[data-theme="dark"] .site-footer { background: var(--card); border-top: 1px solid var(--border); }
.site-footer h4 { color: #fff; font-size: .95rem; }
[data-theme="dark"] .site-footer h4 { color: var(--text); }
.site-footer a { color: #aab6c5; display: block; padding: 3px 0; font-size: .9rem; }
.site-footer a:hover { color: var(--gold); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 34px; padding-top: 18px; font-size: .84rem; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Utility ---------- */
.divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--info-bg); color: var(--blue);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none;
}
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; font-size: .92rem; }
.kv dt { color: var(--text-2); font-weight: 500; }
.kv dd { margin: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 8px; } }
.progress { height: 9px; border-radius: 5px; background: var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--blue)); border-radius: 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
