:root {
  --ink: #14110e;
  --ink-soft: #3a342c;
  --muted: #7a7268;
  --line: #e4ddd3;
  --paper: #f6f1e8;
  --paper-2: #efe8db;
  --white: #fffcf7;
  --copper: #c4622d;
  --copper-d: #9c4a1f;
  --copper-s: #f3d5c0;
  --pine: #1f4d43;
  --pine-s: #d7e6e0;
  --sage: #3f6d5c;
  --gold: #c9a227;
  --danger: #b42318;
  --ok: #1f7a4d;
  --warn: #b45309;
  --info: #1d5f8a;
  --shadow: 0 10px 30px rgba(20, 17, 14, 0.08);
  --radius: 16px;
  --sidebar: 260px;
  --font: "Source Serif 4", Georgia, serif;
  --ui: "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--ui);
  background: var(--paper);
  color: var(--ink);
  letter-spacing: -0.01em;
}

button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar);
  background: var(--ink);
  color: #f3ece3;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 11px;
  overflow: hidden;
  flex-shrink: 0;
  background: #1f4d43;
  box-shadow: 0 8px 18px rgba(31, 77, 67, .28);
}
.brand-mark img, .brand-mark svg { width: 100%; height: 100%; display: block; object-fit: cover; }
.brand h1 { font-size: 16px; font-weight: 650; letter-spacing: -.02em; }
.brand p { font-size: 11px; color: #b8aea2; margin-top: 1px; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #d9d0c6;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: #2a241e; color: #fff; }
.nav a.active svg { color: var(--copper); opacity: 1; }
.nav-label {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: #8a8176; padding: 12px 12px 6px; font-weight: 600;
}

.sidebar-user {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; gap: 10px; align-items: center;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #3a322b; display: grid; place-items: center;
  font-weight: 650; font-size: 13px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .meta { min-width: 0; }
.sidebar-user strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { font-size: 11px; color: #b8aea2; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: rgba(246,241,232,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-family: var(--font); font-size: 22px; font-weight: 600; flex: 1; }
.search {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  display: flex; align-items: center; gap: 8px;
  min-width: 240px;
}
.search input {
  border: 0; outline: 0; background: transparent; width: 100%;
  font-size: 13px; color: var(--ink);
}
.mic-btn {
  border: 0; background: var(--pine-s); color: var(--pine);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 14px; line-height: 1; flex-shrink: 0;
}
.mic-btn:hover { background: var(--pine); color: #fff; }
.mic-btn.big { width: 44px; height: 44px; font-size: 18px; }
.oggi-search { padding: 16px; }
.oggi-row { display: flex; gap: 8px; align-items: center; }
.oggi-input {
  flex: 1; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; background: var(--white);
}
.oggi-input.plate { letter-spacing: 0.08em; text-transform: uppercase; }
.oggi-search .hint { margin: 8px 0 0; }
#oggi-hits { margin-top: 8px; }
.alert-stock { border-left: 4px solid var(--warn); }
.msg-box {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--paper-2); white-space: pre-wrap; font-size: 14px; line-height: 1.45;
}
.badge-premium {
  font-size: 11px; font-weight: 650; letter-spacing: .04em;
  background: linear-gradient(90deg, #c9a227, #e0c56a);
  color: #3a2c00; padding: 5px 10px; border-radius: 999px;
}
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 12px; }
.fld small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.fiscal {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  padding: 12px 14px;
  background: var(--paper-2);
  border-radius: 12px;
  font-size: 13px;
}
.fiscal div { display: flex; flex-direction: column; gap: 2px; }
.fiscal span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.feat-list { margin: 0 0 14px 18px; color: var(--ink-soft); line-height: 1.7; }
.insight-list { display: flex; flex-direction: column; gap: 8px; }
.insight {
  display: block; padding: 12px 14px; border-radius: 12px;
  text-decoration: none; font-size: 14px; font-weight: 550;
}
.insight.warn { background: #f8ead8; color: #7a3e08; }
.insight.info { background: var(--pine-s); color: var(--pine); }
.insight.ok { background: #e4f3ea; color: var(--ok); }
.pill.warn { background: #f8ead8; color: #7a3e08; }
.pill.info { background: var(--pine-s); color: var(--pine); }
.pill.ok { background: #e4f3ea; color: var(--ok); }
.premium-lock p { color: var(--muted); margin: 0 0 12px; }
.nav a.locked { opacity: .72; }
.nav-lock {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #e0c56a;
}
.expiry-only { display: none; }
.check-list { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 14px; max-width: 420px; }
.check-row {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer;
  margin: 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--white);
}
.check-row input[type="checkbox"] {
  width: 18px; height: 18px; margin: 0; flex: 0 0 auto;
  accent-color: var(--copper);
}
label.fld.chk { flex-direction: row; align-items: center; gap: 8px; }
label.fld.chk input[type="checkbox"] { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; padding: 0; border: 0; box-shadow: none; accent-color: var(--copper); }
.content { padding: 24px 28px 48px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 11px;
  padding: 10px 14px;
  font-size: 13.5px; font-weight: 600;
  background: var(--ink); color: #fff;
  transition: transform .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); background: #2a241e; }
.btn.copper { background: var(--copper); }
.btn.copper:hover { background: var(--copper-d); }
.btn.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 7px 10px; font-size: 12.5px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Cards / grids */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 550; }
.kpi .value { font-family: var(--font); font-size: 28px; margin-top: 6px; letter-spacing: -.03em; }
.kpi .hint { font-size: 11px; color: var(--sage); margin-top: 6px; font-weight: 550; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 14px; font-weight: 650; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}

/* Chart */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 28px;
  background: linear-gradient(180deg, var(--copper), #8a3a16);
  border-radius: 6px 6px 3px 3px;
  min-height: 4px;
}
.bar-col span { font-size: 10px; color: var(--muted); }

/* Tables / lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.row-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
  text-decoration: none; color: inherit;
}
.row-item:hover { background: var(--paper); }
.row-item .who { flex: 1; min-width: 0; }
.row-item .who strong { display: block; font-size: 13.5px; }
.row-item .who p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 650;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 12px 10px; border-bottom: 1px solid #efe9df; vertical-align: middle; }
table.data tr { cursor: pointer; }
table.data tbody tr:hover { background: #faf6ef; }
table.data .right { text-align: right; }

.pill {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650;
  background: var(--paper-2); color: var(--ink-soft);
}
.pill.new { background: #e8f1f8; color: var(--info); }
.pill.progress { background: #f8edd8; color: var(--warn); }
.pill.done, .pill.accepted, .pill.paid { background: #e3f3ea; color: var(--ok); }
.pill.sent { background: #e8e4f6; color: #5b4bb3; }
.pill.rejected, .pill.draft { background: #f3e8e4; color: #8a4a3c; }
.pill.pending { background: #f8edd8; color: var(--warn); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--white);
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 550;
  color: var(--ink-soft);
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.empty {
  text-align: center; padding: 48px 16px; color: var(--muted);
}
.empty h4 { color: var(--ink); font-size: 16px; margin-bottom: 6px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
label.fld { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
label.fld input, label.fld select, label.fld textarea {
  border: 1px solid var(--line); background: var(--white);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--ink);
  outline: none;
}
label.fld textarea { min-height: 90px; resize: vertical; }
label.fld input:focus, label.fld select:focus, label.fld textarea:focus {
  border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-s);
}

/* Quote builder */
.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.lines th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: left; padding: 6px; }
.lines td { padding: 6px; }
.lines input, .lines select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  background: var(--white); font-size: 13px;
}
.totals { margin-top: 16px; margin-left: auto; width: 280px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.totals .grand { border-top: 1px solid var(--line); font-weight: 700; font-size: 16px; padding-top: 10px; }

/* Detail */
.hero-detail {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  margin-bottom: 18px;
}
.hero-detail h3 { font-family: var(--font); font-size: 26px; }
.meta-line { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Onboarding */
.onboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper);
}
.onboard-art {
  background:
    radial-gradient(800px 400px at 20% 20%, rgba(196,98,45,.25), transparent 50%),
    radial-gradient(600px 400px at 80% 80%, rgba(31,77,67,.25), transparent 50%),
    var(--ink);
  color: #f6f1e8;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.onboard-art h1 { font-family: var(--font); font-size: 44px; line-height: 1.05; max-width: 420px; }
.onboard-art p.lead { color: #d2c6b8; font-size: 16px; max-width: 380px; margin-top: 14px; line-height: 1.5; }
.onboard-art ul { list-style: none; display: flex; flex-direction: column; gap: 10px; color: #cfc4b6; font-size: 14px; }
.onboard-art ul li { display: flex; gap: 10px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--copper); }

.onboard-form { padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; }
.steps { display: flex; gap: 8px; margin-bottom: 28px; }
.step-dot { height: 4px; flex: 1; border-radius: 99px; background: var(--line); }
.step-dot.on { background: var(--copper); }
.trade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trade-card {
  border: 1px solid var(--line); background: var(--white);
  border-radius: 14px; padding: 16px; text-align: left;
  display: flex; gap: 12px; align-items: center;
}
.trade-card.on { border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-s); }
.trade-ico {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; background: var(--paper-2);
}
.lang-row { display: flex; gap: 10px; }
.lang-btn {
  flex: 1; border: 1px solid var(--line); background: var(--white);
  border-radius: 12px; padding: 16px; font-weight: 650;
}
.lang-btn.on { border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-s); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .hd { font-size: 11px; color: var(--muted); text-align: center; font-weight: 650; padding: 4px; }
.cal .day {
  min-height: 72px; background: var(--paper); border-radius: 10px; padding: 6px;
  font-size: 12px; position: relative;
}
.cal .day.off { opacity: .4; }
.cal .day.today { outline: 2px solid var(--copper); }
.cal .ev {
  margin-top: 4px; background: var(--pine); color: #fff;
  border-radius: 6px; padding: 3px 5px; font-size: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Modal */
.overlay {
  position: fixed; inset: 0; background: rgba(20,17,14,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal {
  background: var(--white); border-radius: 18px; width: min(720px, 100%);
  max-height: 90vh; overflow: auto; padding: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.modal h3 { font-family: var(--font); font-size: 22px; margin-bottom: 14px; }

.toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--ink); color: #fff; padding: 12px 16px;
  border-radius: 12px; font-size: 13px; z-index: 80;
  box-shadow: var(--shadow);
}

.pdf-sheet {
  background: #fff; color: #111; padding: 28px;
  border: 1px solid #ddd; border-radius: 8px;
  font-size: 13px;
}
.pdf-sheet header, .pdf-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; border-bottom: 2px solid #1f4d43; padding-bottom: 14px; margin-bottom: 16px;
}
.pdf-brand { display: flex; align-items: center; gap: 12px; }
.pdf-brand img, .pdf-brand svg { height: 52px; width: auto; max-width: 140px; border-radius: 8px; }
.pdf-doc { text-align: right; font-size: 13px; line-height: 1.45; }
.pdf-contacts { font-size: 12px; color: #555; margin: -8px 0 16px; }
.pdf-sheet.banner { padding: 0 0 24px; }
.pdf-sheet.banner .pdf-head {
  background: #1f4d43; color: #f3ece3; border: 0; margin: 0 0 16px;
  padding: 18px 24px; border-radius: 8px 8px 0 0; align-items: center;
}
.pdf-sheet.banner .pdf-doc { color: #f3ece3; }
.pdf-sheet.banner .pdf-contacts { padding: 0 24px; }
.pdf-sheet.banner > p, .pdf-sheet.banner .fiscal, .pdf-sheet.banner table, .pdf-sheet.banner .hint {
  margin-left: 24px; margin-right: 24px;
}
.pdf-sheet.compatto { padding: 18px 20px; font-size: 12px; }
.pdf-sheet.compatto .pdf-head { padding-bottom: 8px; margin-bottom: 10px; border-width: 1px; }
.pdf-sheet.compatto .pdf-brand img, .pdf-sheet.compatto .pdf-brand svg { height: 36px; }
.tpl-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tpl-btn {
  border: 1px solid var(--line); background: var(--white); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.tpl-btn.on { background: var(--pine); color: #fff; border-color: var(--pine); }
.logo-row { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.logo-preview {
  width: 72px; height: 72px; border-radius: 14px; overflow: hidden;
  background: #1f4d43; flex-shrink: 0; box-shadow: var(--shadow);
}
.logo-preview img, .logo-preview svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo-row .btn { margin-right: 8px; }
.logo-row label.btn { display: inline-flex; align-items: center; cursor: pointer; }

.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

@media print {
  .sidebar, .topbar, .actions, .menu-btn, .search, .toast, .tpl-row, .mic-btn, .oggi-search { display: none !important; }
  .app, .main, .content { display: block; background: #fff; padding: 0; }
  .pdf-sheet { border: 0; box-shadow: none; }
}

@media (max-width: 1080px) {
  .kpis, .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr 1fr; }
  .onboard { grid-template-columns: 1fr; }
  .onboard-art { display: none; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .sidebar.open {
    display: flex; position: fixed; z-index: 40; width: min(280px, 86vw);
  }
  .kpis, .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .search { min-width: 0; flex: 1; }
}

.menu-btn { display: none; border: 0; background: var(--white); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; }
@media (max-width: 820px) { .menu-btn { display: grid; place-items: center; } }
