/* --- CSS VARIABLES & THEME CONFIGURATION --- */
cgv-neo-tools {
    display: block; /* Custom tags are inline by default, this makes it behave like a div */
    
    /* 1. Color Palette */
    --color-primary: #2563eb;          /* blue-600 */
    --color-primary-hover: #1d4ed8;    /* blue-700 */
    --color-primary-light: #3b82f6;    /* blue-500 */
    --color-primary-bg: #eff6ff;       /* blue-50 */
    --color-secondary-bg: #f3f4f6;     /* gray-100 */
    
    --color-background: #f1f5f9;       /* slate-100 */
    --color-surface: #ffffff;
    
    --color-text-main: #1f2937;        /* gray-800 */
    --color-text-muted: #4b5563;       /* gray-600 */
    --color-text-light: #9ca3af;       /* gray-400 */
    
    --color-border: #e5e7eb;
    --color-border-focus: #93c5fd;     /* blue-300 */
    --color-danger: #ef4444;           /* red-500 */

    /* 2. Dimensions & Spacing */
    --container-width: 72rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-full: 9999px;
    
    /* 3. Typography */
    --font-family-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    
    /* Configurable Text Transform */
    --label-transform: none; 
    --label-weight: 700;

    /* Base Body Styles Moved Here */
    margin: 0;
    font-family: var(--font-family-sans);
    background-color: var(--color-background);
    min-height: 100vh;
    padding: 2rem 1rem;
    color: var(--color-text-main);
}

/* --- RESET & BASE --- */
cgv-neo-tools *, 
cgv-neo-tools *::before, 
cgv-neo-tools *::after { 
    box-sizing: border-box; 
}

