/* VITI Portal Styles - Professional Light Theme (Tecnologia Match) */
:root {
    /* Brand Colors */
    --primary: #0a192f;
    /* Deep Navy from screenshots */
    --primary-hover: #112240;
    --accent: #0056d2;
    /* Vibrant Blue for buttons/actions */
    --accent-hover: #004494;

    /* Status Colors */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-text: #065f46;

    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-text: #92400e;

    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-text: #b91c1c;

    --info: #3b82f6;
    --info-bg: #eff6ff;
    --info-text: #1e40af;

    /* Backgrounds */
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;
    --bg-hover: #f3f4f6;

    /* Borders */
    --border-subtle: #e5e7eb;
    --border-default: #d1d5db;
    --border-focus: #3b82f6;

    /* Text */
    --text-primary: #111827;
    /* Gray 900 */
    --text-secondary: #4b5563;
    /* Gray 600 */
    --text-muted: #6b7280;
    /* Gray 500 */
    --text-light: #ffffff;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Missing Utils */
    --bg-elevated: #ffffff;
    --primary-dark: #112240;
    --success-light: #ecfdf5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.viti-portal {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation - Clean White Header */
.portal-nav {
    background: #ffffff;
    padding: 0 30px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 9999;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.nav-brand img {
    height: 32px;
}

.nav-links {
    display: flex;
    gap: 30px;
    height: 100%;
}

.nav-links>a,
.nav-dropdown>a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 5px;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.nav-links>a:hover,
.nav-links>a.active,
.nav-dropdown>a:hover,
.nav-dropdown>a.active {
    color: var(--primary);
}

.nav-links>a.active,
.nav-dropdown>a.active {
    border-bottom-color: var(--accent);
}

/* User Menu */
.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Main Content */
.portal-main {
    flex: 1;
    padding: 40px 30px;
}

.portal-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Typography */
h1 {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    letter-spacing: -0.8px;
}

h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

p {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 6px rgba(0, 86, 210, 0.2);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(0, 86, 210, 0.25);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--border-focus);
    color: var(--accent);
    background: var(--bg-hover);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 5px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: rgb(110, 107, 107);
}

/* Cards */
.stat-card,
.license-card,
.license-detail-card,
.auth-card,
.empty-state {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-subtle);
    padding: 24px;
    transition: all 0.3s ease;
}

.stat-card:hover,
.license-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-focus);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-number {
    font-size: 42px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
}

/* License List */
.license-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 15px;
}

