[hidden] { display: none !important; }

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #697586;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --soft: #edf7f6;
  --danger: #dc2626;
  --warn-bg: #fef9ec;
  --warn-border: #f59e0b;
}

* { box-sizing: border-box; }

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 28px;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
}

button:hover { border-color: var(--accent); color: var(--accent-dark); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-wrap: wrap;
}

.eyebrow { margin: 0 0 2px; color: var(--accent-dark); font-size: 12px; font-weight: 700; text-transform: uppercase; }
h1, h2, p { margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 15px; margin-bottom: 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions button:last-child { background: var(--accent); border-color: var(--accent); color: #fff; }

.workspace { padding: 12px; display: flex; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }

.layout {
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.order-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-y: auto;
  min-height: 0;
}

.order-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
}
.order-item:hover { background: var(--soft); }
.order-item.active { background: var(--soft); border-left: 3px solid var(--accent); }
.order-item:last-child { border-bottom: 0; }
.order-item-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-item-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

.order-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
}

.status-bar { color: var(--muted); font-size: 13px; }

.part-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* SSO banner styling */
.sso-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.sso-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #ddd; }
.sso-name { font-weight: 600; font-size: 14px; }

.grid { display: grid; gap: 12px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  padding: 6px 10px;
  text-transform: none;
  font-size: 14px;
}

textarea { resize: vertical; }

.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#partFormStatus { font-size: 12px; color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }
tr.low-stock { background: var(--warn-bg); }

.qty-cell { font-weight: 700; }
.badge-low {
  display: inline-block;
  background: var(--warn-border);
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 4px;
}

.row-actions { display: flex; gap: 6px; white-space: nowrap; }
small { color: var(--muted); }

#emptyState { text-align: center; color: var(--muted); padding: 40px; }

@media (max-width: 780px) {
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { flex-direction: column; align-items: stretch; }
}