/* --- LAYOUT UTILITIES --- */
cgv-neo-tools .container {
    max-width: var(--container-width);
    margin: 0 auto;
    background-color: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
cgv-neo-tools .header {
    background-color: var(--color-primary);
    padding: 1.5rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

cgv-neo-tools .main-content {
    padding: 2rem;
}

cgv-neo-tools .grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}
 @media (min-width: 1024px) {
    cgv-neo-tools .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

cgv-neo-tools .space-y-4 > * + * { margin-top: 1rem; }
cgv-neo-tools .space-y-3 > * + * { margin-top: 0.75rem; }

/* --- TYPOGRAPHY & ELEMENTS --- */
cgv-neo-tools h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
cgv-neo-tools h2 { font-size: 1.125rem; font-weight: 700; color: var(--color-text-main); display: flex; align-items: center; margin: 0; }
cgv-neo-tools p { margin: 0; }

cgv-neo-tools .badge {
    background-color: var(--color-primary-light);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-family: var(--font-family-mono);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.75rem;
    color: white;
}

cgv-neo-tools .section-header {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

cgv-neo-tools .number-circle {
    background-color: var(--color-primary);
    color: white;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

cgv-neo-tools .btn-add {
    font-size: 0.625rem;
    background-color: var(--color-secondary-bg);
    color: var(--color-text-muted);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
cgv-neo-tools .btn-add:hover { background-color: var(--color-primary); color: white; }

cgv-neo-tools .helper-text {
    font-size: 0.625rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-top: 0.5rem;
}

/* --- FORMS --- */

cgv-neo-tools .btn-sm-light {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 9999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
}
cgv-neo-tools .btn-sm-light:hover {
    background-color: white;
    color: var(--color-primary);
}

cgv-neo-tools .input-label { 
    display: block; 
    font-size: 0.75rem; 
    text-transform: var(--label-transform); 
    letter-spacing: 0.05em; 
    font-weight: var(--label-weight); 
    color: var(--color-text-muted); 
    margin-bottom: 0.25rem; 
}

cgv-neo-tools .input-field { 
    width: 100%; 
    padding: 0.5rem; 
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md); 
    font-size: 0.875rem;
    transition: all 0.2s; 
    font-family: inherit;
}
cgv-neo-tools .input-field:focus { 
    outline: none; 
    border-color: var(--color-primary); 
    box-shadow: 0 0 0 2px var(--color-border-focus); 
}

cgv-neo-tools .grid-2-sm {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* --- DYNAMIC ROWS --- */
cgv-neo-tools .payment-row {
    background-color: var(--color-surface);
    padding: 0.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    position: relative;
    transition: all 0.2s;
}
cgv-neo-tools .payment-row:hover {
    border-color: var(--color-border-focus);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

cgv-neo-tools .editable-label {
    border: none;
    border-bottom: 1px dashed #d1d5db;
    background: transparent;
    padding: 2px 4px;
    font-size: 10px;
    font-weight: 800;
    text-transform: var(--label-transform); 
    color: #6b7280;
    cursor: text;
    width: auto;
    transition: all 0.2s;
    margin-bottom: 2px;
    display: inline-block;
}
cgv-neo-tools .editable-label:hover { border-bottom-color: var(--color-primary-light); color: var(--color-primary-light); background-color: var(--color-primary-bg); }
cgv-neo-tools .editable-label:focus { outline: none; border-bottom: 2px solid var(--color-primary); color: #1e40af; background-color: var(--color-primary-bg); }

cgv-neo-tools .row-input {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.25rem;
    border: none;
    color: #374151;
    resize: vertical;
    font-family: inherit;
    background: transparent;
}
cgv-neo-tools .row-input:focus { outline: none; }
cgv-neo-tools .row-input::placeholder { color: #d1d5db; }

cgv-neo-tools .row-controls {
    position: absolute;
    right: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}
cgv-neo-tools .payment-row:hover .row-controls { opacity: 1; }

cgv-neo-tools .btn-icon {
    background: white;
    border: 1px solid var(--color-border);
    color: var(--color-text-light);
    border-radius: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
}
cgv-neo-tools .btn-icon:hover { color: var(--color-primary); border-color: var(--color-border-focus); }

cgv-neo-tools .btn-delete {
    position: absolute;
    top: -0.5rem;
    left: -0.5rem;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: var(--radius-full);
    background-color: var(--color-border);
    color: #6b7280;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}
cgv-neo-tools .payment-row:hover .btn-delete { opacity: 1; }
cgv-neo-tools .btn-delete:hover { background-color: var(--color-danger); color: white; }

/* --- TABS --- */
cgv-neo-tools .tabs-scroll {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    scrollbar-width: thin;
    border-bottom: 1px solid var(--color-border);
}
cgv-neo-tools .tabs-scroll::-webkit-scrollbar { height: 4px; }
cgv-neo-tools .tabs-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

cgv-neo-tools .tab-btn {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
cgv-neo-tools .tab-btn:hover {
    color: var(--color-primary);
    background-color: var(--color-primary-bg);
}
cgv-neo-tools .tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background-color: #eff6ff;
}
cgv-neo-tools .tab-close {
    font-size: 10px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    color: #64748b;
    margin-left: 0.25rem;
}
cgv-neo-tools .tab-close:hover {
    background: #ef4444;
    color: white;
}
cgv-neo-tools .btn-new-tab {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    color: var(--color-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
}
cgv-neo-tools .btn-new-tab:hover {
    transform: scale(1.1);
}

/* --- FOOTER & BUTTON --- */
cgv-neo-tools .footer-action {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

cgv-neo-tools .btn-primary {
    width: 100%;
    max-width: 28rem;
    background-color: var(--color-primary);
    color: white;
    font-weight: 700;
    padding: 1rem;
    border-radius: var(--radius-xl);
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s, background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}
cgv-neo-tools .btn-primary:hover { background-color: var(--color-primary-hover); transform: scale(1.02); }
cgv-neo-tools .btn-primary:active { transform: scale(0.95); }
cgv-neo-tools .btn-primary:disabled { background-color: var(--color-border-focus); cursor: not-allowed; transform: none; }

cgv-neo-tools .bill-to-box {
    background-color: var(--color-primary-bg);
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid #dbeafe;
}

cgv-neo-tools .hidden-sm { display: none; }
 @media (min-width: 640px) { .hidden-sm { display: block; } }

/* Spinner */
cgv-neo-tools .spinner { animation: spin 1s linear infinite; height: 1.25rem; width: 1.25rem; color: white; }
 @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
