/* =================================================================
   MAESTROS MODULE – Reusable component classes
   Replaces inline styles used across maestros drawers & cards.
   ================================================================= */

/* ── Dashboard Metric Cards ─────────────────────────────────────── */
.md-metric-card {
    background: rgba(22, 32, 50, 0.8);
    border: 1px solid rgba(45, 59, 85, 0.6);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* refactor(audit): MANT-03 — Dashboard layout + inline style replacements */
.md-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.md-grid-1-1-320 { display: grid; grid-template-columns: 1fr 1fr 320px; gap: 16px; margin-bottom: 24px; }
.md-flex-col-gap16 { display: flex; flex-direction: column; gap: 16px; }
.md-flex-col-gap10 { display: flex; flex-direction: column; gap: 10px; }
.md-flex-col-gap8  { display: flex; flex-direction: column; gap: 8px; }
.md-icon-emoji { font-size: 1.4rem; }
.md-icon-materiales { background: linear-gradient(135deg, #6366f1, #818cf8); }
.md-icon-proveedores { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }
.md-icon-servicios { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.md-icon-relaciones { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.md-loading-text { color: #64748b; font-size: 0.85rem; }
.md-alert-header { border-bottom-color: rgba(251, 191, 36, 0.2); }
.md-alert-header h4 { color: #fbbf24; }
.md-quick-action-icon { font-size: 1rem; }

.md-metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.4), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.md-metric-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.md-metric-card:hover::before {
    opacity: 1;
}

.md-metric-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.md-metric-info {
    flex: 1;
    min-width: 0;
}

.md-metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: #f1f5f9;
    line-height: 1;
    letter-spacing: -0.02em;
}

.md-metric-label {
    font-size: 0.82rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.md-metric-sub {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 2px;
}

/* ── Dashboard Panels ───────────────────────────────────────────── */
.md-panel {
    background: rgba(22, 32, 50, 0.8);
    border: 1px solid rgba(45, 59, 85, 0.6);
    border-radius: 14px;
    overflow: hidden;
}

.md-panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(45, 59, 85, 0.5);
    background: rgba(0, 0, 0, 0.15);
}

.md-panel-header h4 {
    margin: 0;
    font-size: 0.88rem;
    color: #e2e8f0;
    font-weight: 600;
}

.md-panel-body {
    padding: 16px 20px;
}

.m-percent-input,
.ai-percent-input {
    position: relative;
    display: flex;
    align-items: center;
}

.m-percent-input input,
.ai-percent-input input {
    width: 100%;
    padding-right: 24px;
}

.m-percent-input span,
.ai-percent-input span {
    position: absolute;
    right: 9px;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 700;
    pointer-events: none;
}

/* ── Distribution bars ──────────────────────────────────────────── */
.md-dist-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.md-dist-row:last-child {
    margin-bottom: 0;
}

.md-dist-name {
    width: 120px;
    font-size: 0.78rem;
    color: #cbd5e1;
    text-align: right;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.md-dist-bar-wrap {
    flex: 1;
    height: 22px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.md-dist-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.md-dist-count {
    width: 36px;
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 600;
    font-family: monospace;
    flex-shrink: 0;
}

/* ── Quick Action buttons ───────────────────────────────────────── */
.md-quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(45, 59, 85, 0.4);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: #cbd5e1;
    font-weight: 500;
}

.md-quick-action:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: #e0e7ff;
    transform: translateX(4px);
}

/* ── Alert rows ─────────────────────────────────────────────────── */
.md-alert-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.4);
    cursor: pointer;
    transition: all 0.2s;
}

.md-alert-row:hover {
    background: rgba(251, 191, 36, 0.08);
}

.md-alert-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    animation: md-pulse 2s infinite;
}

@keyframes md-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.md-alert-text {
    font-size: 0.82rem;
    color: #cbd5e1;
    flex: 1;
}

.md-alert-arrow {
    color: #64748b;
    font-size: 0.9rem;
}

/* ── Recent materials list ──────────────────────────────────────── */
.md-recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(45, 59, 85, 0.3);
}

.md-recent-item:last-child {
    border-bottom: none;
}

.md-recent-code {
    font-family: monospace;
    font-size: 0.8rem;
    color: #6366f1;
    font-weight: 600;
    width: 70px;
    flex-shrink: 0;
}

.md-recent-name {
    font-size: 0.85rem;
    color: #e2e8f0;
}

/* ── Drawer structure ───────────────────────────────────────────── */
.m-drawer-hero {
    padding: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.m-drawer-hero .m-hero-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.m-drawer-hero .m-hero-row-center {
    display: flex;
    gap: 20px;
    align-items: center;
}

.m-drawer-avatar {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: white;
}

.m-drawer-avatar.lg {
    width: 60px;
    height: 60px;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.m-drawer-title {
    margin: 0;
    font-size: 1.2rem;
    color: white;
}

.m-drawer-title.lg {
    font-size: 1.5rem;
}

.m-drawer-badge {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    margin-top: 5px;
}

.m-drawer-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.m-drawer-close.round {
    background: rgba(255, 255, 255, 0.05);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.m-drawer-body {
    padding: 25px;
    overflow-y: auto;
    flex-grow: 1;
    background: #0b1120;
}

.m-drawer-footer {
    padding: 20px;
    border-top: 1px solid #2d3b55;
    background: #0f172a;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.m-card {
    background: #162032;
    border-radius: 12px;
    border: 1px solid #2d3b55;
    overflow: hidden;
    margin-bottom: 20px;
}

.m-card:last-child {
    margin-bottom: 0;
}

.m-card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #2d3b55;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.m-card-header h4 {
    margin: 0;
    font-size: 0.95rem;
    color: #e2e8f0;
    font-weight: 600;
}

.m-card-body {
    padding: 20px;
}

/* ── Grid layouts ───────────────────────────────────────────────── */
.m-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.m-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.m-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.m-fields {
    display: grid;
    gap: 15px;
}

.m-fields-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.m-span-2 {
    grid-column: span 2;
}

.m-span-full {
    grid-column: 1 / -1;
}

/* ── Field label / value ────────────────────────────────────────── */
.m-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 4px;
}

.m-label.sm {
    font-size: 0.7rem;
}

.m-value {
    font-size: 0.95rem;
    color: #f1f5f9;
}

.m-value.lg {
    font-size: 1.1rem;
    font-weight: bold;
}

.m-value.mono {
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.m-value.green {
    color: #34d399;
}

.m-value.blue {
    color: #60a5fa;
}

.m-value.yellow {
    color: #facc15;
}

.m-value.red {
    color: #f87171;
}

.m-value.small {
    font-size: 0.85rem;
}

/* ── Contact icon row ───────────────────────────────────────────── */
.m-icon-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.m-icon-circle {
    width: 36px;
    height: 36px;
    background: rgba(251, 191, 36, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fbbf24;
    flex-shrink: 0;
}

/* ── Desglose badge row ─────────────────────────────────────────── */
.m-desglose-row {
    grid-column: span 2;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.m-desglose-row .m-label {
    margin: 0;
    white-space: nowrap;
}

.m-desglose-badge {
    font-size: 0.85rem;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
}

/* ── Config flag tiles (checkbox grid in drawers) ──────────────── */
.mat-config-flag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.1);
    cursor: help;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
}

.mat-config-flag:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.05);
}

.mat-config-label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 500;
    line-height: 1.2;
}

