:root {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --surface-strong: #ecf6f4;
  --text: #132927;
  --muted: #6b7f7c;
  --line: #dfe9e7;
  --line-strong: #cbdad7;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #d9f5f0;
  --accent: #f59e0b;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --shadow-sm: 0 1px 2px rgba(13, 52, 48, .05), 0 1px 6px rgba(13, 52, 48, .04);
  --shadow: 0 12px 36px rgba(15, 70, 65, .10);
  --shadow-lg: 0 24px 70px rgba(8, 48, 44, .18);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar: 256px;
  --topbar: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bfd0cd; border-radius: 99px; }

.boot-screen {
  min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px;
  background:
    radial-gradient(circle at 20% 20%, rgba(45, 212, 191, .15), transparent 30%),
    radial-gradient(circle at 80% 80%, rgba(14, 165, 233, .10), transparent 32%),
    var(--bg);
}
.boot-title { font-size: 26px; font-weight: 800; letter-spacing: -.04em; }
.boot-subtitle { color: var(--muted); }
.loader-line { width: 168px; height: 4px; overflow: hidden; border-radius: 99px; background: var(--line); margin-top: 4px; }
.loader-line i { display: block; width: 45%; height: 100%; border-radius: inherit; background: var(--primary); animation: loading 1.15s infinite ease-in-out; }
@keyframes loading { 0% { transform: translateX(-110%); } 100% { transform: translateX(330%); } }

