/* ===== TPIS Global Styles ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --green: #059669;
  --green-light: #ecfdf5;
  --red: #dc2626;
  --red-light: #fef2f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--gray-50); color: var(--gray-900); font-size: 14px; line-height: 1.5; }

/* ===== Login ===== */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.login-box { background: #fff; border-radius: var(--radius-lg); padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 2rem; font-size: 28px; color: var(--blue); }
.login-title { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.login-sub { font-size: 12px; color: var(--gray-500); }
.error-msg { background: var(--red-light); color: var(--red); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 0.75rem; }

/* ===== Layout ===== */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ===== Sidebar ===== */
.sidebar { width: 230px; min-width: 230px; background: #fff; border-right: 1px solid var(--gray-200); display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 1.25rem 1rem; border-bottom: 1px solid var(--gray-200); }
.sidebar-title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.sidebar-sub { font-size: 10px; color: var(--gray-400); }
.sidebar-nav { flex: 1; padding: 0.5rem 0; }
.nav-section { font-size: 10px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.8px; padding: 0.75rem 1rem 0.25rem; }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 8px 1rem; font-size: 13px; color: var(--gray-600); cursor: pointer; text-decoration: none; border-radius: 0; transition: background 0.1s; }
.nav-link:hover { background: var(--gray-50); color: var(--gray-900); }
.nav-link.active { background: var(--blue-light); color: var(--blue); font-weight: 500; border-right: 2px solid var(--blue); }
.nav-link i { font-size: 16px; }
.sidebar-footer { padding: 0.75rem; border-top: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.user-pill { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }

/* ===== Main content ===== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { background: #fff; border-bottom: 1px solid var(--gray-200); padding: 0.875rem 1.5rem; display: flex; align-items: center; justify-content: space-between; min-height: 58px; }
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.page-heading { font-size: 16px; font-weight: 600; color: var(--gray-900); }
.breadcrumb { font-size: 13px; color: var(--gray-400); }
.topbar-right { display: flex; gap: 8px; }
.page-body { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--gray-200); background: #fff; color: var(--gray-700); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.1s; white-space: nowrap; }
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border-color: var(--gray-300); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.icon-btn { background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 4px; font-size: 16px; }
.icon-btn:hover { color: var(--gray-700); }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--gray-600); margin-bottom: 4px; }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 13px; color: var(--gray-900); background: #fff; outline: none; transition: border-color 0.1s; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.6; }
select.input { cursor: pointer; }

/* ===== Cards ===== */
.card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 1.25rem; }
.card-title { font-size: 13px; font-weight: 600; color: var(--gray-500); margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-card { background: var(--gray-50); border-radius: var(--radius); padding: 1rem; }
.metric-label { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.metric-sub { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ===== Grid ===== */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0.75rem; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 20px; }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 8px 12px; background: var(--gray-50); font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--gray-200); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-50); }

/* ===== Risk items ===== */
.risk-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); margin-bottom: 4px; font-size: 13px; }
.risk-high { background: var(--red-light); color: #991b1b; }
.risk-med { background: var(--amber-light); color: #92400e; }
.risk-low { background: var(--green-light); color: #065f46; }

/* ===== Pipeline ===== */
.pipeline { display: flex; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 1.5rem; }
.pipeline-step { flex: 1; padding: 10px 8px; text-align: center; font-size: 11px; color: var(--gray-400); border-right: 1px solid var(--gray-200); cursor: pointer; background: #fff; transition: background 0.1s; }
.pipeline-step:last-child { border-right: none; }
.pipeline-step i { display: block; font-size: 18px; margin-bottom: 3px; }
.pipeline-step.done { background: var(--green-light); color: var(--green); }
.pipeline-step.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }
.pipeline-step.locked { opacity: 0.35; cursor: not-allowed; }

/* ===== AI thinking ===== */
.ai-bubble { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--blue-light); border-radius: var(--radius); font-size: 13px; color: var(--blue); margin-bottom: 8px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite; display: inline-block; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ===== Document editor ===== */
.doc-editor { border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; }
.doc-editor-toolbar { padding: 8px 12px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); display: flex; gap: 6px; flex-wrap: wrap; }
.doc-editor-toolbar button { padding: 4px 8px; font-size: 12px; border: 1px solid var(--gray-200); border-radius: 4px; background: #fff; cursor: pointer; }
.doc-editor-toolbar button:hover { background: var(--gray-100); }
.doc-editor-body { padding: 1rem; }
.doc-editor-body textarea { width: 100%; border: none; outline: none; font-size: 13px; line-height: 1.8; color: var(--gray-800); resize: none; min-height: 320px; font-family: 'Georgia', serif; }

/* ===== Price feedback ===== */
.price-feedback { padding: 8px 12px; border-radius: var(--radius); font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.price-feedback.good { background: var(--green-light); color: #065f46; }
.price-feedback.too_high { background: var(--red-light); color: #991b1b; }
.price-feedback.too_low { background: var(--amber-light); color: #92400e; }
.price-feedback.risky { background: var(--amber-light); color: #92400e; }

/* ===== Email compose ===== */
.email-compose { border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; }
.email-field { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--gray-100); }
.email-field-label { font-size: 12px; color: var(--gray-400); width: 48px; min-width: 48px; }
.email-field input { flex: 1; border: none; outline: none; font-size: 13px; color: var(--gray-900); }
.email-body-area { padding: 12px; }
.email-body-area textarea { width: 100%; border: none; outline: none; font-size: 13px; line-height: 1.7; color: var(--gray-800); resize: none; min-height: 200px; }
.email-attachments { padding: 10px 12px; background: var(--gray-50); border-top: 1px solid var(--gray-200); }
.attachment-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; background: #fff; border: 1px solid var(--gray-200); font-size: 11px; color: var(--gray-600); margin: 2px; }

/* ===== Misc ===== */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-400); }
.empty-state i { font-size: 36px; display: block; margin-bottom: 0.75rem; }
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; background: var(--gray-100); font-size: 11px; color: var(--gray-600); margin: 1px; }
.separator { border: none; border-top: 1px solid var(--gray-100); margin: 0.75rem 0; }
.success-banner { background: var(--green); color: #fff; border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; }
.success-banner i { font-size: 40px; display: block; margin-bottom: 0.75rem; }
.confirm-box { border: 2px solid var(--red); border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; }
.win-bar { height: 5px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.win-bar-fill { height: 100%; border-radius: 4px; }
.supplier-card { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-500); }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