/* Tooltip popup on hover */
.mat-config-flag::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #e2e8f0;
    font-size: 0.7rem;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    width: 220px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: normal;
}

.mat-config-flag:hover::after {
    opacity: 1;
}

/* ── Flex column with gap ───────────────────────────────────────── */
.m-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.m-btn-close {
    padding: 8px 16px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
}

.m-btn-edit {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    font-weight: 500;
}

/* ── Drawer gradients (per entity) ──────────────────────────────── */
.m-hero-proveedor {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.m-hero-material {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
}

.m-hero-servicio {
    background: linear-gradient(135deg, #4c1d95 0%, #2e1065 100%);
}

.m-hero-rel-mat {
    background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%);
}

.m-hero-rel-serv {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.m-hero-variantes {
    background: linear-gradient(135deg, #be185d 0%, #831843 100%);
}

/* ── Form controls (edit mode) ─────────────────────────────────── */
.m-drawer-body select,
.m-drawer-body select option {
    background-color: #1e293b;
    color: #f1f5f9;
}

.m-drawer-body select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 32px 8px 12px;
    font-size: 0.9rem;
    border: 1px solid #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    width: 100%;
}

.m-drawer-body select:focus {
    outline: none;
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.m-drawer-body select:hover {
    border-color: #475569;
}

.m-drawer-body select option {
    padding: 8px 12px;
}

.m-drawer-body select option:checked {
    background-color: var(--accent-primary, #6366f1);
    color: white;
}

.m-drawer-body input[type="text"],
.m-drawer-body input[type="number"],
.m-drawer-body input[type="email"],
.m-drawer-body input[type="tel"],
.m-drawer-body input[type="url"] {
    background-color: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.m-drawer-body input:focus {
    outline: none;
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ══════════════════════════════════════════════════════════════════
   TABLE IMPROVEMENTS – Filters, Sticky Headers, Badges
   ══════════════════════════════════════════════════════════════════ */

/* ── Filter Bar ─────────────────────────────────────────────────── */
.mt-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(45, 59, 85, 0.4);
    border-radius: 10px;
}

.mt-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mt-filter-label {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    white-space: nowrap;
}

.mt-filter-select {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 5px 28px 5px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
    transition: border-color 0.2s;
    min-width: 100px;
}

.mt-filter-select option {
    background: #1e293b;
    color: #e2e8f0;
}

.mt-filter-select:hover {
    border-color: #475569;
}

.mt-filter-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.mt-filter-clear {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
}

.mt-filter-clear:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

/* ── Scrollable Table with Sticky Header ─────────────────────────── */
.mt-table-scroll {
    max-height: 65vh;
    overflow-y: auto;
    border-radius: 8px;
}

.mt-table-scroll thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg, #1a202c);
    z-index: 5;
    box-shadow: 0 1px 0 rgba(45, 59, 85, 0.5);
}

/* ── Tipo Oferta badges (Proveedores) ────────────────────────────── */
.mt-tipo-badge {
    font-size: 0.68rem;
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: inline-block;
}

.mt-tipo-badge.tipo-mp {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.mt-tipo-badge.tipo-me {
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.mt-tipo-badge.tipo-serv,
.mt-tipo-badge.tipo-servicio {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.mt-tipo-badge.tipo-maquila {
    background: rgba(236, 72, 153, 0.12);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

.mt-tipo-badge.tipo-default {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

/* ══════════════════════════════════════════════════════════════════
   PHASE 4 – Global Experience: Skeletons, Transitions, Polish
   ══════════════════════════════════════════════════════════════════ */

/* ── Skeleton Table Rows ─────────────────────────────────────────── */
.mt-skel-row td {
    padding: 16px 12px !important;
}

.mt-skel-bar {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
    animation: mtShimmer 1.4s ease-in-out infinite;
}

.mt-skel-bar.w-short { width: 50px; }
.mt-skel-bar.w-med   { width: 120px; }
.mt-skel-bar.w-long  { width: 200px; }
.mt-skel-bar.w-pill  { width: 55px; height: 20px; border-radius: 999px; }

@keyframes mtShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Fade-in for Maestros sub-module switch ──────────────────────── */
#section-maestros .sub-module-section {
    opacity: 1 !important;
    animation: none !important;
}

#section-maestros .sub-module-section.mt-fade-enter {
    animation: mtFadeIn 0.35s ease-out !important;
}

@keyframes mtFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Count Badge Pulse on Update ─────────────────────────────────── */
.mt-badge-pop {
    animation: mtBadgePop 0.4s ease;
}

@keyframes mtBadgePop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.15); background: #48bb78; }
    100% { transform: scale(1); }
}

/* ── Consistent table header separator ───────────────────────────── */
.mt-table-scroll thead tr {
    border-bottom: 2px solid rgba(45, 59, 85, 0.6);
}

/* ── Empty state for tables ──────────────────────────────────────── */
.mt-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #475569;
    font-size: 0.9rem;
}

.mt-empty-state .mt-empty-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* ══════════════════════════════════════════════════════════════════
   ALTA INTELIGENTE – Premium Form System
   ══════════════════════════════════════════════════════════════════ */

/* ── Header ── */
.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(51, 65, 85, 0.3);
    border-radius: 0.75rem;
    backdrop-filter: blur(8px);
}
.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ai-header-right { display: flex; gap: 8px; }
.ai-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
}
.ai-subtitle {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: #64748b;
}
.ai-btn-ghost {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid rgba(51, 65, 85, 0.4);
    border-radius: 0.4rem;
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-btn-ghost:hover {
    background: rgba(51, 65, 85, 0.3);
    color: #e2e8f0;
    border-color: rgba(51, 65, 85, 0.6);
}

/* ── Form Grid ── */
.ai-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Cards ── */
.ai-card {
    background: rgba(22, 32, 50, 0.7);
    border: 1px solid rgba(51, 65, 85, 0.35);
    border-radius: 0.75rem;
    overflow: hidden;
    backdrop-filter: blur(6px);
    transition: border-color 0.2s;
}
.ai-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
}
.ai-card-wide {
    grid-column: 1 / -1;
}
.ai-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.25);
    background: rgba(0, 0, 0, 0.15);
}
.ai-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
}
.ai-step-badge {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
}
.ai-badge-info {
    font-size: 0.68rem;
    padding: 3px 10px;
    border-radius: 6px;
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.2);
    font-weight: 600;
}
.ai-card-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Fields ── */
.ai-field { display: flex; flex-direction: column; gap: 4px; }
.ai-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.ai-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.ai-label-sm {
    font-size: 0.68rem;
    font-weight: 500;
    color: #64748b;
}
.ai-input {
    padding: 9px 12px;
    background: rgba(15, 23, 42, 0.6);
    color: #f1f5f9;
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 0.5rem;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.ai-input:focus {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}
.ai-input::placeholder {
    color: #475569;
}
.ai-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 28px;
}