.license-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.license-key code {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    background: var(--bg-body);
    color: var(--primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    display: block;
    margin-bottom: 15px;
}

.license-meta {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.meta-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.meta-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

/* Badges & Status */
.badge,
.status {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-starter {
    background: var(--info-bg);
    color: var(--info-text);
}

.badge-pro {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-enterprise {
    background: #f3e8ff;
    color: #6b21a8;
}

.badge-service {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.status-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-expired {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.status-pending {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-inactive {
    background: var(--bg-body);
    color: var(--text-muted);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
}

.data-table th {
    background: var(--bg-input);
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 12px;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

/* Forms */
.auth-form input,
.form-row input,
.form-row select {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.auth-form input:focus,
.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 86, 210, 0.1);
}

.auth-card {
    max-width: 420px;
    margin: 40px auto;
}

/* Footer */
.portal-footer {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 14px;
    border-top: 1px solid var(--border-subtle);
    background: white;
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #fca5a5;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #6ee7b7;
}

/* Responsive */
@media (max-width: 768px) {
    .portal-nav {
        flex-direction: column;
        height: auto;
        padding: 20px;
        gap: 20px;
    }

    .nav-links {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        gap: 20px;
    }

    .portal-main {
        padding: 20px 15px;
    }
}

/* ===========================================================
 * Design System v2 (2026-04)
 * Reusable building blocks for the portal. Rules live at the end
 * so later declarations override anything earlier in this file.
 * =========================================================== */

/* Inline SVG icon — scales with font-size, inherits color. */
.viti-icon {
    flex-shrink: 0;
    vertical-align: middle;
}
.icon-muted { color: var(--text-muted); }
.icon-accent { color: var(--accent); }
.icon-success { color: var(--success); }
.icon-warning { color: var(--warning); }
.icon-danger { color: var(--danger); }

/* Page header (h1 + subtitle + optional right-side actions). */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}
.page-header h1 {
    margin-bottom: 6px;
}
.page-header p {
    color: var(--text-muted);
    font-size: 15px;
    max-width: 680px;
    margin: 0;
}
.page-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Breadcrumbs. */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Generic card — companion to existing .stat-card/.license-card.
   Used by richer pages like dashboard/order-downloads. */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-header .card-action {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}
.card-header .card-action:hover { text-decoration: underline; }
.card-body {
    padding: 20px;
}
.card-body.compact { padding: 12px 16px; }

/* Key–value strip — replaces raw .meta-item markup with a proper grid. */
.kv-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}
.kv-row .kv {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.kv-row .kv .kv-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}
.kv-row .kv .kv-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Icon chip — small rounded square used on cards as a visual anchor. */
.icon-chip {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
    color: var(--accent);
    flex-shrink: 0;
}
.icon-chip.chip-success { background: var(--success-bg); color: var(--success-text); }
.icon-chip.chip-warning { background: var(--warning-bg); color: var(--warning-text); }
.icon-chip.chip-danger  { background: var(--danger-bg);  color: var(--danger-text);  }
.icon-chip.chip-info    { background: var(--info-bg);    color: var(--info-text);    }
.icon-chip.chip-muted   { background: var(--bg-input);   color: var(--text-muted);   }
.icon-chip.lg { width: 56px; height: 56px; border-radius: var(--radius-lg); }

/* Copy button — inline icon chip variant used next to keys/URLs. */
.copy-chip {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
.copy-chip:hover,
.copy-chip:focus-visible {
    background: var(--bg-input);
    border-color: var(--border-subtle);
    color: var(--text-primary);
    outline: none;
}
.copy-chip.copied {
    color: var(--success);
    border-color: var(--success);
    background: var(--success-bg);
}

/* Fix: .btn-danger had color: rgb(110, 107, 107) (gray) — unreadable
   on red background. Restore proper white foreground + hover state. */
.btn-danger {
    background: var(--danger);
    color: #ffffff;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.18);
}
.btn-danger:hover {
    background: #dc2626;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(239, 68, 68, 0.28);
}

/* Ghost button — text-only with hover background. Used for toolbar actions. */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.btn-ghost:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Icon-only button inside toolbars. */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-grid;
    place-items: center;
}

/* Focus ring for all interactive elements — WCAG AA compliance. */
.btn:focus-visible,
.copy-chip:focus-visible,
.nav-links > a:focus-visible,
.dropdown-menu a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Improved empty state layout. */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}
.empty-state .empty-icon {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--text-muted);
}
.empty-state h2,
.empty-state h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-secondary);
    max-width: 420px;
    margin: 0 auto 20px;
}

/* Better stats card — adds an optional icon-chip. */
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card .stat-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.stat-card .stat-number {
    font-size: 32px;
    margin-bottom: 2px;
}
.stat-card .stat-delta {
    font-size: 12px;
    color: var(--text-muted);
}

/* Section grouping with a subtle divider above. */
.section {
    margin-top: 40px;
}
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.section-header h2 {
    margin-bottom: 0;
}
.section-header .section-link {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.section-header .section-link:hover { text-decoration: underline; }

/* License key with inline copy button (replacement for masked version). */
.key-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-body);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px 8px 6px 12px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    color: var(--primary);
    overflow: hidden;
}
.key-display code {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: transparent;
    padding: 0;
    border: 0;
    color: inherit;
    font: inherit;
}

/* Utility colors for chips used across licenses/services. */
.chip-plan-starter    { background: var(--info-bg);    color: var(--info-text);    }
.chip-plan-pro        { background: #e0e7ff;           color: #3730a3;             }
.chip-plan-enterprise { background: #f3e8ff;           color: #6b21a8;             }
.chip-plan-trial      { background: var(--warning-bg); color: var(--warning-text); }

/* Tighter license-meta so label+value sit in a clean column stack. */
.license-meta .meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Responsive refinements for the new components. */
@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        gap: 12px;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
