/* PRINTFACTORY — Industrial Design System */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --sb:      #0f1724;
  --sb-2:    #1a2438;
  --sb-bd:   #1e2d45;
  --primary: #e8541a;
  --primary-d:#c44010;
  --navy:    #1b2b4b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #3b82f6;
  --main-bg: #eef0f5;
  --card:    #ffffff;
  --bd:      #dde2eb;
  --bd-light:#f0f2f6;
  --t1:      #1a2035;
  --t2:      #4b5a72;
  --t3:      #8b99b5;
  --r:       4px;
  --r-lg:    6px;
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 12px; color: var(--t1); -webkit-font-smoothing: antialiased; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bd-light); }
::-webkit-scrollbar-thumb { background: #c4cad8; border-radius: 2px; }

/* ── Sidebar ── */
#sidebar-container { background: var(--sb); width: 220px; flex-shrink: 0; }
.nav-logo { padding: 14px 14px 12px; border-bottom: 1px solid var(--sb-bd); display: flex; align-items: center; }
.nav-body { flex: 1; padding: 8px 6px; overflow-y: auto; }
.nav-section-label { font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #3d5070; padding: 8px 6px 4px; }
.nav-item { display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: var(--r); font-size: 11px; font-weight: 500; color: #6b80a0; cursor: pointer; text-decoration: none; transition: all 0.12s; }
.nav-item:hover { background: var(--sb-2); color: #c4d0e8; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ni { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.75; }
.nav-item.active .ni { opacity: 1; filter: brightness(0) invert(1); }
.nav-item:not(.active):hover .ni { filter: brightness(0) invert(0.85); }
/* Parent khi có child đang active: nền nhạt, chữ sáng, không dùng màu cam */
.nav-parent.active { background: var(--sb-2); color: #c4d0e8; }
.nav-parent.active .ni { opacity: 1; filter: brightness(0) invert(0.85); }
.nav-sub { padding-left: 14px; }
.nav-sub .nav-item { font-size: 11px; padding: 5px 8px; color: #556b8a; }
.nav-sub .nav-item::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: #3d5070; flex-shrink: 0; }
.nav-sub .nav-item.active { background: var(--primary); color: #fff; }
.nav-sub .nav-item.active::before { background: white; }
.nav-footer { padding: 10px 10px 12px; border-top: 1px solid var(--sb-bd); display: flex; align-items: center; gap: 8px; }
.nav-user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: white; flex-shrink: 0; }
.nav-user-name { font-size: 11px; font-weight: 600; color: #c4d0e8; line-height: 1.3; }
.nav-user-role { font-size: 9px; color: #4b6080; }

/* ── Header ── */
#header-container { background: var(--card); border-bottom: 1px solid var(--bd); }
.page-header { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.page-title { font-size: 13px; font-weight: 700; color: var(--t1); }
.page-subtitle { font-size: 10px; color: var(--t3); margin-top: 1px; }
.header-badge-live { display: flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid #c6f6d5; background: #f0fdf4; color: #166534; font-size: 10px; font-weight: 600; border-radius: 10px; }
.header-badge-live::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--success); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.4 } }

/* ── KPI Cards ── */
.kpi-grid { display: grid; gap: 10px; margin-bottom: 14px; }
.kpi-card { background: var(--card); border: 1px solid var(--bd); border-radius: var(--r-lg); padding: 12px 14px; }
.kpi-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--t3); }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 20px; font-weight: 700; color: var(--t1); margin-top: 3px; line-height: 1; }
.kpi-value.sm { font-size: 17px; }
.kpi-delta { font-size: 10px; margin-top: 3px; display: flex; align-items: center; gap: 3px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ── Cards ── */
.card { background: var(--card); border: 1px solid var(--bd); border-radius: var(--r-lg); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--bd-light); }
.card-title { font-size: 12px; font-weight: 700; color: var(--t1); }
.card-body { padding: 14px; }

/* ── Tables ── */
.dt { width: 100%; border-collapse: collapse; font-size: 11px; }
.dt thead tr { background: #f7f8fa; }
.dt th { text-align: left; padding: 6px 10px; font-size: 10px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--bd); white-space: nowrap; }
.dt th.r { text-align: right; }
.dt td { padding: 7px 10px; color: var(--t2); border-bottom: 1px solid var(--bd-light); white-space: nowrap; }
.dt td.r { text-align: right; }
.dt td.bold { font-weight: 600; color: var(--t1); }
.dt td.mono { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600; color: var(--navy); }
.dt tbody tr:hover { background: #fafbfd; }
.dt tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 3px; font-size: 10px; font-weight: 700; letter-spacing: 0.02em; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f3f4f6; color: #374151; }
.badge-orange  { background: #fff7ed; color: #9a3412; }

/* ── Status dot ── */
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot.green  { background: var(--success); box-shadow: 0 0 0 2px #d1fae5; }
.dot.yellow { background: var(--warning); box-shadow: 0 0 0 2px #fef3c7; }
.dot.red    { background: var(--danger);  box-shadow: 0 0 0 2px #fee2e2; }
.dot.gray   { background: #9ca3af;        box-shadow: 0 0 0 2px #f3f4f6; }
.dot.blue   { background: var(--info);    box-shadow: 0 0 0 2px #dbeafe; }
.dot.pulse  { animation: pulse 1.5s infinite; }

/* ── Inputs ── */
.fi { width: 100%; padding: 5px 9px; font-size: 11px; font-family: inherit; border: 1px solid var(--bd); border-radius: var(--r); color: var(--t1); outline: none; background: white; transition: border-color 0.12s, box-shadow 0.12s; }
.fi:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(232,84,26,0.12); }
.fi::placeholder { color: var(--t3); }
.fi:read-only { background: #f7f8fa; color: var(--t3); cursor: default; }
.fi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--t3); margin-bottom: 4px; display: block; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 5px 12px; font-size: 11px; font-weight: 600; border-radius: var(--r); border: 1px solid transparent; cursor: pointer; transition: all 0.12s; white-space: nowrap; font-family: inherit; }
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-secondary { background: white; color: var(--t2); border-color: var(--bd); }
.btn-secondary:hover { background: #f7f8fa; color: var(--t1); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 3px 8px; font-size: 10px; }
.btn-xs { padding: 2px 6px; font-size: 9px; }
.btn-icon { padding: 5px; border-radius: var(--r); border: 1px solid var(--bd); background: white; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--t2); transition: all 0.12s; }
.btn-icon:hover { background: #f7f8fa; color: var(--t1); }

/* ── Progress ── */
.prog { height: 4px; background: var(--bd-light); border-radius: 2px; overflow: hidden; }
.prog-bar { height: 100%; border-radius: 2px; transition: width 0.4s; }
.prog-bar.orange { background: var(--primary); }
.prog-bar.green  { background: var(--success); }
.prog-bar.blue   { background: var(--info); }
.prog-bar.red    { background: var(--danger); }
.prog-bar.yellow { background: var(--warning); }

/* ── Alert strips ── */
.alert-strip { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border-radius: var(--r); border-left: 3px solid; }
.alert-strip.danger  { background: #fef2f2; border-color: var(--danger); }
.alert-strip.warning { background: #fffbeb; border-color: var(--warning); }
.alert-strip.info    { background: #eff6ff; border-color: var(--info); }
.alert-strip.success { background: #f0fdf4; border-color: var(--success); }
.alert-strip-title { font-size: 11px; font-weight: 600; color: var(--t1); }
.alert-strip-sub   { font-size: 10px; color: var(--t3); margin-top: 1px; }

/* ── Section tabs ── */
.tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--bd); margin-bottom: 12px; }
.tab { padding: 7px 12px; font-size: 11px; font-weight: 600; color: var(--t3); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.12s; }
.tab:hover { color: var(--t1); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Filter row ── */
.filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-seg { display: flex; border: 1px solid var(--bd); border-radius: var(--r); overflow: hidden; background: white; }
.filter-seg-btn { padding: 4px 10px; font-size: 10px; font-weight: 600; color: var(--t3); cursor: pointer; border: none; background: none; transition: all 0.12s; }
.filter-seg-btn.active { background: var(--primary); color: white; }
.filter-seg-btn:not(.active):hover { background: #f7f8fa; color: var(--t1); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,14,26,0.55); display: none; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: var(--r-lg); box-shadow: 0 20px 60px rgba(0,0,0,0.2); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--bd-light); }
.modal-title { font-size: 13px; font-weight: 700; color: var(--t1); }
.modal-body { padding: 16px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--bd-light); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Step wizard ── */
.step-row { display: flex; align-items: center; gap: 0; margin-bottom: 16px; }
.step-item { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: var(--r); font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.12s; }
.step-item.done, .step-item.active { background: var(--primary); color: white; }
.step-item.idle { background: white; color: var(--t3); border: 1px solid var(--bd); }
.step-connector { width: 24px; height: 1px; background: var(--bd); flex-shrink: 0; }
.step-circle { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; flex-shrink: 0; }
.step-item.active .step-circle { background: white; color: var(--primary); }
.step-item.done .step-circle { background: rgba(255,255,255,0.25); color: white; }
.step-item.idle .step-circle { background: var(--bd); color: var(--t3); }

/* ── Stage progress row ── */
.stage-row { display: grid; gap: 8px; }
.stage-item { text-align: center; }
.stage-icon { width: 36px; height: 36px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; margin: 0 auto 5px; }
.stage-pct { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; }
.stage-label { font-size: 10px; font-weight: 600; color: var(--t3); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Gantt ── */
.gantt-row { position: relative; display: flex; align-items: center; border-bottom: 1px solid var(--bd-light); }
.gantt-label { width: 220px; flex-shrink: 0; padding: 8px 12px; border-right: 1px solid var(--bd-light); }
.gantt-label-main { font-size: 11px; font-weight: 600; color: var(--t1); }
.gantt-label-sub { font-size: 10px; color: var(--t3); }
.gantt-area { flex: 1; position: relative; height: 36px; }
.gantt-bar { height: 20px; border-radius: 3px; position: absolute; top: 8px; display: flex; align-items: center; padding: 0 6px; font-size: 9px; font-weight: 700; color: white; white-space: nowrap; overflow: hidden; cursor: pointer; transition: opacity 0.12s; }
.gantt-bar:hover { opacity: 0.8; }
.gantt-col-bg { position: absolute; top: 0; bottom: 0; width: calc(100%/7); background: rgba(232,84,26,0.04); border-left: 1px dashed rgba(232,84,26,0.2); }

/* ── Chat ── */
.chat-msg { display: flex; gap: 8px; margin-bottom: 12px; }
.chat-avatar { width: 28px; height: 28px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; flex-shrink: 0; }
.chat-bubble { border-radius: 0 var(--r-lg) var(--r-lg) var(--r-lg); padding: 10px 12px; font-size: 11px; line-height: 1.6; max-width: 600px; }
.chat-bubble.ai { background: white; border: 1px solid var(--bd); color: var(--t2); }
.chat-bubble.user { background: var(--navy); color: #c4d0e8; border-radius: var(--r-lg) 0 var(--r-lg) var(--r-lg); }
.chat-time { font-size: 10px; color: var(--t3); margin-top: 4px; }
.typing-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--t3); animation: td 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.4s; }
.typing-dot:nth-child(3) { animation-delay: 0.8s; }
@keyframes td { 0%,80%,100% { opacity:0.2; transform:translateY(0); } 40% { opacity:1; transform:translateY(-3px); } }

/* ── Misc utility ── */
.mono { font-family: 'JetBrains Mono', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divide-light > * + * { border-top: 1px solid var(--bd-light); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-info    { color: var(--info); }
.bg-primary { background: var(--primary); }
.separator { height: 1px; background: var(--bd-light); margin: 10px 0; }