/* ── Toggle Pills ── */
.ai-toggle-group {
    display: flex;
    gap: 6px;
    background: rgba(15, 23, 42, 0.4);
    padding: 4px;
    border-radius: 0.5rem;
    border: 1px solid rgba(51, 65, 85, 0.3);
}
.ai-toggle-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
    user-select: none;
}
.ai-toggle-pill input[type="radio"] {
    display: none;
}
.ai-toggle-pill:hover {
    color: #94a3b8;
    background: rgba(51, 65, 85, 0.2);
}
.ai-toggle-active {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
    font-weight: 600;
}

/* ── Conditions Grid ── */
.ai-conditions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

/* ── Collapsible Details ── */
.ai-details {
    border-top: 1px solid rgba(51, 65, 85, 0.2);
    padding-top: 12px;
}
.ai-details-summary {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}
.ai-details-summary::-webkit-details-marker { display: none; }
.ai-details-summary::before {
    content: '▶';
    font-size: 0.6rem;
    transition: transform 0.2s;
}
.ai-details[open] .ai-details-summary::before {
    transform: rotate(90deg);
}
.ai-details-summary:hover { color: #94a3b8; }

/* ── Action Buttons ── */
.ai-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid rgba(51, 65, 85, 0.2);
    margin-top: 4px;
}
.ai-btn-cancel {
    padding: 9px 20px;
    background: transparent;
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 0.5rem;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-btn-cancel:hover {
    background: rgba(51, 65, 85, 0.3);
    color: #e2e8f0;
}
.ai-btn-save {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 22px;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    border: none;
    border-radius: 0.5rem;
    color: white;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
.ai-btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

/* ── Bulk Upload Grid ── */
.ai-bulk-wrapper {
    overflow: visible;
    border: 1px solid rgba(51, 65, 85, 0.25);
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.3);
    min-height: 320px;
    padding-bottom: 200px;
}
.ai-bulk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.ai-bulk-th {
    padding: 9px 10px;
    text-align: left;
    color: #64748b;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(30, 41, 59, 0.6);
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
    white-space: nowrap;
}
.ai-bulk-td {
    padding: 6px 6px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.15);
    vertical-align: middle;
    position: relative;
}
.ai-bulk-row-saving {
    background: rgba(251, 191, 36, 0.06) !important;
    border-left: 3px solid #fbbf24;
    animation: ai-pulse-row 1s ease-in-out infinite;
}
@keyframes ai-pulse-row {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.ai-bulk-row-ok {
    background: rgba(34, 197, 94, 0.06) !important;
    border-left: 3px solid #22c55e;
}
.ai-bulk-row-ok .ai-bulk-input,
.ai-bulk-row-ok .ai-bulk-select {
    pointer-events: none;
    opacity: 0.6;
}
.ai-bulk-row-err {
    background: rgba(239, 68, 68, 0.08) !important;
    border-left: 3px solid #ef4444;
}
.ai-field-error {
    border-color: #f87171 !important;
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.45), 0 0 0 4px rgba(248, 113, 113, 0.10) !important;
}
.ai-bulk-row-error-detail td {
    padding: 0 6px 8px;
    border-bottom: 1px solid rgba(248, 113, 113, 0.18);
}
.ai-row-error-box {
    display: block;
    padding: 7px 10px;
    border: 1px solid rgba(248, 113, 113, 0.28);
    border-radius: 6px;
    background: rgba(127, 29, 29, 0.24);
    color: #fecaca;
    font-size: 0.73rem;
    line-height: 1.35;
}
.ai-existing-change-list {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}
.ai-existing-change {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(80px, auto) 18px minmax(80px, auto);
    gap: 8px;
    align-items: center;
    padding: 7px 8px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.45);
}
.ai-existing-change span {
    color: #94a3b8;
}
.ai-existing-change strong {
    color: #e2e8f0;
    font-weight: 700;
}
.ai-existing-change em {
    color: #fbbf24;
    font-style: normal;
    text-align: center;
}
.ai-bulk-input {
    width: 100%;
    padding: 7px 8px;
    background: rgba(15, 23, 42, 0.5);
    color: #e2e8f0;
    border: 1px solid rgba(51, 65, 85, 0.35);
    border-radius: 0.35rem;
    font-size: 0.78rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.ai-bulk-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
}
.ai-bulk-select {
    width: 100%;
    padding: 7px 6px;
    background: rgba(15, 23, 42, 0.5);
    color: #e2e8f0;
    border: 1px solid rgba(51, 65, 85, 0.35);
    border-radius: 0.35rem;
    font-size: 0.75rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.ai-master-cell {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px;
    align-items: center;
}
.ai-master-btn {
    min-width: 42px;
    height: 28px;
    padding: 0 7px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.28);
    background: rgba(99, 102, 241, 0.10);
    color: #a5b4fc;
    font-size: 0.66rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.ai-master-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    color: #c7d2fe;
}
.ai-master-btn-new {
    border-color: rgba(251, 191, 36, 0.28);
    background: rgba(251, 191, 36, 0.10);
    color: #fbbf24;
}
.ai-master-btn-dirty {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.10);
    color: #fca5a5;
}
.ai-master-btn-loading {
    opacity: .6;
}
.ai-bulk-remove {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    color: #f87171;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0 auto;
}
.ai-bulk-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}
.ai-bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0 0;
}
.ai-btn-add-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px dashed rgba(99, 102, 241, 0.35);
    border-radius: 0.4rem;
    color: #818cf8;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-btn-add-row:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.5);
}
.ai-btn-copy-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(14, 165, 233, 0.06);
    border: 1px solid rgba(14, 165, 233, 0.28);
    border-radius: 0.4rem;
    color: #7dd3fc;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-btn-copy-row:hover {
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.45);
    color: #bae6fd;
}
.ai-btn-save-all {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    border: none;
    border-radius: 0.4rem;
    color: white;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}