/* SSO banner actions */
.sso-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.btn-link { color: var(--muted); font-size: 12px; text-decoration: none; padding: 4px 8px; border-radius: 4px; }
.btn-link:hover { color: var(--accent-dark); background: var(--soft); }
.btn-sm { font-size: 12px; min-height: 28px; padding: 0 10px; }
.crm-pick-btn { font-size: 12px; min-height: 28px; padding: 0 10px; color: var(--accent); border-color: var(--accent); }
.btn-service { color: var(--accent); border-color: var(--accent); }
.btn-service:hover { background: var(--accent); color: #fff; }

/* Cross-module reference section (matches Service/Scheduling) */
.xmodule-section { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.xmodule-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.xmodule-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted, var(--muted-foreground, #71717a)); }
.xmodule-link { font-size: 11px; font-weight: 600; color: var(--accent, #0891b2); text-decoration: none; white-space: nowrap; }
.xmodule-link:hover { text-decoration: underline; }

/* Sourcing / RFQ */
.sourcing-empty { font-size: 12px; color: var(--muted-foreground, #71717a); margin: 4px 0 10px; }
.kb-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 12px; }
.kb-table th { text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted-foreground, #71717a); padding: 3px 6px; border-bottom: 1px solid var(--line); }
.kb-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.kb-table tr.kb-best td { background: color-mix(in srgb, var(--accent, #0891b2) 8%, transparent); }
.kb-best-tag { font-size: 9px; font-weight: 700; text-transform: uppercase; color: #059669; background: #05966922; padding: 1px 5px; border-radius: 8px; margin-left: 4px; }
.sourcing-rfqs { display: flex; flex-direction: column; gap: 6px; }
.rfq-row { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.rfq-row-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.rfq-meta { color: var(--muted-foreground, #71717a); font-size: 11px; }
.rfq-chip { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 9px; }
.rfq-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.rfq-actions button { font: inherit; font-size: 11px; padding: 3px 9px; border-radius: 5px; border: 1px solid var(--line); background: transparent; color: var(--ink, #f4f4f5); cursor: pointer; }
.rfq-actions button:hover { border-color: var(--accent, #0891b2); color: var(--accent, #0891b2); }

/* RFQ modal tabs + AI research results */
.rfq-tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); }
.rfq-tab { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted-foreground, #71717a); cursor: pointer; }
.rfq-tab.active { color: var(--accent, #0891b2); border-bottom-color: var(--accent, #0891b2); }
.ai-result { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; margin-bottom: 6px; }
.ai-result-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-result-meta { font-size: 11px; color: var(--muted-foreground, #71717a); }
.ai-result-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.ai-result-actions button { font: inherit; font-size: 11px; padding: 3px 9px; border-radius: 5px; border: 1px solid var(--line); background: transparent; color: var(--ink, #f4f4f5); cursor: pointer; white-space: nowrap; }
.ai-result-actions button:hover:not(:disabled) { border-color: var(--accent, #0891b2); color: var(--accent, #0891b2); }
.ai-result-actions button:disabled { opacity: 0.45; cursor: not-allowed; }
.ai-crm-tag { display: inline-block; font-size: 10px; font-weight: 700; background: #059669; color: #fff; border-radius: 4px; padding: 1px 5px; vertical-align: middle; margin-left: 5px; }

/* AI part-details verification step */
.kf-review { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--soft, transparent); }
.kf-review-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kf-section { margin-bottom: 8px; }
.kf-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground, #71717a); margin-bottom: 2px; }
.kf-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kf-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.kf-check { width: 26px; }
.kf-label { width: 38%; color: var(--muted-foreground, #71717a); }
.kf-value { color: var(--ink, #f4f4f5); }
.kf-table tr:has(input:not(:checked)) .kf-label,
.kf-table tr:has(input:not(:checked)) .kf-value { opacity: 0.4; text-decoration: line-through; }

/* Published part knowledge (standardized section tables) */
.pk-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 12px; }
.pk-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground, #71717a); margin-bottom: 2px; }
.pk-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pk-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.pk-label { color: var(--muted-foreground, #71717a); width: 45%; }
.pk-value { color: var(--ink, #f4f4f5); font-weight: 500; }

/* Manual details editor (Details tab) */
.dm-section { margin-bottom: 10px; }
.dm-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground, #71717a); margin-bottom: 2px; }
.dm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dm-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dm-label { width: 40%; color: var(--muted-foreground, #71717a); }
.dm-value .dm-edit { width: 100%; font: inherit; font-size: 12px; padding: 3px 6px; background: var(--panel, transparent); color: var(--ink, #f4f4f5); border: 1px solid var(--line); border-radius: 4px; }
.dm-del { width: 28px; text-align: center; }
.dm-del button { font: inherit; font-size: 15px; line-height: 1; width: 22px; height: 22px; padding: 0; border-radius: 4px; border: 1px solid var(--line); background: transparent; color: #ef4444; cursor: pointer; }
.dm-del button:hover { border-color: #ef4444; background: #ef444415; }

/* Part image gallery */
.part-img-gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.part-img-cell { position: relative; width: 88px; height: 88px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.part-img-cell.is-main { border-color: var(--accent, #0891b2); box-shadow: 0 0 0 1px var(--accent, #0891b2); }
.part-img-cell img { width: 100%; height: 100%; object-fit: contain; display: block; }
.part-img-main-tag { position: absolute; top: 3px; left: 3px; font-size: 9px; font-weight: 700; text-transform: uppercase; background: var(--accent, #0891b2); color: #fff; padding: 1px 5px; border-radius: 6px; }
.part-img-act, .part-img-del { position: absolute; width: 20px; height: 20px; border-radius: 50%; border: none; cursor: pointer; font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .12s; }
.part-img-cell:hover .part-img-act, .part-img-cell:hover .part-img-del { opacity: 1; }
.part-img-act { bottom: 3px; left: 3px; background: rgba(0,0,0,0.6); color: #fbbf24; }
.part-img-del { top: 3px; right: 3px; background: rgba(0,0,0,0.6); color: #fff; }

/* Part row thumbnail (shown wherever the part is listed) */
.part-name-cell { display: flex; align-items: center; gap: 8px; }
.part-row-thumb { width: 28px; height: 28px; object-fit: contain; border: 1px solid var(--line); border-radius: 5px; background: #fff; flex-shrink: 0; }

/* CRM Picker Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-panel { background: var(--panel); border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); width: 100%; max-width: 520px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--ink); }
.modal-close { min-height: 28px; padding: 0 10px; font-size: 18px; line-height: 1; }
.modal-search { margin: 10px 16px 6px; width: calc(100% - 32px); }
.crm-results { flex: 1; overflow-y: auto; padding: 6px 8px 10px; }
.crm-result-row { padding: 10px; border-radius: 6px; cursor: pointer; }
.crm-result-row:hover { background: var(--soft); }
.crm-result-row strong { display: block; color: var(--ink); font-size: 14px; }
.crm-result-row span { display: block; color: var(--muted); font-size: 12px; }
.crm-no-results { text-align: center; color: var(--muted); padding: 24px; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input { flex: 1; }

/* ── Landing page styles ── */
.landing-wrap { max-width: 900px; margin: 0 auto; padding: 48px 24px 32px; }
.landing-hero { margin-bottom: 40px; }
h1 { margin: 0 0 10px; font-size: 28px; }
.landing-sub { color: var(--muted); font-size: 16px; margin-top: 6px; max-width: 520px; }
.landing-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 24px; }
.btn-signin { display: inline-block; padding: 10px 28px; background: var(--accent); color: #fff;
  border-radius: 8px; font-size: 15px; font-weight: 700; text-decoration: none; }
.btn-signin:hover { background: var(--accent-dark); }
.btn-hub { display: inline-block; padding: 10px 20px; background: transparent; color: var(--muted);
  border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; border: 1px solid var(--line); }
.btn-hub:hover { border-color: var(--accent); color: var(--accent-dark); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.feature-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 18px; }
.feature-card svg { width: 26px; height: 26px; stroke: var(--accent); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; margin-bottom: 12px; }
.feature-card h3 { margin: 0 0 4px; font-size: 14px; }
.feature-card p { margin: 0; color: var(--muted); font-size: 13px; }
.landing-footer { text-align: center; padding: 24px 16px; font-size: 12px; color: var(--muted); }
.landing-footer a { color: inherit; text-decoration: underline; }

#statusBar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 150; border-top: 1px solid var(--border); border-bottom: none !important; }
