/* OptiVision — application stylesheet (original light theme)
   Structure: tokens, base, layout (sidebar/topbar), components, modules, responsive, print. */

/* ---------------------------------------------------------------- Tokens */
:root {
  --sidebar-w: 248px;
  --topbar-h: 48px;

  --surface: rgba(255, 255, 255, .86);
  --surface-2: #f3f7fd;
  --surface-3: #eaf2ff;
  --border: #dfe8f5;
  --border-strong: #d8e3f3;
  --text: #18325b;
  --text-2: #415c81;
  --muted: #647997;
  --faint: #8a9fba;

  --primary: #2f6ae6;
  --primary-hover: #2457c9;
  --primary-soft: #eaf2ff;
  --primary-text: #2d61d1;
  --primary-grad: linear-gradient(100deg, #4778ff, #2965df);
  --ring: 0 0 0 3px rgba(56, 108, 243, .16);

  --success: #2a9f87; --success-soft: #e1f6ed; --success-text: #268262;
  --warning: #c88a28; --warning-soft: #fff1d6; --warning-text: #98621d;
  --danger: #c43c5c;  --danger-soft: #fce6ec;  --danger-text: #ad3e59;
  --info: #3b70e9;    --info-soft: #e5efff;    --info-text: #3f6fc3;
  --violet: #8a56dd;  --violet-soft: #eee7ff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 21px;
  --shadow-sm: 0 12px 35px #456ba310;
  --shadow: 0 14px 38px #456ba31c;
  --shadow-lg: 0 18px 50px #12335b2e;
  --font: Inter, "Segoe UI", Arial, sans-serif;
}

/* ---------------------------------------------------------------- Base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; font: 14px/1.55 var(--font); color: var(--text); background: linear-gradient(125deg, #eff6ff, #e4effe 50%, #f2f7ff); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.8px; }
h2 { font-size: 17px; line-height: 1.4; font-weight: 700; letter-spacing: -.3px; }
h3 { font-size: 15px; font-weight: 700; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
img, svg { display: block; }
small { font-size: 12px; }
:focus-visible { outline: 3px solid #4e85fa; outline-offset: 3px; }
.icon { width: 21px; height: 21px; flex: none; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link:focus { position: fixed; z-index: 200; top: 8px; left: 8px; padding: 12px; background: #fff; border-radius: 10px; }
.muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.danger-text { color: #b52b48; }
.success-text { color: var(--success-text); }
.mt { margin-top: 22px; }
.mt-sm { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Thin, quiet scrollbars across the app */
* { scrollbar-width: thin; scrollbar-color: #c3d3ea transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8d6ec; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #a3b8d8; }

/* ---------------------------------------------------------------- App shell */
.app { min-height: 100vh; }
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; padding: 24px 28px 10px; transition: margin-left .2s; min-width: 0; }
.content { flex: 1; width: 100%; min-width: 0; }
.app-footer { display: flex; justify-content: space-between; gap: 15px; padding: 24px 3px 12px; font-size: 11px; color: #7990af; }

/* ---------------------------------------------------------------- Sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 100; width: var(--sidebar-w);
  display: flex; flex-direction: column; padding: 26px 17px 18px;
  background: #f9fcffeb; border-right: 1px solid #fff; box-shadow: 6px 0 35px #426c9e0a;
  overflow-y: auto; overflow-x: hidden; transition: width .2s, transform .2s;
  scrollbar-width: thin; scrollbar-color: transparent transparent;
}
.sidebar:hover { scrollbar-color: #c3d3ea transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border: 0; border-radius: 6px; }
.sidebar:hover::-webkit-scrollbar-thumb { background: #c8d6ec; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #9fb4d6; }
.brand-wrap { height: 85px; display: flex; align-items: center; justify-content: center; flex: none; }
.brand-img { width: 156px; max-height: 80px; object-fit: contain; }
.nav-caption { font-size: 9px; letter-spacing: 2px; color: #8a9fba; padding: 8px 20px; margin: 12px 0 9px; }
.nav-menu { display: flex; flex-direction: column; gap: 7px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 49px; padding: 7px 12px;
  border: 0; border-radius: 15px; background: transparent; text-align: left;
  font-size: 13px; color: #496485; white-space: nowrap; flex: none; transition: background .15s;
}
.nav-item:hover { background: #eaf2ff; color: #496485; }
.nav-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: #eaf2ff; color: #3769bb; flex: none; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item.active { background: linear-gradient(100deg, #5475fc, #2771e5); color: #fff; box-shadow: 0 7px 16px #386cf333; font-weight: 600; }
.nav-item.active .nav-icon { background: #ffffff29; color: #fff; }
.nav-caret { width: 16px; height: 16px; color: #8a9fba; transition: transform .2s; }
.nav-item.active .nav-caret { color: #fff; }
.nav-group.open > .nav-toggle .nav-caret { transform: rotate(180deg); }

.nav-sub { display: none; flex-direction: column; gap: 2px; margin: 6px 0 4px 29px; padding-left: 16px; border-left: 2px solid #dfe8f5; }
.nav-group.open > .nav-sub { display: flex; animation: sub-in .18s ease; }
@keyframes sub-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.nav-sub-title { display: none; }
.nav-sublink { position: relative; display: block; padding: 8px 12px; border-radius: 10px; font-size: 12.5px; color: #5d7699; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sublink:hover { background: #eaf2ff; color: #2d61d1; }
.nav-sublink.active { background: #e3edff; color: #2d61d1; font-weight: 600; }
.nav-sublink.active::before { content: ""; position: absolute; left: -18px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: #386cf3; }

.sidebar-toggle { margin: 18px 0 15px; background: transparent; border: 0; color: #6d84a2; display: flex; align-items: center; gap: 18px; min-height: 40px; padding: 10px 18px; font-size: 11px; white-space: nowrap; flex: none; }
.sidebar-toggle .icon { transition: transform .2s; }
.sidebar-promo { margin-top: auto; position: relative; min-height: 144px; height: 144px; border-radius: 19px; overflow: hidden; flex-shrink: 0; }
.sidebar-promo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-promo span { position: absolute; inset: 0; padding: 20px; background: linear-gradient(90deg, #edf6fff2, transparent); font-weight: 700; color: #28538a; font-size: 14px; }
.sidebar-backdrop { display: none; }
.sidebar .mobile-close, .topbar .mobile-menu-btn { display: none; }

/* Collapsed (icon-only) sidebar on desktop: submenus open as a hover flyout */
.sidebar-collapsed { --sidebar-w: 86px; }
.sidebar-collapsed .sidebar { padding-inline: 12px; overflow: visible; }
.sidebar-collapsed .brand-img { width: 64px; }
.sidebar-collapsed .nav-caption, .sidebar-collapsed .sidebar-promo, .sidebar-collapsed .nav-caret { display: none; }
.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.sidebar-collapsed .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sidebar-collapsed .sidebar-toggle { justify-content: center; padding: 10px; margin-top: 22px; }
.sidebar-collapsed .sidebar-toggle .icon { transform: rotate(180deg); }
.sidebar-collapsed .nav-menu { margin-top: 34px; }
.sidebar-collapsed .nav-group { position: relative; }
.sidebar-collapsed .nav-group > .nav-sub,
.sidebar-collapsed .nav-group.open > .nav-sub {
  display: none; position: absolute; left: calc(100% + 12px); top: 0; z-index: 120; min-width: 210px;
  margin: 0; padding: 8px; border: 1px solid #fff; border-radius: 16px; background: #fff; box-shadow: var(--shadow-lg);
}
.sidebar-collapsed .nav-group:hover > .nav-sub,
.sidebar-collapsed .nav-group:focus-within > .nav-sub { display: flex; }
.sidebar-collapsed .nav-group > .nav-sub::before { content: ""; position: absolute; left: -14px; top: 0; width: 14px; height: 100%; }
.sidebar-collapsed .nav-sub-title { display: block; padding: 6px 12px 8px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #8a9fba; }
.sidebar-collapsed .nav-sublink.active::before { display: none; }

/* ---------------------------------------------------------------- Topbar */
.topbar { display: flex; align-items: center; gap: 20px; justify-content: space-between; margin-bottom: 28px; min-height: 48px; }
.search-box { display: flex; align-items: center; gap: 5px; flex: 1; max-width: 485px; min-width: 150px; padding: 3px 4px 3px 15px; background: #fff9; border: 1px solid #fff; border-radius: 14px; }
.search-box:focus-within { background: #fff; box-shadow: var(--ring); }
.search-box input { width: 100%; min-width: 0; height: auto; padding: 8px 0; border: 0; outline: 0; box-shadow: none; background: transparent; font-size: 12px; color: var(--text); }
.search-box .icon-btn { border: 0; background: transparent; width: 34px; height: 34px; }
.top-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.top-actions form { margin: 0; }
.date-pill { font-size: 11px; display: flex; align-items: center; gap: 8px; color: #627ca1; }
.date-pill .icon { width: 17px; }
.profile { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.avatar { width: 39px; height: 39px; flex: none; display: grid; place-items: center; border: 2px solid #fff; border-radius: 50%; background: linear-gradient(135deg, #7396d1, #274c82); color: #fff; font-weight: 700; font-size: 13px; }
.avatar.lg { width: 58px; height: 58px; font-size: 19px; }
.avatar.soft { background: #eaf2ff; color: #3769bb; }
.profile-copy { display: flex; flex-direction: column; max-width: 155px; }
.profile-copy strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-copy small { font-size: 10px; color: #7286a2; }
.logout-btn { color: #6984aa; }

/* ---------------------------------------------------------------- Page header */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-title p { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 17px; border: 1px solid #dce6f5; border-radius: 11px;
  background: #f2f6fe; color: #365e9c; font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, filter .15s;
}
.btn:hover { background: #e6efff; color: #2d5592; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary-grad); border-color: transparent; color: #fff; box-shadow: 0 7px 16px #386cf326; }
.btn-primary:hover { background: var(--primary-grad); color: #fff; filter: brightness(.95); }
.btn-success { background: linear-gradient(100deg, #2fb58f, #1f9474); border-color: transparent; color: #fff; box-shadow: 0 7px 16px #2a9f8726; }
.btn-success:hover { background: linear-gradient(100deg, #2fb58f, #1f9474); color: #fff; filter: brightness(.95); }
.btn-danger { background: #fff0f2; border-color: #f3cdd7; color: #ad2948; }
.btn-danger:hover { background: #fde4e9; color: #ad2948; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12px; border-radius: 10px; }
.btn-lg { min-height: 50px; padding: 0 20px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 1px solid #dfe8f5; border-radius: 12px; background: #fff; color: #486a9d; flex: none; }
.icon-btn:hover { background: #eaf2ff; }
.icon-action { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #5d7699; }
.icon-action .icon { width: 17px; height: 17px; }
.icon-action:hover { background: var(--surface-3); color: var(--text); }
.icon-action.danger:hover { background: var(--danger-soft); color: var(--danger-text); }
.icon-action.success:hover { background: var(--success-soft); color: var(--success-text); }
.inline-form { display: inline-flex; margin: 0; }
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--primary); font-weight: 600; font-size: 13px; }
.link-btn:hover { color: var(--primary-hover); text-decoration: underline; }

/* ---------------------------------------------------------------- Cards */
.card { background: var(--surface); border: 1px solid #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 20px 24px 16px; border-bottom: 1px solid #e7edf6; }
.card-header p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-header .icon-title { display: flex; align-items: center; gap: 10px; }
.card-header .icon-title > .icon { color: var(--muted); }
.card-body { padding: 22px 24px; }
.card-footer { padding: 14px 24px; border-top: 1px solid #e7edf6; background: #f6f9fe; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-link { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.card-link .icon { width: 15px; height: 15px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.layout-side-main { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.form-narrow { max-width: 860px; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 20px); }

/* ---------------------------------------------------------------- Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 15px; margin-bottom: 22px; }
.stat { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px; color: inherit; }
a.stat:hover { box-shadow: var(--shadow); color: inherit; transform: translateY(-1px); }
.stat-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.stat-icon .icon { width: 20px; height: 20px; }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.violet { background: var(--violet-soft); color: var(--violet); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-body { min-width: 0; display: flex; flex-direction: column; }
.stat-body > span { display: block; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 21px; font-weight: 700; letter-spacing: -.6px; line-height: 1.3; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-meta { color: #7591b2; font-size: 11px; margin-top: 2px; }

/* ---------------------------------------------------------------- Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 9px; border-radius: 8px; font-size: 11px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge.success { background: var(--success-soft); color: var(--success-text); }
.badge.warning { background: var(--warning-soft); color: var(--warning-text); }
.badge.danger { background: var(--danger-soft); color: var(--danger-text); }
.badge.info { background: var(--info-soft); color: var(--info-text); }
.badge.primary { background: var(--primary-soft); color: var(--primary-text); }
.badge.neutral { background: #edf0f5; color: #7a8799; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.up { background: var(--success-soft); color: var(--success-text); }
.chip.down { background: var(--danger-soft); color: var(--danger-text); }

/* ---------------------------------------------------------------- Alerts */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 20px; border: 1px solid; border-radius: var(--radius); font-size: 13.5px; overflow-wrap: anywhere; }
.alert > .icon { margin-top: 1px; }
.alert > span { flex: 1; }
.alert.success { background: #edfaf4; border-color: #c2e9d9; color: #216949; }
.alert.danger { background: #fff1f3; border-color: #f2cbd6; color: #a32943; }
.alert.warning { background: #fff8e7; border-color: #f3e0af; color: #8c641e; }
.alert.info { background: #ecf4ff; border-color: #c9defe; color: #285eaa; }
.alert-close { display: grid; place-items: center; width: 24px; height: 24px; margin: -2px -4px -2px 0; border: 0; border-radius: 6px; background: transparent; color: inherit; opacity: .7; }
.alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }
.alert-close .icon { width: 15px; height: 15px; }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: #f3f8ff; border: 1px dashed #c9d9f1; color: var(--muted); font-size: 13px; }
.note .icon { width: 17px; height: 17px; margin-top: 1px; }

/* ---------------------------------------------------------------- Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: 12px; font-weight: 600; color: #415c81; }
.req { color: var(--danger); font-weight: 700; }
.hint { color: var(--muted); font-size: 12.5px; }
:where(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea) {
  width: 100%; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid #d8e3f3; border-radius: 9px;
  background: #fafdff; color: var(--text); font-size: 13px; outline: 0; transition: border-color .15s, box-shadow .15s;
}
:where(textarea) { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
:where(select) { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; background-size: 15px; }
:where(input, select, textarea):hover { border-color: #bfd0ea; }
:where(input, select, textarea):focus { border-color: #4e85fa; background: #fff; box-shadow: var(--ring); }
:where(input[readonly]) { background: #eaf0f8; color: #6a7e9e; }
input::placeholder, textarea::placeholder { color: #9aaac0; }
.form-section { padding: 22px 24px; border-bottom: 1px solid #e7edf6; }
.form-section:last-child { border-bottom: 0; }
.form-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.form-section-title p { color: var(--muted); font-size: 12.5px; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 24px; border-top: 1px solid #e7edf6; background: #f6f9fe; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.form-actions .spacer { flex: 1; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.input-icon input { padding-left: 36px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }

/* ---------------------------------------------------------------- Toolbar, tabs */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 24px; border-bottom: 1px solid #e7edf6; }
.toolbar .input-icon { flex: 1 1 240px; max-width: 360px; }
.toolbar select, .toolbar input[type=date] { width: auto; min-width: 140px; height: 38px; font-size: 13px; }
.toolbar .input-icon input { height: 38px; font-size: 13px; }
.toolbar .btn { min-height: 38px; }
.toolbar-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid #e7edf6; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 15px 10px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: #2d61d1; border-bottom-color: #386cf3; }
.tab-count { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11.5px; }
.tab.active .tab-count { background: var(--primary-soft); color: var(--primary-text); }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { padding: 12px 16px; text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: #6880a0; background: #f3f7fd; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid #e7edf6; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:not(.empty-row):hover td { background: #f9fbff; }
th.num, td.num { text-align: right; }
th.actions, td.actions { text-align: right; width: 1%; white-space: nowrap; }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-main .avatar { width: 34px; height: 34px; font-size: 12px; }
.cell-title { font-weight: 600; color: var(--text); }
a.cell-title:hover { color: var(--primary); }
.cell-sub { display: block; color: #8797af; font-size: 11px; margin-top: 3px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 24px; border-top: 1px solid #e7edf6; color: var(--muted); font-size: 12px; }
.pager { display: flex; gap: 4px; }
.pager-btn { min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border: 1px solid #dce6f5; border-radius: 10px; background: #f2f6fe; color: #365e9c; font-weight: 600; font-size: 13px; }
.pager-btn .icon { width: 15px; height: 15px; }
a.pager-btn:hover { background: var(--surface-3); color: var(--text); }
.pager-btn.current { background: var(--primary-grad); border-color: transparent; color: #fff; }
.pager-btn.disabled { opacity: .45; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 16px; color: var(--muted); text-align: center; font-size: 13.5px; }
.empty-state .icon { width: 30px; height: 30px; color: #b5c6e0; }
tfoot td { font-weight: 700; background: #f3f7fd; border-top: 1px solid #dfe8f5; }

/* ---------------------------------------------------------------- Detail lists */
.detail-list { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px 16px; margin: 0; font-size: 13.5px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head h2 { font-size: 17px; }
.info-lines { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; font-size: 13.5px; }
.info-lines div { display: flex; align-items: flex-start; gap: 10px; color: var(--text-2); overflow-wrap: anywhere; }
.info-lines .icon { width: 16px; height: 16px; color: var(--faint); margin-top: 2px; }
.summary-rows { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.summary-rows > div { display: flex; justify-content: space-between; gap: 12px; }
.summary-rows > div span { color: var(--muted); }
.summary-rows > div strong { font-variant-numeric: tabular-nums; }
.summary-rows .total { padding-top: 12px; margin-top: 2px; border-top: 1px dashed #c9d9f1; font-size: 16px; }
.summary-rows .total span { color: var(--text); font-weight: 650; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--success); }

/* Status steps (orders) */
.steps { display: flex; align-items: center; gap: 0; padding: 18px 20px; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 130px; color: var(--faint); font-size: 13px; font-weight: 600; }
.step-dot { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--border-strong); background: #fff; color: var(--faint); font-size: 12px; }
.step-dot .icon { width: 14px; height: 14px; }
.step::after { content: ""; flex: 1; height: 2px; margin: 0 10px; background: var(--border); border-radius: 2px; }
.step:last-child { flex: none; }
.step:last-child::after { display: none; }
.step.done { color: var(--text-2); }
.step.done .step-dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.done::after { background: var(--success); }
.step.current { color: var(--primary-text); }
.step.current .step-dot { border-color: #386cf3; color: #386cf3; box-shadow: var(--ring); }

/* ---------------------------------------------------------------- Dashboard */
.eyebrow { font-size: 10px; letter-spacing: 2.4px; font-weight: 700; color: #6480a8; margin-bottom: 10px; }
.hero-card { display: grid; grid-template-columns: 1.1fr 1fr; overflow: hidden; min-height: 207px; margin-bottom: 22px; }
.hero-card > div { padding: 29px; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; }
.hero-card h1 { font-size: 34px; margin: 0 0 10px; overflow-wrap: anywhere; }
.hero-card p:not(.eyebrow) { font-size: 12.5px; color: var(--muted); margin-bottom: 18px; }
.hero-card img { height: 100%; width: 100%; object-fit: cover; min-width: 0; }
.collection-card { position: relative; overflow: hidden; min-height: 220px; padding: 24px; background: linear-gradient(130deg, #fff, #deedff); }
.collection-card h2 { font-size: 23px; line-height: 1.3; position: relative; z-index: 1; }
.collection-card img { position: absolute; right: -15px; bottom: 30px; width: 58%; height: 100px; object-fit: cover; border-radius: 16px; }
.collection-card .btn { position: relative; margin-top: 70px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.chart { display: flex; align-items: flex-end; gap: 12px; height: 230px; padding: 20px 20px 14px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; min-width: 0; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { position: relative; width: min(46px, 70%); min-height: 3px; border-radius: 8px 8px 3px 3px; background: linear-gradient(#83b4ff, #4577f1); }
.chart-bar.zero { background: #e3ecfb; }
.chart-bar span { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.chart-col small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.chart-col.today small { color: #2d61d1; font-weight: 700; }
.list-items { list-style: none; margin: 0; padding: 0; }
.list-items li { border-bottom: 1px solid #e7edf6; }
.list-items li:last-child { border-bottom: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 24px; color: inherit; }
a.list-item:hover { background: #f9fbff; color: inherit; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-body strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-body small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-tile { width: 42px; flex: none; display: flex; flex-direction: column; align-items: center; padding: 4px 0; border-radius: 9px; background: var(--primary-soft); color: var(--primary-text); line-height: 1.15; }
.date-tile b { font-size: 15px; }
.date-tile small { font-size: 10px; font-weight: 700; text-transform: uppercase; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 18px 24px 24px; }
.quick-action { display: flex; flex-direction: column; gap: 9px; padding: 15px 12px; border-radius: 13px; background: #f2f6ff; color: #3a67b2; font-size: 12px; font-weight: 600; transition: background .15s; }
.quick-action:hover { background: #e5eeff; color: #2d5592; }
.quick-action .icon { width: 21px; height: 21px; color: #3769bb; }

/* ---------------------------------------------------------------- POS */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.scan-bar { position: relative; display: flex; gap: 10px; padding: 20px 24px; border-bottom: 1px solid #d4e3ff; background: linear-gradient(115deg, #edf4ff, #f8fbff); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.scan-input { flex: 1; position: relative; }
.scan-input > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: #386cf3; pointer-events: none; }
.scan-input input { height: 50px; padding-left: 44px; font-size: 15px; background: #fff; border-radius: 13px; }
.scan-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; max-height: 320px; overflow-y: auto; margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid #dfe8f5; border-radius: 14px; box-shadow: var(--shadow-lg); }
.scan-results[hidden] { display: none; }
.scan-results li button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: left; }
.scan-results li button:hover, .scan-results li button.active { background: var(--primary-soft); }
.scan-results .r-body { flex: 1; min-width: 0; }
.scan-results .r-body strong { display: block; font-size: 13.5px; font-weight: 600; }
.scan-results .r-body small { color: var(--muted); }
.scan-results .r-price { font-weight: 700; font-size: 13px; white-space: nowrap; }
.scan-results .r-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.scan-status { display: flex; align-items: center; gap: 8px; padding: 10px 24px; font-size: 12px; color: #466b9e; background: #f6f9fe; border-bottom: 1px solid #e7edf6; }
.scan-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.scan-status.error { color: var(--danger-text); background: var(--danger-soft); }
.scan-status.error::before { background: var(--danger); }
.cart-table td { padding-top: 10px; padding-bottom: 10px; }
.qty { display: inline-flex; align-items: center; border: 1px solid #d8e3f3; border-radius: 10px; overflow: hidden; background: #fff; }
.qty button { width: 32px; height: 34px; display: grid; place-items: center; border: 0; background: #f2f6fe; color: #365e9c; }
.qty button:hover { background: var(--surface-3); }
.qty button .icon { width: 14px; height: 14px; }
.qty input { width: 54px !important; height: 34px !important; border: 0 !important; border-radius: 0 !important; text-align: center; padding: 0 4px !important; box-shadow: none !important; font-weight: 600; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cart-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 20px; color: var(--muted); text-align: center; }
.cart-empty .icon { width: 40px; height: 40px; color: #b5c6e0; }
.cart-empty strong { color: var(--text-2); font-size: 15px; }
.checkout .card-body { display: flex; flex-direction: column; gap: 16px; }
.grand-total { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 16px 18px; border-radius: 15px; background: linear-gradient(100deg, #5475fc, #2771e5); color: #fff; box-shadow: 0 7px 16px #386cf333; }
.grand-total span { color: #dbe7ff; font-size: 13px; font-weight: 600; }
.grand-total output { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pay-methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.change-box { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--success-soft); color: var(--success-text); font-weight: 650; }
.change-box output { font-size: 17px; font-variant-numeric: tabular-nums; }
.kbd-hint { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.kbd-hint kbd { font: 600 11px var(--font); padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--text-2); }

/* ---------------------------------------------------------------- Order lines */
.line-table td { padding: 10px 8px; vertical-align: top; }
.line-table td:first-child { padding-left: 20px; }
.line-table td:last-child { padding-right: 20px; }
.line-table th:first-child { padding-left: 20px; }
.line-table input, .line-table select { height: 38px; font-size: 13.5px; }
.line-table output { display: block; padding-top: 9px; font-weight: 650; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.line-table .col-product { min-width: 200px; }
.line-table .col-desc { min-width: 200px; }
.line-table .col-qty { width: 92px; }
.line-table .col-price { width: 140px; }
.line-table .col-total { width: 130px; }

/* ---------------------------------------------------------------- Invoice / receipt */
.document { width: 100%; max-width: 880px; margin: 0 auto; padding: 36px 40px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 24px; border-bottom: 1px solid #dfe8f5; }
.doc-logo { width: 150px; height: auto; margin: -10px 0 6px -8px; }
.doc-store h2 { font-size: 17px; }
.doc-store p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.doc-meta { text-align: right; }
.doc-meta .doc-type { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.doc-meta h1 { font-size: 24px; margin: 4px 0; }
.doc-meta p { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.doc-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: 22px 0; }
.doc-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.doc-parties strong { font-size: 15px; }
.doc-parties p { color: var(--muted); font-size: 13px; }
.doc-table { border: 1px solid #dfe8f5; border-radius: 12px; overflow: hidden; }
.doc-totals { display: flex; justify-content: flex-end; padding-top: 18px; }
.doc-totals .summary-rows { width: min(320px, 100%); }
.doc-notes { margin-top: 22px; padding: 14px 16px; background: #f3f7fd; border-radius: 12px; font-size: 13px; color: var(--text-2); }
.doc-foot { margin-top: 28px; padding-top: 18px; border-top: 1px solid #dfe8f5; text-align: center; color: var(--muted); font-size: 12.5px; }
.stamp { display: inline-block; padding: 4px 12px; border: 2px solid currentColor; border-radius: 8px; font-weight: 800; font-size: 13px; letter-spacing: .12em; }
.stamp.success { color: var(--success); }
.stamp.warning { color: var(--warning); }
.stamp.danger { color: var(--danger); }

/* ---------------------------------------------------------------- Barcode labels */
.label-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.barcode-label { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 10px; background: #fff; border: 1px dashed #aabbcf; border-radius: 8px; text-align: center; break-inside: avoid; }
.barcode-label strong { font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barcode-label svg { max-width: 100%; height: auto; }
.barcode-label span { font-size: 12.5px; font-weight: 700; }

/* ---------------------------------------------------------------- Search & misc */
.result-list { display: flex; flex-direction: column; }
.result-list a { display: flex; align-items: center; gap: 12px; padding: 13px 24px; border-bottom: 1px solid #e7edf6; color: inherit; }
.result-list a:last-child { border-bottom: 0; }
.result-list a:hover { background: #fafbfd; }
.result-list .icon-wrap { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--primary-soft); color: var(--primary); flex: none; }
.result-list .icon-wrap .icon { width: 17px; height: 17px; }
.result-list > a > .icon { color: var(--faint); width: 16px; height: 16px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 12px; align-items: center; padding: 12px 24px; border-bottom: 1px solid #e7edf6; font-size: 13.5px; }
.bar-row:last-child { border-bottom: 0; }
.bar-row .progress { margin-top: 6px; }
.bar-row .progress > span { background: linear-gradient(90deg, #83b4ff, #4577f1); }
details.inline-details summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 13px; list-style: none; }
details.inline-details summary::-webkit-details-marker { display: none; }
details.inline-details[open] { padding: 14px; margin-top: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }

/* ---------------------------------------------------------------- Message pages */
.message-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.message-card { width: min(540px, 100%); padding: 40px; text-align: center; }
.message-logo { width: 180px; height: 100px; object-fit: contain; margin: 0 auto 20px; }
.message-card .code { font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--muted); }
.message-card h1 { margin: 6px 0 8px; }
.message-card p { color: var(--muted); margin-bottom: 22px; }

/* ---------------------------------------------------------------- Responsive */
@media (min-width: 1600px) { .content { max-width: 1700px; } }
@media (max-width: 1400px) {
  .app-main { padding-inline: 22px; }
  .date-pill { display: none; }
  .dash-grid { grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; }
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 1120px) {
  :root { --sidebar-w: 218px; }
  .dash-grid, .pos, .layout-main-side, .layout-side-main { grid-template-columns: minmax(0, 1fr); }
  .sticky-side { position: static; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .profile-copy { display: none; }
  .app-main { padding-inline: 18px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .hero-card h1 { font-size: 29px; }
}
@media (max-width: 720px) {
  :root, body.sidebar-collapsed { --sidebar-w: 0px; }
  .sidebar, .sidebar-collapsed .sidebar { width: 270px; padding: 18px; transform: translateX(-100%); box-shadow: none; background: #f8fbff; overflow-y: auto; }
  .sidebar-open .sidebar { transform: translateX(0); box-shadow: 15px 0 70px #12335b33; }
  .sidebar-open { overflow: hidden; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 99; background: #12335b66; border: 0; }
  .sidebar .mobile-close, .topbar .mobile-menu-btn { display: inline-grid; }
  .brand-wrap { height: 80px; justify-content: space-between; }
  .brand-img, .sidebar-collapsed .brand-img { width: 150px; }
  /* the collapsed desktop state must not leak into the mobile drawer */
  .sidebar-collapsed .nav-menu { margin-top: 0; }
  .sidebar-collapsed .nav-caption, .sidebar-collapsed .nav-caret { display: block; }
  .sidebar-collapsed .nav-label { position: static; width: auto; height: auto; clip: auto; overflow: hidden; }
  .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 7px 12px; }
  .sidebar-collapsed .nav-group > .nav-sub { position: static; display: none; min-width: 0; margin: 6px 0 4px 29px; padding: 0 0 0 16px; border: 0; border-left: 2px solid #dfe8f5; border-radius: 0; background: none; box-shadow: none; }
  .sidebar-collapsed .nav-group.open > .nav-sub { display: flex; }
  .sidebar-collapsed .nav-sub-title { display: none; }
  .sidebar-toggle, .sidebar-collapsed .sidebar-toggle { display: none; }
  .sidebar-promo, .sidebar-collapsed .sidebar-promo { display: block; margin-top: 25px; min-height: 130px; height: 130px; }
  .app-main { padding: 16px 14px 8px; }
  .topbar { gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
  .top-actions { margin-left: auto; gap: 10px; }
  .search-box { order: 3; max-width: none; flex-basis: 100%; }
  .date-pill { display: flex; font-size: 10px; }
  .app-footer { flex-direction: column; gap: 4px; font-size: 10px; }
  h1 { font-size: 24px; }
  .page-header { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
  .page-actions .btn { flex: 1; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .card { border-radius: 17px; }
  .card-header, .card-body, .form-section, .toolbar, .form-actions, .table-footer, .list-item, .result-list a, .bar-row { padding-left: 16px; padding-right: 16px; }
  .toolbar .input-icon { max-width: none; }
  .toolbar select, .toolbar input[type=date] { flex: 1; min-width: 0; }
  th, td { padding-left: 12px; padding-right: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { flex-direction: column; gap: 10px; padding: 16px; }
  .stat-value { font-size: 17px; }
  .hero-card > div { padding: 23px; }
  .hero-card h1 { font-size: 28px; }
  .document { padding: 22px 16px; }
  .doc-meta { text-align: left; }
  .doc-parties { grid-template-columns: minmax(0, 1fr); }
  .detail-list { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .detail-list dd { margin-bottom: 10px; }
  .scan-bar { flex-direction: column; }
  .chart { gap: 6px; padding-inline: 10px; }
  .chart-bar span { display: none; }
}
@media (max-width: 450px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-card > img { display: none; }
  .date-pill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- Print */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .sidebar-backdrop, .topbar, .app-footer, .page-header, .no-print, .alert, .skip-link { display: none !important; }
  .app-main { margin: 0 !important; padding: 0; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; background: #fff; }
  .document { padding: 0; max-width: none; }
  .print-only { display: block !important; }
  .printing-labels .content > *:not(.label-sheet) { display: none !important; }
  .printing-labels .label-sheet { grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .printing-labels .barcode-label { border: 1px dashed #bbb; }
  a { color: inherit; }
}
.print-only { display: none; }
.mono .muted { font-family: var(--font); font-size: 12px; }