.ai-btn-save-all:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
/* Row status indicators */
.ai-bulk-row-ok td:first-child { border-left: 3px solid #4ade80; }
.ai-bulk-row-err td:first-child { border-left: 3px solid #f87171; }
.ai-bulk-row-saving { opacity: 0.6; pointer-events: none; }

/* ── Grid Autocomplete Dropdown ── */
.ai-ac-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 300px;
    max-height: 280px;
    overflow-y: auto;
    background: #1e293b;
    border: 1px solid #48bb78;
    border-top: none;
    border-radius: 0 0 10px 10px;
    z-index: 99999;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
    margin-top: 1px;
}
.ai-ac-option {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ai-ac-option:last-child { border-bottom: none; }
.ai-ac-option:hover {
    background: #334155;
    border-left: 3px solid #48bb78;
}
.ai-ac-code {
    color: #48bb78;
    font-weight: 800;
    font-size: 0.78rem;
    letter-spacing: 0.3px;
}
.ai-ac-name {
    font-size: 0.82rem;
    color: #e2e8f0;
}

/* ── Scale Popover ── */
.ai-row-scale-btn {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid rgba(51, 65, 85, 0.5);
    color: #94a3b8;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ai-row-scale-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}
.ai-row-scale-btn.ai-has-scales {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: #818cf8;
}
.ai-scale-popover {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    width: 280px;
    padding: 12px;
    background: #1a2235;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-top: 4px;
}
.ai-scale-pop-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #818cf8;
    margin-bottom: 8px;
}
.ai-scale-row {
    display: grid;
    grid-template-columns: 60px 1fr 1fr;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.ai-scale-row label {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 600;
}
.ai-scale-input {
    width: 100%;
    padding: 5px 6px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(51, 65, 85, 0.4);
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}
.ai-scale-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
}
.ai-scale-done {
    width: 100%;
    padding: 6px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    color: #a5b4fc;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.15s;
}
.ai-scale-done:hover {
    background: rgba(99, 102, 241, 0.25);
}

/* ── Per-Row Status Button ── */
.ai-row-status-btn {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid rgba(51, 65, 85, 0.5);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.ai-row-status-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}
.ai-row-status-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 0.35rem;
    transition: background 0.15s;
}
.ai-row-status-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}
.ai-row-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #475569;
    flex-shrink: 0;
    transition: background 0.2s;
}
.ai-dot-set-active {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}
.ai-dot-set-inactive {
    background: #94a3b8;
}
.ai-row-status-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}
.ai-status-active {
    color: #4ade80;
}
.ai-status-inactive {
    color: #94a3b8;
}

