/* ── portint.css — Port Intelligent module styles ─────────────────────── */

/* KPI Cards */
.kpi-card {
  border-radius: 1rem; padding: 0.75rem;
  display: flex; align-items: flex-start; gap: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.kpi-icon {
  width: 2.75rem; height: 2.75rem; border-radius: .75rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-num   { font-size: 1.5rem; font-weight: 900; line-height: 1.2; }
.kpi-label { font-size: .75rem; font-weight: 600; color: #64748b; margin-top: .125rem; }
.kpi-sub   { font-size: .6875rem; color: #94a3b8; margin-top: .125rem; }
.dark .kpi-label { color: #94a3b8; }
.dark .kpi-sub   { color: #64748b; }

/* Portfolio table */
.port-table-wrap { overflow-x: auto; border-radius: .75rem; border: 1px solid #e2e8f0; }
.dark .port-table-wrap { border-color: #334155; }
.port-table { width: 100%; min-width: 1400px; border-collapse: collapse; font-size: .8125rem; }
.port-table thead th {
  background: #f8fafc; padding: .625rem .75rem;
  font-weight: 700; color: #64748b; font-size: .6875rem;
  text-align: right; border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.port-table thead th:first-child { text-align: left; position: sticky; left: 0; z-index: 2; background: #f8fafc; }
.dark .port-table thead th { background: #1e293b; color: #64748b; border-color: #334155; }
.dark .port-table thead th:first-child { background: #1e293b; }
.port-table tbody td {
  padding: .5625rem .75rem; text-align: right;
  border-bottom: 1px solid #f1f5f9; color: #374151;
  vertical-align: middle;
}
.port-table tbody td:first-child { text-align: left; position: sticky; left: 0; z-index: 1; background: white; }
.dark .port-table tbody td { color: #cbd5e1; border-color: #1e293b; }
.dark .port-table tbody td:first-child { background: #0f172a; }
.port-table tbody tr:hover td { background: #f8fafc; }
.dark .port-table tbody tr:hover td { background: #1e293b; }
.port-table tbody tr:hover td:first-child { background: #f0f4ff; }
.dark .port-table tbody tr:hover td:first-child { background: #1e3a5f; }
.port-table tfoot td {
  padding: .625rem .75rem; text-align: right;
  font-weight: 700; font-size: .8125rem;
  border-top: 2px solid #e2e8f0; background: #f8fafc;
}
.dark .port-table tfoot td { background: #1e293b; border-color: #334155; }

/* Formation badges */
.formation-badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .6875rem; font-weight: 700;
}
.badge-front   { background: #dbeafe; color: #1d4ed8; }
.badge-mid     { background: #ccfbf1; color: #0d9488; }
.badge-back    { background: #dcfce7; color: #16a34a; }
.badge-cash    { background: #f1f5f9; color: #475569; }
.badge-unknown { background: #fee2e2; color: #dc2626; }

/* P/L colors */
.pi-pos { color: #16a34a; font-weight: 700; }
.pi-neg { color: #dc2626; font-weight: 700; }
.dark .pi-pos { color: #4ade80; }
.dark .pi-neg { color: #f87171; }

/* Toolbar buttons */
.pi-btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .5rem 1rem; border-radius: .5rem;
  font-size: .8125rem; font-weight: 700; cursor: pointer;
  border: none; transition: opacity .15s;
}
.pi-btn:hover { opacity: .85; }
.pi-btn-primary { background: #2563eb; color: #fff; }
.pi-btn-sky     { background: #0ea5e9; color: #fff; }
.pi-btn-slate   { background: #94a3b8; color: #fff; }
.pi-btn-teal    { background: #0d9488; color: #fff; }
.pi-btn-red     { background: #ef4444; color: #fff; }
.pi-btn-ghost   { background: #f1f5f9; color: #374151; }
.dark .pi-btn-ghost { background: #1e293b; color: #cbd5e1; }
.pi-btn:disabled, .pi-btn.disabled { opacity: .4; cursor: not-allowed; }

/* Summary footer cards */
.sum-cards { display: flex; gap: 1rem; padding: 1rem; background: #f8fafc; border-top: 1px solid #e2e8f0; flex-wrap: wrap; }
.dark .sum-cards { background: #1e293b; border-color: #334155; }
.sum-card { min-width: 130px; }
.sum-card-label { font-size: .6875rem; font-weight: 600; color: #94a3b8; }
.sum-card-pct   { font-size: .8125rem; font-weight: 900; }
.sum-card-val   { font-size: .9375rem; font-weight: 900; color: #1e293b; }
.dark .sum-card-val { color: #e2e8f0; }

/* Analyze tabs */
.pi-tabs { display: flex; gap: .25rem; padding: 0 .25rem; overflow-x: auto; }
.pi-tab {
  padding: .5rem 1rem; border-radius: .5rem; font-size: .8125rem; font-weight: 700;
  color: #64748b; background: transparent; border: none; cursor: pointer;
  white-space: nowrap; transition: background .15s, color .15s;
}
.pi-tab:hover  { background: #f1f5f9; color: #374151; }
.pi-tab.active { background: #2563eb; color: #fff; }
.dark .pi-tab  { color: #94a3b8; }
.dark .pi-tab:hover  { background: #1e293b; color: #e2e8f0; }
.pi-tab-badge { background: #ef4444; color: #fff; font-size: .625rem; padding: .1rem .4rem; border-radius: 999px; margin-left: .25rem; }

/* Guide rows */
.pi-guide-row {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: .875rem 1rem; border-bottom: 1px solid #f1f5f9;
}
.dark .pi-guide-row { border-color: #1e293b; }
.pi-guide-weight  { min-width: 80px; text-align: center; }
.pi-guide-wnum    { font-size: 1.125rem; font-weight: 900; color: #2563eb; }
.pi-guide-wlabel  { font-size: .6875rem; font-weight: 700; color: #64748b; }
.pi-guide-pl      { font-size: .8125rem; font-weight: 700; margin-bottom: .25rem; }
.pi-guide-text    { font-size: .8125rem; color: #475569; line-height: 1.6; }
.dark .pi-guide-text { color: #94a3b8; }

/* Switch pairs */
.pi-switch-pair {
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  gap: .75rem; align-items: center;
  padding: .75rem 1rem; border-bottom: 1px solid #f1f5f9;
}
.dark .pi-switch-pair { border-color: #1e293b; }
.pi-switch-card  { background: #f8fafc; border-radius: .5rem; padding: .625rem .75rem; }
.dark .pi-switch-card { background: #1e293b; }
.pi-switch-sname { font-size: .875rem; font-weight: 800; color: #1e293b; }
.dark .pi-switch-sname { color: #e2e8f0; }
.pi-switch-meta  { font-size: .6875rem; color: #94a3b8; margin-top: .125rem; }
.pi-switch-pl    { font-size: .8125rem; font-weight: 700; margin-top: .25rem; }
.pi-switch-period { font-size: .6875rem; color: #94a3b8; }
.pi-switch-dir   { color: #94a3b8; font-size: 1.25rem; }

/* Stock analysis cards */
.pi-stock-card {
  display: flex; align-items: flex-start; gap: .75rem;
  background: #f8fafc; border-radius: .75rem; padding: .875rem;
  margin-bottom: .5rem;
}
.dark .pi-stock-card { background: #1e293b; }
.pi-stock-card-icon {
  width: 2.25rem; height: 2.25rem; border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 1rem;
}
.pi-stock-card-name  { font-size: .875rem; font-weight: 800; color: #1e293b; }
.dark .pi-stock-card-name { color: #e2e8f0; }
.pi-stock-card-guide { font-size: .8125rem; color: #64748b; margin-top: .25rem; line-height: 1.5; }
.dark .pi-stock-card-guide { color: #94a3b8; }

/* Dividend table */
.div-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.div-table th {
  padding: .625rem .75rem; background: #f8fafc; font-weight: 700;
  color: #64748b; font-size: .6875rem; border-bottom: 1px solid #e2e8f0;
  text-align: right; white-space: nowrap;
}
.div-table th:first-child { text-align: left; }
.dark .div-table th { background: #1e293b; border-color: #334155; color: #64748b; }
.div-table td {
  padding: .5625rem .75rem; text-align: right;
  border-bottom: 1px solid #f1f5f9; color: #374151;
}
.div-table td:first-child { text-align: left; }
.dark .div-table td { color: #cbd5e1; border-color: #1e293b; }

/* Balance table */
.bal-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.bal-table th, .bal-table td {
  padding: .625rem .75rem; border-bottom: 1px solid #f1f5f9;
  font-size: .8125rem; text-align: right;
}
.bal-table th { background: #f8fafc; font-weight: 700; color: #64748b; font-size: .6875rem; border-color: #e2e8f0; }
.bal-table th:first-child, .bal-table td:first-child { text-align: left; }
.dark .bal-table th { background: #1e293b; border-color: #334155; }
.dark .bal-table td { border-color: #1e293b; color: #cbd5e1; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 100; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay:not(.hidden) {
  display: flex;
}
.modal-box {
  background: white; border-radius: 1rem; width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden;
}
.dark .modal-box { background: #1e293b; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.125rem 1.375rem; border-bottom: 1px solid #f1f5f9;
}
.dark .modal-header { border-color: #334155; }
.modal-title { font-size: 1rem; font-weight: 800; color: #1e293b; }
.dark .modal-title { color: #e2e8f0; }
.modal-body   { padding: 1.375rem; }
.modal-footer {
  padding: 1rem 1.375rem; border-top: 1px solid #f1f5f9;
  display: flex; gap: .75rem; justify-content: flex-end;
}
.dark .modal-footer { border-color: #334155; }

/* Form elements */
.form-label { font-size: .8125rem; font-weight: 700; color: #374151; margin-bottom: .375rem; display: block; }
.dark .form-label { color: #94a3b8; }
.form-input {
  width: 100%; border: 1px solid #e2e8f0; border-radius: .5rem;
  padding: .625rem .875rem; font-size: .875rem; outline: none;
  transition: border-color .15s; background: white; color: #374151;
}
.form-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.dark .form-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }

/* Custom select dropdown */
.csel-wrap { display: flex; min-width: 0; }
.csel-btn  { display: flex !important; align-items: center; justify-content: space-between; text-align: left; cursor: pointer; }
.dark .csel-btn { background: #0f172a; border-color: #334155; color: #e2e8f0; }

/* Dropdown menu (shared) */
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 200px; background: white;
  border-radius: .75rem; box-shadow: 0 10px 40px rgba(0,0,0,.14);
  border: 1px solid #f1f5f9; z-index: 9999; padding: .375rem;
}
.dark .dropdown-menu { background: #1e293b; border-color: #334155; }
.dropdown-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .75rem; border-radius: .5rem;
  font-size: .875rem; font-weight: 600; color: #374151;
  cursor: pointer; transition: background .15s;
}
.dropdown-item:hover { background: #f8fafc; }
.dark .dropdown-item { color: #e2e8f0; }
.dark .dropdown-item:hover { background: #334155; }

/* SweetAlert2 font size */
.swal2-popup { font-size: 0.8rem !important; }

/* Fixed-position dropdown for stock combobox and basket picker */
.pi-dd {
  display: none; position: fixed; z-index: 99999;
  background: white; border-radius: .5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  border: 1px solid #e2e8f0;
  max-height: 200px; overflow-y: auto; padding: .25rem;
}
.dark .pi-dd { background: #1e293b; border-color: #334155; }
.pi-dd .dropdown-item { font-size: .8125rem; }

/* Basket button (standalone, not inheriting form-input width:100%) */
.bsk-btn {
  display: flex; align-items: center; justify-content: space-between; gap: .25rem;
  width: 100%; height: 100%; padding: .5rem .375rem; font-size: .8125rem;
  background: white; border: 1px solid #e2e8f0; border-radius: .5rem;
  color: #374151; cursor: pointer; text-align: left; line-height: 1.4;
  transition: border-color .15s;
}
.dark .bsk-btn { background: #0f172a; border-color: #334155; color: #e2e8f0; }
.bsk-btn:disabled { opacity: .45; cursor: not-allowed; }
