:root {
  --black: #173b57;
  --coral: #2f718f;
  --white: #ffffff;
  --operational-white: #e9eff3;
  --ink-soft: #667785;
  --line: #d7e0e6;
  --surface: #f2f5f7;
  --success: #2f725b;
  --warning: #9a6817;
  --danger: #a74444;
  --shadow: 0 12px 30px rgba(23, 59, 87, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--black);
  font-family: Aileron, Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 20px 22px;
  color: var(--white);
  background: #173b57;
}

.brand-block { padding: 0 8px 28px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 22px; border: 1px solid rgba(255,255,255,0.35); border-radius: 12px; color: #173b57; background: #ffffff; font-size: 0.95rem; font-weight: 800; letter-spacing: 0.06em; }
.brand-eyebrow, .eyebrow { margin: 0 0 7px; color: var(--coral); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; }
.brand-eyebrow { color: #b9d7e5; }
.brand-block h1 { margin: 0; font-size: 1.55rem; line-height: 1.1; }

.nav-list { display: grid; gap: 6px; }
.nav-item {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #cfcfcf;
  background: transparent;
  text-align: left;
}
.nav-item:hover, .nav-item.active { color: var(--white); background: rgba(255,255,255,0.11); }
.nav-item.active { box-shadow: inset 3px 0 0 #8ac0d8; }
.nav-item small { min-width: 24px; padding: 3px 6px; border-radius: 999px; background: rgba(255,255,255,0.12); text-align: center; }

.sidebar-note { margin-top: auto; padding: 16px; border: 1px solid rgba(255,255,255,0.18); border-radius: 14px; color: #dce8ee; background: rgba(6,31,49,0.18); font-size: 0.82rem; line-height: 1.45; }
.sidebar-note p { margin: 6px 0 10px; }
.link-button, .text-button { padding: 0; border: 0; color: #2f718f; background: transparent; font-weight: 700; }
.sidebar .link-button { color: #b9d7e5; }
.powered-by { margin: 14px 8px 0; }
.powered-button { width: fit-content; display: inline-flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid rgba(255,255,255,0.25); border-radius: 9px; color: rgba(255,255,255,0.75); background: rgba(6,31,49,0.2); text-decoration: none; transition: background 160ms ease, border-color 160ms ease, transform 160ms ease; }
.powered-button span { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.powered-button img { display: block; width: 82px; height: auto; border-radius: 3px; }
.powered-button:hover { border-color: rgba(255,255,255,0.45); background: rgba(6,31,49,0.36); transform: translateY(-1px); }
.powered-button:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
.mobile-powered { display: none; }

.main-content { min-width: 0; padding: 0 clamp(22px, 4vw, 58px) 58px; }
.topbar { min-height: 224px; display: flex; align-items: center; justify-content: space-between; gap: 28px; margin: 0 calc(clamp(22px, 4vw, 58px) * -1) 26px; padding: 40px clamp(22px, 4vw, 58px); color: var(--white); background: linear-gradient(120deg, #173b57 0%, #245b78 65%, #3f7f9b 100%); }
.topbar h2 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(2.6rem, 5vw, 4.8rem); font-weight: 500; line-height: 0.96; letter-spacing: -0.035em; }
.topbar .eyebrow { color: #c9e2ed; }
.topbar-description { max-width: 560px; margin: 18px 0 0; color: #dbeaf1; font-size: 1rem; line-height: 1.5; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.operator-chip { display: flex; align-items: center; gap: 9px; color: #e2edf2; font-size: 0.85rem; }
.operator-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--white); color: #173b57; font-weight: 700; }

.primary-button, .secondary-button {
  min-height: 42px;
  border-radius: 10px;
  padding: 10px 15px;
  font-weight: 700;
  border: 1px solid var(--black);
}
.primary-button { color: var(--white); background: #173b57; }
.primary-button:hover { background: #245b78; }
.topbar .primary-button { color: #173b57; border-color: var(--white); background: var(--white); }
.topbar .primary-button:hover { background: #e8f1f5; }
.secondary-button { color: var(--black); background: var(--white); }
.secondary-button:hover { background: var(--operational-white); }

.view { display: none; }
.view.active { display: block; }
.notice { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; padding: 14px 16px; border-left: 4px solid #2f718f; background: #e8f2f6; color: #294b5d; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { min-height: 145px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: var(--shadow); }
.metric-card.coral { color: var(--white); border-color: #2f718f; background: #2f718f; }
.metric-card span { font-size: 0.82rem; font-weight: 700; }
.metric-card strong { font-size: 2.25rem; line-height: 1; }
.metric-card small { color: inherit; opacity: 0.72; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: var(--shadow); }
.panel-heading, .view-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading { margin-bottom: 15px; }
.panel-heading h3, .view-tools h3 { margin: 0; font-size: 1.18rem; }
.pipeline-panel { overflow: hidden; }
.pipeline-board { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.pipeline-column { min-height: 178px; padding: 12px; border-radius: 12px; background: var(--surface); }
.pipeline-column-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 0.8rem; font-weight: 700; }
.pipeline-column-header span:last-child { color: var(--ink-soft); }
.pipeline-item { margin-top: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.pipeline-item strong, .pipeline-item span { display: block; }
.pipeline-item span { margin-top: 4px; color: var(--ink-soft); font-size: 0.78rem; }

.stack-list, .record-list { display: grid; gap: 10px; }
.stack-row, .record-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.stack-row:last-child, .record-card:last-child { border-bottom: 0; }
.stack-row strong, .record-card strong { display: block; }
.stack-row p, .record-card p { margin: 4px 0 0; color: var(--ink-soft); font-size: 0.86rem; line-height: 1.4; }
.record-card { padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: var(--shadow); }
.record-body { min-width: 0; flex: 1; }
.record-actions { display: flex; flex-direction: column; gap: 8px; }
.prospect-heading { display: flex; align-items: flex-start; gap: 11px; }
.priority-number { flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--white); background: var(--black); font-size: 0.8rem; font-weight: 800; }
.action-plan { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; margin-bottom: 18px; padding: 20px; border-radius: 16px; color: var(--white); background: #245b78; box-shadow: var(--shadow); }
.action-plan .eyebrow { color: #c9e2ed; }
.action-plan h3 { max-width: 680px; margin: 0; font-family: Georgia, 'Times New Roman', serif; font-size: 1.45rem; font-weight: 500; line-height: 1.2; }
.action-plan ol { margin: 0; padding-left: 20px; color: #e5f1f6; line-height: 1.75; }
.copy-status { min-height: 20px; margin: -6px 0 10px; color: var(--success); font-size: 0.8rem; font-weight: 700; }
.record-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; border-radius: 999px; background: var(--operational-white); color: #3e3e3e; font-size: 0.72rem; font-weight: 700; }
.badge.success { color: var(--success); background: #e5f5ed; }
.badge.warning { color: var(--warning); background: #fff1dc; }
.badge.danger { color: var(--danger); background: #ffe7e7; }

.view-tools { margin-bottom: 18px; }
.view-tools.compact { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.tool-copy { margin: 0; color: var(--ink-soft); }
.search-field, .select-field, .form-field { display: grid; gap: 6px; color: var(--ink-soft); font-size: 0.77rem; font-weight: 700; }
.search-field { flex: 1; }
input, select, textarea { width: 100%; border: 1px solid #cfcfcf; border-radius: 9px; padding: 11px 12px; color: var(--black); background: var(--white); }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 113, 143, 0.25); border-color: #2f718f; }

.inventory-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.product-card { display: flex; flex-direction: column; min-height: 238px; padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--white); box-shadow: var(--shadow); }
.product-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.product-card h3 { margin: 0; font-size: 1.05rem; }
.product-card p { margin: 5px 0 0; color: var(--ink-soft); font-size: 0.82rem; }
.stock-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.stock-counts div { padding: 10px 7px; border-radius: 10px; background: var(--surface); text-align: center; }
.stock-counts strong, .stock-counts span { display: block; }
.stock-counts strong { font-size: 1.2rem; }
.stock-counts span { margin-top: 3px; color: var(--ink-soft); font-size: 0.67rem; }
.product-actions { display: flex; gap: 8px; margin-top: auto; }
.product-actions button { flex: 1; }

.empty-state { padding: 32px; border: 1px dashed #bdbdbd; border-radius: 14px; color: var(--ink-soft); text-align: center; }
.empty-state p { margin: 6px 0 0; }

dialog { width: min(650px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; border: 0; border-radius: 18px; padding: 0; box-shadow: 0 30px 80px rgba(0,0,0,0.28); }
dialog::backdrop { background: rgba(10,10,10,0.65); }
#dialog-form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.dialog-heading h3 { margin: 0; font-size: 1.45rem; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: var(--white); font-size: 1.45rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field.full { grid-column: 1 / -1; }
.form-message { margin-top: 12px; padding: 10px 12px; border-radius: 9px; color: var(--danger); background: #ffe7e7; font-size: 0.85rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .inventory-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-content { padding: 0 14px 92px; }
  .topbar { min-height: 235px; align-items: flex-end; margin: 0 -14px 20px; padding: 28px 14px 24px; }
  .topbar h2 { font-size: clamp(2.7rem, 13vw, 3.8rem); }
  .topbar-description { margin-top: 12px; font-size: 0.86rem; }
  .mobile-powered { display: inline-flex; margin: 14px 0 0; }
  .operator-chip { display: none; }
  .topbar-actions .primary-button { min-width: 116px; }
  .metric-grid, .dashboard-grid, .inventory-list { grid-template-columns: 1fr; }
  .metric-card { min-height: 118px; }
  .view-tools { align-items: flex-end; flex-wrap: wrap; }
  .search-field { min-width: 100%; }
  .pipeline-board { grid-template-columns: repeat(4, 230px); }
  .mobile-nav { position: fixed; z-index: 20; left: 10px; right: 10px; bottom: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px; border: 1px solid #173b57; border-radius: 15px; background: #173b57; box-shadow: 0 12px 35px rgba(23,59,87,0.28); }
  .mobile-nav-item { min-height: 48px; border: 0; border-radius: 10px; color: #bdbdbd; background: transparent; font-size: 0.72rem; }
  .mobile-nav-item.active { color: var(--white); background: #282828; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .record-card { display: block; }
  .record-actions { flex-direction: row; margin-top: 14px; }
  .record-actions button { flex: 1; }
  .action-plan { grid-template-columns: 1fr; gap: 14px; }
}

@media print {
  .sidebar, .topbar, .mobile-nav, .view-tools, .product-actions, .secondary-button, .primary-button { display: none !important; }
  .app-shell { display: block; }
  .main-content { padding: 0; }
  .view { display: none !important; }
  #quotes-view.view.active { display: block !important; }
  .record-card { box-shadow: none; break-inside: avoid; }
}