/* ── Status Button ── */
.ai-btn-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 0.5rem;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-btn-status:not(:disabled):hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}
.ai-btn-status:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.ai-status-indicator {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 4px;
    display: none;
}
.ai-si-active {
    display: inline;
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}
.ai-si-inactive {
    display: inline;
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* ── Modal ── */
.ai-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: ai-fade-in 0.15s ease;
}
@keyframes ai-fade-in { from { opacity: 0; } to { opacity: 1; } }
.ai-modal {
    width: 520px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: #1a2235;
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}
.ai-modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
    background: rgba(0, 0, 0, 0.2);
}
.ai-modal-title {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
}
.ai-modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    color: #f87171;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
}
.ai-modal-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
}
.ai-modal-footer {
    display: flex;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid rgba(51, 65, 85, 0.3);
    background: rgba(0, 0, 0, 0.15);
}

/* ── Status choices ── */
.ai-btn-status-choice {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-btn-active {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.ai-btn-active:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.ai-btn-inactive {
    background: rgba(51, 65, 85, 0.5);
    color: #94a3b8;
    border: 1px solid rgba(51, 65, 85, 0.5);
}
.ai-btn-inactive:hover {
    background: rgba(51, 65, 85, 0.7);
    color: #e2e8f0;
}

.ai-master-swal .swal2-html-container {
    margin: 0;
}
.ai-master-modal {
    text-align: left;
}
.ai-master-warning {
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: rgba(251, 191, 36, 0.10);
    border: 1px solid rgba(251, 191, 36, 0.24);
    color: #fde68a;
    font-size: 0.82rem;
    line-height: 1.35;
}
.ai-master-warning-new {
    background: rgba(96, 165, 250, 0.10);
    border-color: rgba(96, 165, 250, 0.26);
    color: #bfdbfe;
}
.ai-master-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.ai-master-modal-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.ai-master-modal-field label {
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.ai-master-modal-input {
    width: 100%;
    min-height: 38px;
    box-sizing: border-box;
    border: 1px solid rgba(51, 65, 85, 0.55);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.74);
    color: #e2e8f0;
    padding: 8px 10px;
    font-size: 0.88rem;
    outline: none;
}
.ai-master-modal-input:focus {
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}
.ai-master-modal-input option {
    background: #111827;
    color: #e2e8f0;
}

/* ── Relationship cards in modal ── */
.ai-status-new {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 0.5rem;
    margin-bottom: 12px;
}
.ai-status-new-badge {
    padding: 3px 10px;
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}
.ai-status-new-text {
    font-size: 0.82rem;
    color: #cbd5e1;
}
.ai-status-subtitle {
    font-size: 0.82rem;
    color: #94a3b8;
    margin: 0 0 12px;
}
.ai-status-hint {
    font-size: 0.78rem;
    color: #64748b;
    margin: 14px 0 0;
    line-height: 1.5;
}
.ai-status-section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 10px 0 6px;
}
.ai-dot-active {
    width: 8px; height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}
.ai-dot-inactive {
    width: 8px; height: 8px;
    background: #64748b;
    border-radius: 50%;
    display: inline-block;
}
.ai-rel-card {
    padding: 10px 14px;
    border-radius: 0.4rem;
    margin-bottom: 6px;
    border-left: 3px solid transparent;
}
.ai-rel-active {
    background: rgba(74, 222, 128, 0.04);
    border-left-color: #4ade80;
}
.ai-rel-inactive {
    background: rgba(51, 65, 85, 0.2);
    border-left-color: #475569;
}
.ai-rel-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-rel-card-row + .ai-rel-card-row {
    margin-top: 4px;
}
.ai-rel-prov {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
}
.ai-rel-code {
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
    color: #818cf8;
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
}
.ai-rel-detail {
    font-size: 0.75rem;
    color: #94a3b8;
}
.ai-rel-date {
    font-size: 0.7rem;
    color: #475569;
    margin-left: auto;
}


/* ── Responsive ── */
@media (max-width: 900px) {
    .ai-form-grid { grid-template-columns: 1fr; }
    .ai-conditions-grid { grid-template-columns: 1fr 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   FILE UPLOAD TAB STYLES
   ══════════════════════════════════════════════════════════════ */

/* ── Tab Bar ── */
.ai-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    padding: 0 4px;
}
.ai-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: rgba(30, 41, 59, 0.4);
    color: #94a3b8;
    border: 1px solid rgba(51, 65, 85, 0.25);
    border-bottom: none;
    border-radius: 0.5rem 0.5rem 0 0;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s;
}
.ai-tab-btn:hover {
    background: rgba(30, 41, 59, 0.7);
    color: #e2e8f0;
}
.ai-tab-btn.ai-tab-active {
    background: rgba(15, 23, 42, 0.6);
    color: #f1f5f9;
    border-color: rgba(99, 102, 241, 0.35);
    border-bottom: 1px solid transparent;
    position: relative;
}
.ai-tab-btn.ai-tab-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, #818cf8);
}

