:root {
  --navy-950: #06192b;
  --navy-900: #071d33;
  --navy-800: #0d304b;
  --cyan-500: #00bfe8;
  --cyan-600: #009ec4;
  --blue-600: #1778b9;
  --ink: #102a3a;
  --muted: #637986;
  --line: #dbe4e8;
  --paper: #f3f6f7;
  --white: #fff;
  --green: #198754;
  --amber: #b7791f;
  --red: #c0392b;
  --shadow: 0 16px 40px rgba(8, 31, 48, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.danger { color: var(--red); }
.success { color: var(--green); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(420px, .8fr);
  background: var(--navy-900);
}
.login-visual {
  min-height: 100vh;
  padding: clamp(42px, 7vw, 96px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  background:
    radial-gradient(circle at 78% 20%, rgba(0,191,232,.27), transparent 31%),
    linear-gradient(145deg, #0a2c45 0%, #06192b 72%);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: 142px; height: 82px; object-fit: contain; background: white; border-radius: 16px; padding: 8px 14px; }
.brand small { color: #9fbdcc; letter-spacing: .04em; }
.login-copy { max-width: 680px; }
.eyebrow { color: var(--cyan-500); font-size: 12px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.login-copy h1 { font-size: clamp(44px, 6vw, 76px); line-height: .98; letter-spacing: -.045em; margin: 22px 0; }
.login-copy p { font-size: 19px; line-height: 1.6; color: #bdd0da; max-width: 620px; }
.login-panel { background: white; padding: clamp(42px, 7vw, 86px); display: flex; align-items: center; }
.login-card { width: 100%; max-width: 420px; margin: auto; }
.login-card h2 { font-size: 30px; margin: 0 0 8px; letter-spacing: -.03em; }
.login-card > p { color: var(--muted); margin: 0 0 30px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy-900); color: white; padding: 28px 20px; display: flex; flex-direction: column; }
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; border-bottom: 1px solid #214158; }
.sidebar-logo img { width: 78px; height: 55px; object-fit: contain; background: white; border-radius: 10px; padding: 5px; }
.sidebar-logo strong { display: block; font-size: 14px; }
.sidebar-logo span { display: block; color: #91adbc; font-size: 11px; margin-top: 3px; }
.nav { display: grid; gap: 6px; margin-top: 26px; }
.nav button { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: transparent; color: #b8ced9; padding: 12px 14px; border-radius: 9px; text-align: left; font-weight: 650; }
.nav button:hover { background: #0c304a; color: white; }
.nav button.active { background: var(--cyan-500); color: #00253a; }
.nav .icon { width: 22px; text-align: center; font-size: 16px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #214158; padding: 18px 8px 0; }
.sidebar-user { font-size: 13px; font-weight: 700; }
.sidebar-role { color: #91adbc; font-size: 11px; margin: 3px 0 12px; }
.logout { border: 0; padding: 0; background: none; color: #91adbc; font-size: 12px; }
.logout:hover { color: white; }

.main { min-width: 0; }
.topbar { min-height: 80px; background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 16px 36px; gap: 20px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.topbar p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.save-state { font-size: 12px; color: var(--muted); min-width: 98px; text-align: right; }
.content { padding: 32px 36px 60px; max-width: 1600px; margin: 0 auto; }

.btn { border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); min-height: 38px; padding: 0 15px; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn:hover { border-color: #a9bbc4; }
.btn.primary { border-color: var(--navy-900); background: var(--navy-900); color: white; }
.btn.primary:hover { background: var(--navy-800); }
.btn.cyan { border-color: var(--cyan-500); background: var(--cyan-500); color: #00253a; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.035em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 18px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 22px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 13px; padding: 22px; box-shadow: 0 6px 20px rgba(8,31,48,.035); }
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.stat strong { display: block; margin-top: 12px; font-size: 34px; letter-spacing: -.04em; }

.card { background: white; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 6px 20px rgba(8,31,48,.035); }
.card-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-body { padding: 20px; }
.card.flat { box-shadow: none; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.field { grid-column: span 4; }
.field.span-6 { grid-column: span 6; }
.field.span-8 { grid-column: span 8; }
.field.span-12 { grid-column: span 12; }
.field.span-3 { grid-column: span 3; }
.field.span-2 { grid-column: span 2; }
.field label { display: block; font-size: 11px; font-weight: 750; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .055em; }
.input, .select, .textarea { width: 100%; border: 1px solid #ccd9df; border-radius: 8px; background: white; color: var(--ink); outline: none; }
.input, .select { height: 40px; padding: 0 11px; }
.textarea { min-height: 86px; padding: 10px 11px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--cyan-600); box-shadow: 0 0 0 3px rgba(0,191,232,.12); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; background: #f7f9fa; color: var(--muted); text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid #e8eef1; font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.table-link { border: 0; background: none; padding: 0; color: var(--blue-600); font-weight: 750; text-align: left; }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 4px 8px; background: #eef3f5; color: #516874; font-size: 10.5px; font-weight: 750; }
.badge.draft { background: #eef3f5; }
.badge.sent { background: #e8f4fa; color: #08698e; }
.badge.accepted { background: #e7f6ed; color: #176d43; }
.badge.rejected, .badge.expired { background: #faecea; color: #9e3128; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

.quote-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.quote-main { display: grid; gap: 18px; }
.quote-summary { position: sticky; top: 102px; background: var(--navy-900); color: white; border-radius: 13px; padding: 22px; box-shadow: var(--shadow); }
.quote-summary h3 { margin: 0 0 16px; font-size: 15px; }
.summary-row { display: flex; justify-content: space-between; gap: 18px; padding: 6px 0; color: #b6ccd8; font-size: 12px; }
.summary-row strong { color: white; }
.summary-row.total { border-top: 1px solid #315068; margin-top: 9px; padding-top: 14px; font-size: 16px; }
.summary-row.profit { color: #8edfb7; }
.summary-row.loss strong { color: #ffb1a9; }
.summary-actions { display: grid; gap: 8px; margin-top: 20px; }
.summary-actions .btn { width: 100%; }
.add-line { display: grid; grid-template-columns: minmax(220px, 1fr) 90px auto; gap: 10px; padding: 16px 20px; background: #f8fafb; border-bottom: 1px solid var(--line); }
.inline-input { height: 34px; border: 1px solid #cbd8de; border-radius: 7px; padding: 0 8px; width: 100%; }
.item-name { min-width: 210px; }
.item-sub { display: block; color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.profit-positive { color: var(--green); font-weight: 750; }
.profit-negative { color: var(--red); font-weight: 750; }
.split { display: grid; grid-template-columns: 20fr 25fr 55fr; height: 10px; overflow: hidden; border-radius: 99px; margin-top: 16px; }
.split span:nth-child(1) { background: #23445b; }
.split span:nth-child(2) { background: #31617e; }
.split span:nth-child(3) { background: var(--cyan-500); }

.product-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.side-card { position: sticky; top: 102px; }
.history { display: grid; gap: 10px; margin-top: 18px; }
.history-item { padding: 11px 0; border-top: 1px solid var(--line); font-size: 12px; }
.history-item strong { display: block; margin-bottom: 4px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; background: var(--navy-900); color: white; border-radius: 9px; padding: 12px 16px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8d2b25; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 86px minmax(0, 1fr); }
  .sidebar { padding: 24px 12px; }
  .sidebar-logo div, .nav .label, .sidebar-user, .sidebar-role, .logout { display: none; }
  .sidebar-logo { padding: 0 2px 22px; justify-content: center; }
  .sidebar-logo img { width: 56px; }
  .nav button { justify-content: center; padding: 12px; }
  .quote-layout, .product-layout { grid-template-columns: 1fr; }
  .quote-summary, .side-card { position: static; }
}

@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 30px 22px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px 16px; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar-logo, .sidebar-footer { display: none; }
  .nav { display: flex; gap: 6px; margin: 0; }
  .nav button { white-space: nowrap; }
  .nav .label { display: inline; }
  .topbar { position: static; padding: 16px 18px; }
  .content { padding: 22px 16px 46px; }
  .stats { grid-template-columns: 1fr; }
  .field, .field.span-2, .field.span-3, .field.span-6, .field.span-8 { grid-column: span 12; }
  .add-line { grid-template-columns: 1fr 90px; }
  .add-line .btn { grid-column: span 2; }
}

@media print {
  body { background: white; }
  .app-shell, .toast { display: none !important; }
}
