:root {
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --canvas: #f3f5f7;
  --paper: #ffffff;
  --line: #e2e8f0;
  --line-dark: #cbd5e1;
  --accent: #c7f464;
  --accent-2: #a7df3c;
  --blue: #2f5bea;
  --blue-soft: #eef2ff;
  --green: #16835b;
  --green-soft: #e8f7f0;
  --orange: #b75b08;
  --orange-soft: #fff4e6;
  --red: #b42332;
  --red-soft: #fff0f1;
  --purple: #6d45c8;
  --purple-soft: #f3efff;
  --shadow: 0 16px 42px rgba(15, 23, 42, .08);
  --shadow-sm: 0 3px 12px rgba(15, 23, 42, .05);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-right { text-align: right !important; }
.text-green { color: var(--green) !important; }
.text-red { color: var(--red) !important; }
.nowrap { white-space: nowrap; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 30; display: flex; flex-direction: column; height: 100vh; padding: 22px 15px 16px; color: #dbe4f0; background: var(--ink); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 25px; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; flex: 0 0 auto; border-radius: 11px; color: var(--ink); background: var(--accent); font-weight: 950; font-size: 22px; letter-spacing: -2px; transform: skew(-7deg); }
.sidebar-brand strong { display: block; color: white; font-size: 17px; line-height: 1; letter-spacing: .09em; }
.sidebar-brand small { display: block; margin-top: 5px; color: #7f8da4; font-size: 8px; font-weight: 800; letter-spacing: .2em; }
.sidebar-nav { display: grid; gap: 5px; }
.nav-item { position: relative; display: grid; grid-template-columns: 31px 1fr auto; align-items: center; width: 100%; min-height: 44px; padding: 0 11px; border: 0; border-radius: 11px; color: #9facbf; background: transparent; text-align: left; font-size: 12px; font-weight: 700; transition: .16s ease; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: var(--ink); background: var(--accent); }
.nav-icon { display: inline-grid; place-items: center; width: 22px; color: currentColor; font-size: 18px; font-weight: 500; }
.nav-item em { padding: 3px 5px; border-radius: 5px; color: #a9f0cf; background: rgba(28, 184, 127, .14); font-size: 7px; font-style: normal; font-weight: 900; letter-spacing: .08em; }
.nav-item.active em { color: var(--ink); background: rgba(15,23,42,.1); }
.sidebar-bottom { display: grid; gap: 12px; margin-top: auto; }
.sync-card { display: grid; grid-template-columns: 12px 1fr; align-items: center; gap: 10px; width: 100%; padding: 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; color: white; background: rgba(255,255,255,.04); text-align: left; }
.sync-card:hover { background: rgba(255,255,255,.075); }
.sync-card strong, .owner-card strong { display: block; overflow: hidden; font-size: 10px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.sync-card small, .owner-card small { display: block; margin-top: 3px; color: #7f8da4; font-size: 9px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(183,91,8,.15); }
.sync-dot.connected { background: #46d59a; box-shadow: 0 0 0 4px rgba(70,213,154,.12); }
.sync-dot.syncing { background: #79a2ff; box-shadow: 0 0 0 4px rgba(121,162,255,.15); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .45; } }
.owner-card { display: grid; grid-template-columns: 35px 1fr; align-items: center; gap: 10px; padding: 4px 7px; }
.avatar { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; color: var(--ink); background: white; font-weight: 900; }

.main-area { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; min-height: 76px; padding: 12px clamp(20px, 3vw, 40px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.91); backdrop-filter: blur(18px); }
.menu-button { display: none; width: 40px; height: 40px; margin-right: 10px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.topbar-title { min-width: 170px; }
.topbar-title p { margin: 0 0 2px; color: var(--blue); font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.topbar-title h1 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-left: auto; }
.global-search { display: flex; align-items: center; width: min(340px, 30vw); height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: #f7f9fb; }
.global-search span { color: var(--muted); font-size: 20px; }
.global-search input { width: 100%; height: 100%; padding: 0 8px; border: 0; outline: none; color: var(--ink); background: transparent; font-size: 11px; }
.search-results { position: absolute; top: 65px; right: clamp(20px, 3vw, 40px); width: min(460px, calc(100vw - 30px)); max-height: 420px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: var(--shadow); }
.search-result { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 9px; background: white; text-align: left; }
.search-result:hover { background: #f3f6f8; }
.search-result-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: var(--blue); background: var(--blue-soft); font-weight: 900; }
.search-result strong { display: block; font-size: 11px; }
.search-result small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.search-result em { color: var(--muted); font-size: 9px; font-style: normal; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 10px; font-weight: 800; font-size: 11px; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--ink); box-shadow: 0 7px 16px rgba(15,23,42,.13); }
.button-primary:hover { background: #273449; }
.button-accent { color: var(--ink); background: var(--accent); border-color: var(--accent-2); }
.button-light { color: var(--ink); background: white; border-color: var(--line); }
.button-danger { color: var(--red); background: var(--red-soft); border-color: #ffd5d9; }
.button-small { min-height: 32px; padding: 0 10px; font-size: 9px; }
.icon-button { display: grid; place-items: center; width: 37px; height: 37px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; font-size: 21px; line-height: 1; }

.view { padding: 26px clamp(18px, 3vw, 40px) 60px; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-toolbar p { margin: 0; color: var(--muted); font-size: 11px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.filter-select, .table-search { min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--ink); background: white; font-size: 10px; }
.table-search { min-width: 220px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.metric-card { position: relative; overflow: hidden; min-height: 126px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-sm); }
.metric-card::after { content: ""; position: absolute; right: -26px; top: -28px; width: 84px; height: 84px; border-radius: 50%; background: var(--tone, var(--blue-soft)); }
.metric-label { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.metric-label span { display: grid; place-items: center; width: 27px; height: 27px; margin-top: -5px; border-radius: 8px; color: var(--icon, var(--blue)); background: var(--tone, var(--blue-soft)); font-size: 14px; }
.metric-value { position: relative; z-index: 1; margin: 14px 0 5px; font-size: clamp(22px, 2.4vw, 30px); font-weight: 900; letter-spacing: -.045em; }
.metric-foot { position: relative; z-index: 1; color: var(--muted); font-size: 9px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(280px,.7fr); gap: 16px; margin-top: 16px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-sm); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 13px; letter-spacing: -.015em; }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.panel-body { padding: 18px; }
.chart { display: grid; grid-template-columns: repeat(6, 1fr); align-items: end; gap: 11px; height: 220px; padding-top: 16px; }
.chart-col { display: grid; grid-template-rows: 1fr auto; align-items: end; height: 100%; gap: 9px; }
.chart-bars { display: flex; align-items: end; justify-content: center; gap: 4px; height: 100%; border-bottom: 1px solid var(--line); }
.chart-bar { width: min(20px, 38%); min-height: 3px; border-radius: 5px 5px 1px 1px; background: var(--blue); transition: .2s; }
.chart-bar.profit { background: var(--accent-2); }
.chart-label { color: var(--muted); text-align: center; font-size: 9px; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 8px; }
.chart-legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 2px; background: var(--blue); }
.chart-legend span:last-child::before { background: var(--accent-2); }
.activity-list { display: grid; }
.activity-row { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 11px 0; border-bottom: 1px solid #edf0f3; }
.activity-row:last-child { border-bottom: 0; }
.activity-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-size: 11px; }
.activity-row strong { display: block; font-size: 10px; line-height: 1.4; }
.activity-row time { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }

.data-panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-sm); }
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th { padding: 11px 15px; border-bottom: 1px solid var(--line); color: var(--muted); background: #fafbfc; text-align: left; font-size: 8px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.data-table td { padding: 13px 15px; border-bottom: 1px solid #edf0f3; color: var(--ink-2); font-size: 10px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfd; }
.cell-title { display: flex; align-items: center; gap: 10px; }
.cell-avatar { display: grid; place-items: center; width: 31px; height: 31px; flex: 0 0 auto; border-radius: 9px; color: var(--blue); background: var(--blue-soft); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.cell-title strong { display: block; color: var(--ink); font-size: 10px; }
.cell-title small { display: block; margin-top: 3px; color: var(--muted); font-size: 8.5px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 99px; font-size: 8px; font-weight: 850; text-transform: capitalize; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.paid, .status.accepted, .status.active { color: var(--green); background: var(--green-soft); }
.status.sent, .status.part-paid, .status.lead { color: var(--blue); background: var(--blue-soft); }
.status.unpaid, .status.draft { color: var(--orange); background: var(--orange-soft); }
.status.overdue, .status.declined, .status.inactive { color: var(--red); background: var(--red-soft); }
.status.expired { color: var(--muted); background: #eef1f4; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-action { min-width: 29px; height: 29px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2); background: white; font-size: 9px; font-weight: 800; }
.row-action:hover { border-color: var(--line-dark); background: #f7f9fb; }
.row-action.danger { color: var(--red); }
.empty-state { display: grid; justify-items: center; padding: 64px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border: 1px dashed var(--line-dark); border-radius: 14px; color: var(--muted); font-size: 20px; }
.empty-state h3 { margin: 0; font-size: 13px; }
.empty-state p { max-width: 380px; margin: 6px 0 16px; color: var(--muted); font-size: 10px; line-height: 1.55; }

.catalog-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; }
.product-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow-sm); }
.product-card-top { display: flex; justify-content: space-between; gap: 12px; }
.product-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--purple); background: var(--purple-soft); font-size: 15px; font-weight: 900; }
.product-card h3 { margin: 15px 0 4px; font-size: 12px; }
.product-card > p { margin: 0; color: var(--muted); font-size: 9px; }
.price-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.price-pair small { display: block; color: var(--muted); font-size: 7px; font-weight: 850; letter-spacing: .08em; }
.price-pair strong { display: block; margin-top: 4px; font-size: 11px; }

.modal-backdrop, .drawer-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; background: rgba(6, 13, 25, .58); backdrop-filter: blur(6px); }
.modal-backdrop { z-index: 100; }
.modal { width: min(620px, 100%); max-height: calc(100vh - 36px); overflow: auto; border-radius: 19px; background: white; box-shadow: 0 28px 90px rgba(0,0,0,.25); }
.modal-header, .drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 21px 23px; border-bottom: 1px solid var(--line); }
.modal-header p, .drawer-header p { margin: 0 0 5px; color: var(--blue); font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.modal-header h2, .drawer-header h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.modal-body { padding: 22px 23px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 23px; border-top: 1px solid var(--line); background: #fafbfc; }
.form-grid { display: grid; gap: 13px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { display: grid; gap: 6px; color: var(--ink-2); font-size: 9px; font-weight: 850; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea, .editor-input { width: 100%; min-height: 40px; padding: 9px 10px; border: 1px solid var(--line-dark); border-radius: 9px; outline: none; color: var(--ink); background: white; font-size: 11px; transition: .15s; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .editor-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,91,234,.1); }
.field-hint { color: var(--muted); font-size: 8px; font-weight: 500; line-height: 1.4; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding: 13px; border: 1px solid #ffd8dc; border-radius: 11px; background: #fff7f8; }
.danger-zone strong { display: block; color: var(--red); font-size: 10px; }
.danger-zone small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }

.drawer-backdrop { place-items: stretch end; padding: 0; }
.document-drawer { width: min(1120px, 94vw); height: 100vh; overflow: hidden; background: #f4f6f8; box-shadow: -20px 0 70px rgba(0,0,0,.2); }
.drawer-header { height: 78px; padding: 16px 22px; background: white; }
.drawer-header > div:first-child span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; text-transform: capitalize; }
.drawer-actions { display: flex; align-items: center; gap: 8px; }
.drawer-body { height: calc(100vh - 78px); overflow: auto; padding: 20px; }
.editor-layout { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(280px,.7fr); gap: 17px; align-items: start; }
.editor-card { margin-bottom: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow-sm); }
.editor-card h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 14px; font-size: 11px; }
.editor-card h3 span { color: var(--muted); font-size: 8px; font-weight: 600; }
.line-items { display: grid; gap: 10px; }
.line-item { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd; }
.line-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.line-item-head strong { font-size: 10px; }
.line-item-grid { display: grid; grid-template-columns: 1.2fr .85fr .7fr .55fr; gap: 8px; }
.line-item-grid + .line-item-grid { margin-top: 8px; }
.line-item .field { font-size: 8px; }
.line-item .field input, .line-item .field select { min-height: 36px; padding: 7px 8px; font-size: 9px; }
.remove-line { border: 0; color: var(--red); background: transparent; font-size: 9px; font-weight: 800; }
.line-total { display: flex; justify-content: flex-end; gap: 18px; margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line-dark); color: var(--muted); font-size: 8px; }
.line-total strong { color: var(--ink); font-size: 10px; }
.editor-summary { position: sticky; top: 0; }
.summary-customer { display: grid; gap: 4px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.summary-customer small, .document-totals small { color: var(--muted); font-size: 7px; font-weight: 900; letter-spacing: .11em; }
.summary-customer strong { font-size: 12px; }
.summary-lines { display: grid; gap: 9px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.summary-line { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 9px; }
.summary-line strong { color: var(--ink); }
.document-totals { display: grid; gap: 8px; padding-top: 14px; }
.document-total-row { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 9px; }
.document-total-row strong { color: var(--ink); }
.document-total-row.grand { margin-top: 3px; padding-top: 11px; border-top: 1px solid var(--ink); color: var(--ink); font-size: 14px; font-weight: 900; }
.profit-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; padding: 12px; border-radius: 11px; background: var(--green-soft); }
.profit-box small { display: block; color: var(--green); font-size: 7px; font-weight: 900; letter-spacing: .08em; }
.profit-box strong { display: block; margin-top: 4px; color: #0c6243; font-size: 13px; }
.share-summary { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.share-summary span { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 9px; }
.share-summary strong { color: var(--ink); }

.ai-layout { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(250px,.55fr); gap: 16px; }
.ai-chat { display: flex; flex-direction: column; min-height: 620px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-sm); }
.ai-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.ai-identity { display: flex; align-items: center; gap: 11px; }
.ai-orb { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--ink); background: radial-gradient(circle at 25% 20%, white 0 4%, var(--accent) 8% 45%, #8bcf18 100%); box-shadow: 0 7px 15px rgba(139,207,24,.23); font-size: 17px; }
.ai-identity strong { display: block; font-size: 11px; }
.ai-identity small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.private-badge { padding: 5px 8px; border-radius: 99px; color: var(--green); background: var(--green-soft); font-size: 7px; font-weight: 900; letter-spacing: .08em; }
.ai-messages { flex: 1; overflow: auto; padding: 20px; }
.ai-welcome { max-width: 560px; margin: 50px auto 0; text-align: center; }
.ai-welcome .ai-orb { width: 52px; height: 52px; margin: 0 auto 14px; font-size: 24px; }
.ai-welcome h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
.ai-welcome p { margin: 8px auto 18px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.prompt-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.prompt-chip { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-2); background: white; font-size: 9px; }
.prompt-chip:hover { border-color: var(--blue); color: var(--blue); }
.chat-message { display: flex; gap: 9px; max-width: 82%; margin-bottom: 14px; }
.chat-message.user { margin-left: auto; flex-direction: row-reverse; }
.chat-avatar { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px; color: var(--ink); background: var(--accent); font-size: 10px; font-weight: 900; }
.chat-message.user .chat-avatar { color: white; background: var(--ink); }
.chat-bubble { padding: 11px 13px; border-radius: 4px 13px 13px; color: var(--ink-2); background: #f2f5f7; font-size: 10px; line-height: 1.65; white-space: pre-line; }
.chat-message.user .chat-bubble { border-radius: 13px 4px 13px 13px; color: white; background: var(--ink); }
.chat-source { display: block; margin-top: 6px; color: var(--muted-2); font-size: 7px; font-weight: 800; text-transform: uppercase; }
.ai-compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 13px; border-top: 1px solid var(--line); background: #fbfcfd; }
.ai-compose textarea { width: 100%; min-height: 43px; max-height: 120px; padding: 12px; border: 1px solid var(--line-dark); border-radius: 11px; outline: none; resize: none; font-size: 10px; }
.ai-compose textarea:focus { border-color: var(--blue); }
.ai-side { display: grid; gap: 13px; align-content: start; }
.ai-info-card { padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-sm); }
.ai-info-card h3 { margin: 0 0 7px; font-size: 11px; }
.ai-info-card p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.ai-progress { height: 6px; margin: 13px 0 6px; overflow: hidden; border-radius: 99px; background: #edf1f4; }
.ai-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent-2); transition: width .2s; }
.privacy-list { display: grid; gap: 9px; margin-top: 13px; }
.privacy-row { display: grid; grid-template-columns: 20px 1fr; gap: 7px; align-items: start; color: var(--ink-2); font-size: 8px; line-height: 1.45; }
.privacy-row span { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; color: var(--green); background: var(--green-soft); font-weight: 900; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.settings-card { padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-sm); }
.settings-card.full { grid-column: 1 / -1; }
.settings-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.settings-heading h2 { margin: 0; font-size: 13px; }
.settings-heading p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.connection-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #f8fafb; }
.connection-banner strong { display: block; font-size: 10px; }
.connection-banner small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.setup-steps { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: 9px; line-height: 1.8; }
.logo-preview { display: grid; place-items: center; width: 90px; height: 90px; overflow: hidden; border: 1px dashed var(--line-dark); border-radius: 12px; background: #fafbfc; }
.logo-preview img { max-width: 90%; max-height: 90%; object-fit: contain; }
.payment-profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.payment-profile { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfc; }
.payment-profile > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.payment-profile h3 { margin: 13px 0 4px; font-size: 12px; }
.payment-profile p { margin: 0; color: var(--muted); font-size: 9px; }
.payment-profile small { display: block; min-height: 30px; margin: 8px 0 12px; color: var(--ink-2); font-size: 8px; line-height: 1.5; }
.currency-chip { display: inline-flex; padding: 5px 8px; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-size: 9px; font-weight: 900; }
.compact-empty { display: grid; gap: 4px; padding: 20px; border: 1px dashed var(--line-dark); border-radius: 12px; text-align: center; }
.compact-empty strong { font-size: 11px; }
.compact-empty span { color: var(--muted); font-size: 9px; }

.setup-callout, .share-ready { display: grid; grid-template-columns: 54px 1fr; gap: 14px; align-items: start; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #f8fafb; }
.setup-callout > span, .share-ready-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px; color: var(--ink); background: var(--accent); font-size: 18px; font-weight: 950; }
.setup-callout strong, .share-ready strong { display: block; font-size: 11px; }
.setup-callout p, .share-ready p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.share-ready { margin-bottom: 16px; border-color: #cfe8dc; background: #f2fbf7; }
.share-ready-icon { color: white; background: var(--green); }
.copy-field { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.copy-field input { min-width: 0; }
.share-recipient { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.share-recipient > div { padding: 11px; border: 1px solid var(--line); border-radius: 10px; }
.share-recipient small { display: block; color: var(--muted); font-size: 7px; font-weight: 900; letter-spacing: .08em; }
.share-recipient strong { display: block; overflow: hidden; margin-top: 4px; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; z-index: 120; left: 50%; bottom: 25px; max-width: min(440px, calc(100vw - 30px)); padding: 11px 15px; border-radius: 10px; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: .2s; font-size: 10px; font-weight: 750; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.print-area { display: none; }

.print-document { width: 100%; min-height: 260mm; padding: 10mm; color: #111827; background: white; font-family: Arial, sans-serif; }
.print-document-header { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 20px; border-bottom: 2px solid #111827; }
.print-document-brand { display: flex; align-items: center; gap: 11px; }
.print-document-brand img { max-width: 90px; max-height: 55px; object-fit: contain; }
.print-document-brand h1 { margin: 0; font-size: 22px; letter-spacing: .06em; }
.print-document-brand p { margin: 5px 0 0; color: #667085; font-size: 9px; }
.print-document-type { text-align: right; }
.print-document-type h2 { margin: 0; font-size: 27px; letter-spacing: .08em; }
.print-document-type p { margin: 6px 0 0; font-size: 10px; }
.print-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; padding: 20px 0; }
.print-meta small { display: block; margin-bottom: 6px; color: #667085; font-size: 8px; font-weight: 700; letter-spacing: .1em; }
.print-meta strong { display: block; font-size: 11px; }
.print-meta span { display: block; margin-top: 4px; color: #667085; font-size: 9px; }
.print-table { width: 100%; border-collapse: collapse; }
.print-table th { padding: 9px 7px; border-bottom: 1px solid #111827; color: #667085; text-align: left; font-size: 8px; }
.print-table td { padding: 11px 7px; border-bottom: 1px solid #e5e7eb; font-size: 9px; vertical-align: top; }
.print-table th:last-child, .print-table td:last-child { text-align: right; }
.print-total-section { display: grid; grid-template-columns: 1fr 220px; gap: 30px; margin-top: 24px; }
.print-notes small { color: #667085; font-size: 8px; font-weight: 700; letter-spacing: .1em; }
.print-notes p { color: #4b5563; font-size: 9px; line-height: 1.6; white-space: pre-line; }
.print-totals { display: grid; gap: 8px; }
.print-total-row { display: flex; justify-content: space-between; gap: 15px; font-size: 9px; }
.print-total-row.grand { margin-top: 4px; padding-top: 10px; border-top: 1px solid #111827; font-size: 14px; font-weight: 800; }
.paid-stamp { display: inline-block; margin-top: 22px; padding: 8px 16px; border: 3px solid #16835b; border-radius: 7px; color: #16835b; font-size: 20px; font-weight: 900; letter-spacing: .12em; transform: rotate(-5deg); }
.paid-stamp.unpaid { border-color: #b42332; color: #b42332; }
.print-footer { display: flex; justify-content: space-between; margin-top: 35px; padding-top: 14px; border-top: 1px solid #e5e7eb; color: #667085; font-size: 8px; }

.dispatch-label { width: 3.7in; min-height: 5.7in; padding: .18in; color: #111827; background: white; font-family: Arial, sans-serif; }
.dispatch-label header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 13px; border-bottom: 3px solid #111827; }
.dispatch-brand { display: flex; align-items: center; gap: 9px; }
.dispatch-brand img { max-width: 78px; max-height: 38px; object-fit: contain; }
.label-brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--accent); font-size: 20px; font-weight: 950; }
.dispatch-brand strong, .dispatch-brand span { display: block; }
.dispatch-brand strong { font-size: 12px; }
.dispatch-brand span { max-width: 145px; margin-top: 2px; color: #475569; font-size: 7px; white-space: pre-line; }
.dispatch-service { padding: 5px 7px; border: 2px solid #111827; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.dispatch-to { min-height: 2.55in; padding: 19px 3px; border-bottom: 2px solid #111827; }
.dispatch-to small, .dispatch-order small { display: block; color: #64748b; font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.dispatch-to h1 { margin: 9px 0 0; font-size: 23px; line-height: 1.08; }
.dispatch-to h2 { margin: 5px 0 0; font-size: 13px; }
.dispatch-to p { margin: 13px 0 8px; font-size: 16px; font-weight: 750; line-height: 1.35; }
.dispatch-to span { font-size: 10px; }
.dispatch-order { display: grid; grid-template-columns: 1.5fr 1fr; gap: 13px; padding: 15px 3px; }
.dispatch-order strong { display: block; margin-top: 4px; font-size: 14px; }
.dispatch-order .full { grid-column: 1 / -1; }
.dispatch-label footer { display: flex; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 12px; border-top: 1px solid #cbd5e1; color: #64748b; font-size: 8px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .catalog-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-summary { position: static; }
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: 248px; box-shadow: 15px 0 50px rgba(0,0,0,.25); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: block; }
  .topbar-title { min-width: 120px; }
  .global-search { width: min(300px, 36vw); }
  .dashboard-grid, .ai-layout { grid-template-columns: 1fr; }
  .ai-chat { min-height: 560px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-card.full { grid-column: auto; }
  .payment-profile-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 690px) {
  .topbar { min-height: 68px; padding: 10px 13px; }
  .topbar-title p { display: none; }
  .topbar-title h1 { font-size: 17px; }
  .global-search, .topbar-actions > .button-light { display: none; }
  .topbar-actions .button-primary { padding: 0 11px; }
  .view { padding: 18px 12px 45px; }
  .page-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; flex-wrap: wrap; }
  .toolbar-actions .table-search { flex: 1; min-width: 160px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 112px; padding: 14px; }
  .metric-value { font-size: 21px; }
  .catalog-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 91vh; border-radius: 20px 20px 0 0; }
  .document-drawer { width: 100vw; }
  .drawer-header { height: auto; min-height: 78px; padding: 12px; }
  .drawer-actions .button-light { display: none; }
  .drawer-body { height: calc(100vh - 76px); padding: 11px; }
  .line-item-grid { grid-template-columns: 1fr 1fr; }
  .ai-messages { padding: 14px; }
  .chat-message { max-width: 94%; }
  .payment-profile-grid, .share-recipient { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .metric-grid, .catalog-grid { grid-template-columns: 1fr; }
  .button { padding: 0 11px; }
  .topbar-actions .button-primary { font-size: 0; width: 41px; padding: 0; }
  .topbar-actions .button-primary span { font-size: 17px; }
}

@media print {
  @page { size: A4; margin: 8mm; }
  body { background: white; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .app-shell, .modal-backdrop, .drawer-backdrop, .toast { display: none !important; }
  .print-area { display: block !important; }
  .print-document { min-height: auto; padding: 0; }
  .dispatch-label { min-height: 5.7in; padding: .18in; }
}