/* ── Instructions Panel ── */
.ai-upload-instructions {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}
.ai-instr-step {
    flex: 1;
    display: flex;
    gap: 12px;
    padding: 16px;
    background: rgba(30, 41, 59, 0.3);
    border-radius: 0.5rem;
    border: 1px solid rgba(51, 65, 85, 0.2);
}
.ai-instr-step strong {
    display: block;
    color: #e2e8f0;
    font-size: 0.82rem;
    margin-bottom: 4px;
}
.ai-instr-step p {
    color: #94a3b8;
    font-size: 0.73rem;
    margin: 0;
    line-height: 1.4;
}
.ai-instr-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

/* ── Upload Actions ── */
.ai-upload-actions {
    margin-bottom: 16px;
}
.ai-btn-download-tpl {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s;
}
.ai-btn-download-tpl:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* ── Dropzone ── */
.ai-dropzone {
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: 0.75rem;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.25s;
    cursor: pointer;
    margin-bottom: 16px;
    background: rgba(15, 23, 42, 0.2);
}
.ai-dropzone:hover,
.ai-dropzone-hover {
    border-color: #818cf8;
    background: rgba(99, 102, 241, 0.06);
}
.ai-dropzone-hover {
    transform: scale(1.005);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.12);
}
.ai-dropzone-text {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 12px 0 4px;
}
.ai-dropzone-sub {
    color: #64748b;
    font-size: 0.78rem;
    margin: 0;
}
.ai-dropzone-link {
    color: #818cf8;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}
.ai-dropzone-link:hover {
    color: #a5b4fc;
}

/* ── Upload Status ── */
.ai-upload-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 0.5rem;
    color: #c7d2fe;
    font-size: 0.82rem;
    margin-bottom: 16px;
}
.ai-upload-error {
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.5rem;
    color: #fca5a5;
    font-size: 0.82rem;
    margin-bottom: 16px;
}