.brand-mark {
  position: relative; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 14px; background: var(--primary);
  box-shadow: 0 8px 18px rgba(15, 118, 110, .23); overflow: visible;
}
.brand-mark::before { content: ""; position: absolute; width: 25px; height: 25px; border: 3px solid #fff; border-radius: 50%; left: 7px; top: 10px; }
.brand-mark::after { content: ""; position: absolute; width: 12px; height: 7px; border-radius: 100% 0 100% 0; background: #99f6e4; left: 15px; top: 21px; transform: rotate(15deg); }
.brand-mark span { position: absolute; display: block; border-radius: 50%; background: #99f6e4; }
.brand-mark span:nth-child(1) { width: 8px; height: 8px; left: 5px; top: -4px; }
.brand-mark span:nth-child(2) { width: 6px; height: 6px; left: 19px; top: -8px; }
.brand-mark span:nth-child(3) { width: 7px; height: 7px; right: 4px; top: -2px; }
.brand-mark-lg { width: 72px; height: 72px; border-radius: 23px; }
.brand-mark-lg::before { width: 43px; height: 43px; left: 12px; top: 17px; border-width: 5px; }
.brand-mark-lg::after { width: 22px; height: 12px; left: 25px; top: 37px; }
.brand-mark-lg span:nth-child(1) { width: 13px; height: 13px; left: 8px; top: -6px; }
.brand-mark-lg span:nth-child(2) { width: 10px; height: 10px; left: 33px; top: -12px; }
.brand-mark-lg span:nth-child(3) { width: 12px; height: 12px; right: 6px; top: -4px; }

.login-shell {
  min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(420px, 560px);
  background: var(--surface);
}
.login-visual {
  padding: clamp(36px, 6vw, 96px); display: flex; flex-direction: column; justify-content: space-between;
  background:
    linear-gradient(135deg, rgba(6, 78, 72, .97), rgba(15, 118, 110, .90)),
    radial-gradient(circle at 20% 10%, #5eead4, transparent 30%);
  color: white; position: relative; overflow: hidden;
}
.login-visual::before, .login-visual::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.login-visual::before { width: 420px; height: 420px; right: -170px; top: -80px; }
.login-visual::after { width: 620px; height: 620px; left: -300px; bottom: -360px; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; }
.login-brand .brand-mark { background: white; }
.login-brand .brand-mark::before { border-color: var(--primary); }
.login-brand-name { font-size: 24px; font-weight: 850; letter-spacing: -.04em; }
.login-hero { position: relative; z-index: 1; max-width: 620px; }
.login-hero h1 { margin: 0 0 18px; font-size: clamp(38px, 5vw, 68px); line-height: 1.03; letter-spacing: -.055em; }
.login-hero p { margin: 0; font-size: 17px; line-height: 1.7; color: rgba(255,255,255,.78); max-width: 540px; }
.login-benefits { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 36px; }
.login-benefit { border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.08); backdrop-filter: blur(8px); border-radius: 16px; padding: 16px; }
.login-benefit strong { display: block; margin: 9px 0 3px; }
.login-benefit small { color: rgba(255,255,255,.68); }
.login-version { position: relative; z-index: 1; color: rgba(255,255,255,.58); font-size: 12px; }
.login-panel { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.login-card { width: min(100%, 380px); }
.login-mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 42px; }
.login-mobile-brand strong { font-size: 22px; }
.login-card h2 { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -.035em; }
.login-card > p { margin: 10px 0 28px; color: var(--muted); }
.login-help { margin-top: 20px; color: var(--muted); font-size: 12px; text-align: center; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar); background: #0d2f2c; color: #d9eeeb;
  padding: 22px 14px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 2px 10px 24px; }
.sidebar-brand .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.sidebar-brand .brand-mark::before { width: 22px; height: 22px; top: 9px; left: 6px; }
.sidebar-brand .brand-mark::after { left: 13px; top: 19px; }
.sidebar-brand-name { min-width: 0; }
.sidebar-brand-name strong { display: block; font-size: 17px; color: white; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand-name small { color: #8fb6b1; }
.nav-group-label { padding: 13px 12px 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .13em; font-weight: 800; color: #6f9a95; }
.nav-list { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; min-height: 45px; padding: 10px 12px; border-radius: 12px;
  color: #b8d3d0; font-weight: 650; transition: .18s ease; border: 0; background: transparent; width: 100%; cursor: pointer; text-align: left;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; opacity: .85; }
.nav-item:hover { color: white; background: rgba(255,255,255,.07); }
.nav-item.active { color: white; background: rgba(45, 212, 191, .16); box-shadow: inset 3px 0 0 #5eead4; }
.sidebar-spacer { flex: 1; min-height: 20px; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.09); padding: 16px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-strong); font-weight: 850; flex: 0 0 auto; }
.sidebar-user .avatar { background: rgba(45,212,191,.16); color: #99f6e4; }
.sidebar-user-meta { min-width: 0; flex: 1; }
.sidebar-user-meta strong, .sidebar-user-meta small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta strong { color: white; font-size: 13px; }
.sidebar-user-meta small { color: #87aaa6; font-size: 11px; }
.sidebar-logout { border: 0; background: transparent; color: #92b4b0; padding: 7px; border-radius: 9px; cursor: pointer; }
.sidebar-logout:hover { background: rgba(255,255,255,.08); color: white; }
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(6, 24, 22, .52); backdrop-filter: blur(2px); }

.app-main { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  position: sticky; top: 0; z-index: 25; height: var(--topbar); padding: 0 clamp(18px, 3vw, 36px); display: flex; align-items: center; gap: 16px;
  background: rgba(243,247,246,.87); backdrop-filter: blur(16px); border-bottom: 1px solid rgba(203,218,215,.7);
}
.mobile-menu-btn { display: none; }
.topbar-title { min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.8); border-radius: 14px; padding: 6px 10px 6px 6px; }
.user-chip .avatar { width: 30px; height: 30px; border-radius: 10px; font-size: 12px; }
.user-chip strong { font-size: 12px; display: block; line-height: 1.2; }
.user-chip small { color: var(--muted); font-size: 10px; display: block; }
.page { padding: clamp(18px, 3vw, 36px); max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-head h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.btn {
  appearance: none; border: 1px solid transparent; border-radius: 12px; min-height: 40px; padding: 9px 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 7px 16px rgba(15,118,110,.19); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: #a9c0bc; background: var(--surface-soft); }
.btn-soft { background: var(--primary-soft); color: var(--primary-strong); }
.btn-soft:hover { background: #c5eee7; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-success-soft { background: var(--success-soft); color: var(--success); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-strong); color: var(--text); }
.btn-icon { width: 40px; padding: 0; }
.btn-sm { min-height: 34px; padding: 6px 10px; border-radius: 10px; font-size: 12px; }
.btn-lg { min-height: 48px; padding: 12px 18px; border-radius: 14px; }
.btn-block { width: 100%; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.card-body { padding: 20px; }
.card-pad { padding: 20px; }
.card + .card { margin-top: 18px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 18px; min-width: 0; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 80px; height: 80px; border-radius: 50%; right: -30px; top: -30px; background: var(--primary-soft); opacity: .65; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: relative; z-index: 1; }
.stat-label { color: var(--muted); font-weight: 650; font-size: 12px; }
.stat-icon { width: 35px; height: 35px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat-icon svg { width: 18px; height: 18px; }
.stat-value { margin-top: 10px; font-size: clamp(22px, 2.2vw, 30px); font-weight: 850; letter-spacing: -.045em; position: relative; z-index: 1; overflow-wrap: anywhere; }
.stat-note { margin-top: 4px; color: var(--muted); font-size: 11px; position: relative; z-index: 1; }
.stat-card.warning .stat-icon, .stat-card.warning::after { background: var(--warning-soft); color: var(--warning); }
.stat-card.danger .stat-icon, .stat-card.danger::after { background: var(--danger-soft); color: var(--danger); }
.stat-card.info .stat-icon, .stat-card.info::after { background: var(--info-soft); color: var(--info); }
.stat-card.success .stat-icon, .stat-card.success::after { background: var(--success-soft); color: var(--success); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .8fr); gap: 18px; }
.dashboard-grid .full { grid-column: 1 / -1; }
.status-pipeline { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 9px; }
.status-step { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); cursor: pointer; transition: .15s ease; }
.status-step:hover { transform: translateY(-2px); border-color: #b5cbc7; box-shadow: var(--shadow-sm); }
.status-step strong { display: block; font-size: 22px; line-height: 1.1; }
.status-step span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.bar-chart { height: 210px; display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); align-items: end; gap: 12px; padding-top: 18px; }
.bar-col { height: 100%; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; }
.bar-value { font-size: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.bar-track { width: min(40px, 70%); height: 145px; display: flex; align-items: flex-end; background: var(--surface-strong); border-radius: 9px; overflow: hidden; }
.bar-fill { width: 100%; min-height: 3px; border-radius: 9px 9px 0 0; background: linear-gradient(180deg, #2dd4bf, var(--primary)); transition: height .4s ease; }
.bar-label { font-size: 10px; color: var(--muted); }

.filters { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; padding: 14px; margin-bottom: 14px; }
.filter-grow { flex: 1 1 240px; }
.filter-field { min-width: 140px; }
.filter-field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search-wrap .input { padding-left: 38px; }

.field { min-width: 0; }
.field label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 7px; font-size: 12px; font-weight: 750; }
.field label small { color: var(--muted); font-weight: 500; }
.field-help { color: var(--muted); font-size: 11px; margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 12px;
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.input, .select { min-height: 42px; padding: 9px 12px; }
.textarea { min-height: 90px; padding: 11px 12px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: #a8c0bc; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.11); background: #fff; }
.input:disabled, .select:disabled, .textarea:disabled { background: #edf2f1; color: #82918f; cursor: not-allowed; }
.input-group { display: flex; }
.input-group .input { border-radius: 12px 0 0 12px; }
.input-group .btn { border-radius: 0 12px 12px 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }
.form-span-2 { grid-column: span 2; }
.form-span-all { grid-column: 1 / -1; }
.form-section { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 15px; padding: 16px; }
.form-section + .form-section { margin-top: 14px; }
.form-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.form-section-title h4 { margin: 0; font-size: 14px; }
.form-section-title p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.check-row { display: flex; align-items: center; gap: 9px; min-height: 40px; }
.check-row input { width: 17px; height: 17px; accent-color: var(--primary); }
.switch { position: relative; width: 42px; height: 24px; display: inline-block; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; background: #c9d5d3; border-radius: 99px; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }

.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { position: sticky; top: 0; z-index: 2; background: var(--surface-soft); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .055em; white-space: nowrap; }
.data-table tbody tr { transition: .12s; }
.data-table tbody tr:hover { background: #f8fcfb; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .right { text-align: right; }
.data-table .center { text-align: center; }
.cell-main { font-weight: 750; }
.cell-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.clickable-row { cursor: pointer; }

.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 4px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge-neutral { background: #edf2f1; color: #526966; }
.badge-primary { background: var(--primary-soft); color: var(--primary-strong); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty-state { padding: 50px 22px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-strong); color: var(--primary); margin-bottom: 13px; }
.empty-icon svg { width: 27px; height: 27px; }
.empty-state h3 { margin: 0 0 5px; color: var(--text); font-size: 15px; }
.empty-state p { margin: 0; max-width: 360px; font-size: 12px; }
.empty-state .btn { margin-top: 15px; }
.skeleton { position: relative; overflow: hidden; background: #e7efed; border-radius: 8px; min-height: 16px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.order-lines { display: grid; gap: 9px; }
.order-line { display: grid; grid-template-columns: minmax(190px, 2fr) minmax(90px, .65fr) minmax(120px, .85fr) minmax(120px, .85fr) 38px; gap: 9px; align-items: end; padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.order-line .line-total { min-height: 42px; display: flex; align-items: center; justify-content: flex-end; font-weight: 800; padding: 0 8px; }
.order-summary { margin-left: auto; width: min(100%, 410px); display: grid; gap: 9px; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.summary-row span { color: var(--muted); }
.summary-row strong { text-align: right; }
.summary-row.total { border-top: 1px dashed var(--line-strong); padding-top: 12px; margin-top: 3px; }
.summary-row.total span, .summary-row.total strong { color: var(--text); font-size: 18px; font-weight: 850; }
.customer-picker { position: relative; }
.picker-results { position: absolute; z-index: 12; left: 0; right: 0; top: calc(100% + 5px); max-height: 260px; overflow-y: auto; background: white; border: 1px solid var(--line-strong); border-radius: 13px; box-shadow: var(--shadow); }
.picker-item { width: 100%; border: 0; background: white; text-align: left; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--surface-soft); }
.picker-item strong, .picker-item small { display: block; }
.picker-item small { color: var(--muted); }
.customer-selected { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--primary); background: var(--primary-soft); border-radius: 12px; }
.customer-selected-meta { flex: 1; min-width: 0; }
.customer-selected-meta strong, .customer-selected-meta small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.customer-selected-meta small { color: var(--primary-strong); }

.detail-hero { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(135deg, var(--surface-soft), #eefaf8); display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.detail-invoice { font-size: 21px; font-weight: 850; letter-spacing: -.03em; }
.detail-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 14px; }
.detail-box { padding: 14px; border: 1px solid var(--line); border-radius: 13px; }
.detail-box label { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.detail-box strong { display: block; }
.detail-box small { display: block; color: var(--muted); margin-top: 2px; }
.timeline { position: relative; display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 18px 30px; }
.timeline-item::before { content: ""; position: absolute; left: 8px; top: 5px; bottom: -5px; width: 1px; background: var(--line-strong); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 3px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline-item strong { display: block; font-size: 12px; }
.timeline-item small { display: block; color: var(--muted); margin-top: 2px; }

.stock-value { font-weight: 850; }
.stock-value.low { color: var(--danger); }
.qty-positive { color: var(--success); font-weight: 800; }
.qty-negative { color: var(--danger); font-weight: 800; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.permission-item { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 11px; padding: 10px; background: white; }
.permission-item input { accent-color: var(--primary); width: 16px; height: 16px; }

.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); width: fit-content; }
.tab { border: 0; border-radius: 9px; background: transparent; color: var(--muted); padding: 8px 12px; font-weight: 700; cursor: pointer; }
.tab.active { background: white; color: var(--text); box-shadow: var(--shadow-sm); }
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); }
.pagination-info { color: var(--muted); font-size: 11px; }
.pagination-buttons { display: flex; gap: 6px; }

.toast-root { position: fixed; z-index: 100; top: 18px; right: 18px; display: grid; gap: 9px; width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); animation: toast-in .22s ease; }
.toast-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; }
.toast-icon svg { width: 15px; height: 15px; }
.toast.success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast.error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast.info .toast-icon { background: var(--info-soft); color: var(--info); }
.toast-body { min-width: 0; flex: 1; }
.toast-body strong { display: block; font-size: 12px; }
.toast-body span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; overflow-wrap: anywhere; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

.modal-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(5, 28, 25, .55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px; animation: fade-in .16s ease; }
.modal { width: min(620px, 100%); max-height: min(900px, calc(100vh - 36px)); background: var(--surface); border: 1px solid rgba(255,255,255,.3); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; animation: modal-in .18s ease; }
.modal-md { width: min(760px, 100%); }
.modal-lg { width: min(1040px, 100%); }
.modal-xl { width: min(1260px, 100%); }
.modal-head { flex: 0 0 auto; padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.modal-close { border: 0; background: var(--surface-strong); color: var(--muted); border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.modal-close:hover { background: var(--line); color: var(--text); }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 20px; }
.modal-foot { flex: 0 0 auto; flex-wrap: wrap; padding: 13px 20px calc(13px + var(--safe-bottom)); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 8px; background: var(--surface-soft); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.confirm-icon { width: 52px; height: 52px; border-radius: 17px; display: grid; place-items: center; background: var(--warning-soft); color: var(--warning); margin-bottom: 14px; }
.confirm-icon svg { width: 25px; height: 25px; }
.confirm-copy h3 { margin: 0 0 6px; }
.confirm-copy p { color: var(--muted); margin: 0; }

.mobile-fab { display: none; position: fixed; right: 18px; bottom: calc(18px + var(--safe-bottom)); z-index: 24; width: 54px; height: 54px; padding: 0; border-radius: 18px; box-shadow: 0 14px 28px rgba(15,118,110,.3); }
.hide-desktop { display: none !important; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.font-bold { font-weight: 800; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 14px; }
.mt-3 { margin-top: 20px; }
.mb-0 { margin-bottom: 0 !important; }
.gap-1 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .full { grid-column: auto; }
  .status-pipeline { grid-template-columns: repeat(5, minmax(120px,1fr)); overflow-x: auto; padding-bottom: 4px; }
}

@media (max-width: 900px) {
  :root { --topbar: 64px; }
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .app-main { margin-left: 0; }
  .mobile-menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .topbar-title p { display: none; }
  .user-chip > div:not(.avatar) { display: none; }
  .user-chip { padding-right: 6px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 28px 22px; background:
    radial-gradient(circle at 90% 5%, rgba(45,212,191,.17), transparent 28%), var(--surface); }
  .login-mobile-brand { display: flex; }
}

@media (max-width: 720px) {
  body { font-size: 13px; }
  .page { padding: 16px 12px calc(88px + var(--safe-bottom)); }
  .page-head { align-items: center; margin-bottom: 16px; }
  .page-head h2 { font-size: 21px; }
  .page-head p { font-size: 11px; }
  .page-actions .btn-primary.desktop-action { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .stat-note { display: none; }
  .stat-icon { width: 31px; height: 31px; }
  .card-head, .card-body, .card-pad { padding: 15px; }
  .filters { align-items: stretch; padding: 11px; gap: 8px; }
  .filter-field { flex: 1 1 calc(50% - 8px); min-width: 125px; }
  .filter-grow { flex-basis: 100%; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; gap: 12px; }
  .form-span-2, .form-span-all { grid-column: auto; }
  .order-line { grid-template-columns: minmax(0,1fr) 90px; padding: 10px; }
  .order-line .line-item { grid-column: 1 / -1; }
  .order-line .line-price { grid-column: 1; }
  .order-line .line-total { grid-column: 2; justify-content: flex-end; }
  .order-line .line-remove { position: absolute; right: 9px; top: 9px; }
  .order-line { position: relative; padding-top: 44px; }
  .order-line .line-qty { grid-column: 2; grid-row: 2; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-hero { flex-direction: column; }
  .permission-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { width: 100%; max-height: 94vh; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .modal-md, .modal-lg, .modal-xl { width: 100%; }
  .modal-body { padding: 16px 14px; }
  .modal-head { padding: 15px 16px; }
  .modal-foot { padding: 11px 14px calc(11px + var(--safe-bottom)); }
  .modal-foot .btn { flex: 1 1 calc(50% - 8px); }
  .toast-root { top: 10px; right: 10px; }
  .mobile-fab { display: inline-flex; }
  .hide-mobile { display: none !important; }
  .hide-desktop { display: initial !important; }
  .data-table { min-width: 680px; }
  .bar-chart { gap: 5px; }
  .bar-value { display: none; }
  .bar-track { width: 60%; }
  .pagination { padding: 12px; }
}

@media (max-width: 440px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-label { font-size: 10px; }
  .stat-value { font-size: 17px; }
  .topbar-actions .btn-install { display: none; }
  .login-card h2 { font-size: 27px; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
}

@media print {
  .sidebar, .topbar, .page-head, .filters, .btn, .mobile-fab, .toast-root { display: none !important; }
  .app-main { margin: 0; }
  .page { padding: 0; }
  .card { box-shadow: none; border: 0; }
}
.loader-mini { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