/* ── Preview ── */
.ai-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.ai-preview-summary {
    display: flex;
    gap: 10px;
}
.ai-preview-stat {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.ai-preview-total {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}
.ai-preview-ok {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}
.ai-preview-err {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}
.ai-preview-row-err {
    background: rgba(239, 68, 68, 0.04) !important;
}
.ai-preview-badge-new {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}
.ai-preview-badge-exists {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
}
.ai-preview-badge-active {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}
.ai-preview-badge-inactive {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

/* ── Spinner ── */
@keyframes ai-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.ai-spin {
    animation: ai-spin 1s linear infinite;
}

/* ══════════════════════════════════════════════════════════════
   BULK PRICE MODIFICATION STYLES
   ══════════════════════════════════════════════════════════════ */

.bp-th {
    padding: 8px 10px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-bottom: 1px solid #2d3b55;
}
.bp-td {
    padding: 8px 10px;
    font-size: 0.78rem;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(45, 59, 85, 0.4);
    vertical-align: middle;
}
.bp-td-price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
}
.bp-td-err {
    color: #f87171;
    font-size: 0.7rem;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bp-row { transition: background 0.15s; }
.bp-row:hover { background: rgba(99, 102, 241, 0.04); }
.bp-row-err {
    background: rgba(239, 68, 68, 0.04) !important;
    border-left: 3px solid #f87171;
}
.bp-row-new {
    background: rgba(251, 191, 36, 0.04) !important;
    border-left: 3px solid #fbbf24;
}
.bp-rel-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: #818cf8;
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

/* Delta indicators */
.bp-delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}
.bp-delta-good {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}
.bp-delta-bad {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}
.bp-delta-same {
    background: rgba(148, 163, 184, 0.1);
    color: #64748b;
}

/* Scale tags */
.bp-scale-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    white-space: nowrap;
}

/* Status */
.bp-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
}
.bp-status-active {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}
.bp-status-inactive {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}
.bp-status-change {
    font-size: 0.72rem;
    color: #fbbf24;
}

/* Connected orders badge */
.bp-conn-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    white-space: nowrap;
}

/* Summary stats */
.bp-stat {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.bp-stat-total {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}
.bp-stat-ok {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}
.bp-stat-err {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}
