/* =====================================================
   FREEPY IA — Design System
   Paleta: turquesa/cian + azul profundo, dark + light
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

/* =====================================================
   VARIABLES — LIGHT THEME (default)
   ===================================================== */
:root {
    --font-head: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Brand */
    --brand-1: #2dd4bf;
    --brand-2: #06b6d4;
    --brand-grad: linear-gradient(135deg, #2dd4bf 0%, #06b6d4 100%);
    --brand-grad-deep: linear-gradient(135deg, #0d9488 0%, #0891b2 100%);

    /* Surfaces */
    --bg:         #f0f4f8;
    --surface:    #ffffff;
    --surface-2:  #f8fafc;
    --surface-3:  #eef2f7;
    --border:     #e2e8f0;
    --border-2:   #cbd5e1;

    /* Text */
    --text:       #0f172a;
    --text-2:     #475569;
    --text-3:     #94a3b8;
    --text-inv:   #ffffff;

    /* Navbar */
    --nav-bg:     linear-gradient(135deg, #0d9488 0%, #0891b2 100%);
    --nav-text:   #ffffff;
    --nav-active: rgba(255,255,255,0.2);
    --nav-hover:  rgba(255,255,255,0.12);

    /* State colors */
    --success:    #10b981;
    --success-bg: #d1fae5;
    --success-fg: #065f46;
    --danger:     #ef4444;
    --danger-bg:  #fee2e2;
    --danger-fg:  #dc2626;
    --warning:    #f59e0b;
    --warning-bg: #fef3c7;
    --warning-fg: #92400e;
    --info:       #3b82f6;
    --info-bg:    #dbeafe;
    --info-fg:    #1e40af;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:     0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:  0 12px 32px rgba(0,0,0,0.12);

    /* Forms */
    --input-bg:     #ffffff;
    --input-border: #cbd5e1;
    --input-focus:  #2dd4bf;

    /* Modal overlay */
    --overlay: rgba(15,23,42,0.5);

    /* Radius */
    --r-sm: 6px;
    --r:    10px;
    --r-lg: 16px;
    --r-xl: 20px;
}

/* =====================================================
   VARIABLES — DARK THEME
   ===================================================== */
[data-theme="dark"] {
    --bg:         #07090f;
    --surface:    #131c2e;
    --surface-2:  #1a2438;
    --surface-3:  #1e2d45;
    --border:     rgba(45,212,191,0.12);
    --border-2:   rgba(45,212,191,0.22);

    --text:       #f1f5f9;
    --text-2:     #94a3b8;
    --text-3:     #64748b;
    --text-inv:   #0f172a;

    --nav-bg:     rgba(10,16,25,0.95);
    --nav-text:   #f1f5f9;
    --nav-active: rgba(45,212,191,0.15);
    --nav-hover:  rgba(45,212,191,0.08);

    --success-bg: rgba(16,185,129,0.15);
    --success-fg: #6ee7b7;
    --danger-bg:  rgba(239,68,68,0.15);
    --danger-fg:  #fca5a5;
    --warning-bg: rgba(245,158,11,0.15);
    --warning-fg: #fcd34d;
    --info-bg:    rgba(59,130,246,0.15);
    --info-fg:    #93c5fd;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
    --shadow:     0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:  0 16px 40px rgba(0,0,0,0.6);

    --input-bg:     #1a2332;
    --input-border: rgba(45,212,191,0.2);
    --input-focus:  #2dd4bf;

    --overlay: rgba(0,0,0,0.7);
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 0.25s, color 0.25s;
    min-height: 100vh;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-head);
    color: var(--text);
    font-weight: 600;
    line-height: 1.3;
}
h4 { font-size: 1.25rem; }
h5 { font-size: 1.05rem; }
h6 { font-size: 0.95rem; }

p { margin-bottom: 0.75rem; }
p:last-child { margin-bottom: 0; }

/* =====================================================
   NAVBAR
   ===================================================== */
.fr-nav {
    background: var(--nav-bg);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    gap: 1rem;
}

.fr-nav-brand {
    font-family: var(--font-head);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--nav-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.fr-nav-brand svg { color: var(--brand-1); }

.fr-nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.fr-nav-link {
    color: var(--nav-text) !important;
    text-decoration: none !important;
    padding: 0.4rem 0.85rem;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.18s;
    opacity: 0.85;
}
.fr-nav-link:hover { background: var(--nav-hover); opacity: 1; text-decoration: none !important; }
.fr-nav-link.active { background: var(--nav-active); opacity: 1; font-weight: 600; }

.fr-nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Theme toggle */
.fr-theme-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.1);
    color: var(--nav-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
}
.fr-theme-btn:hover { background: rgba(255,255,255,0.22); }
.fr-theme-btn svg { pointer-events: none; }
[data-theme="dark"] .fr-theme-btn .icon-sun  { display: block; }
[data-theme="dark"] .fr-theme-btn .icon-moon { display: none;  }
.fr-theme-btn .icon-sun  { display: none; }
.fr-theme-btn .icon-moon { display: block; }

/* Lang selector */
.fr-lang {
    background: rgba(255,255,255,0.1);
    color: var(--nav-text);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--r-sm);
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-body);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.fr-lang:focus { outline: none; }
.fr-lang option { background: #0d1117; color: #f1f5f9; }

/* Mobile hamburger */
.fr-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    flex-shrink: 0;
}
.fr-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--nav-text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

/* =====================================================
   PAGE LAYOUT
   ===================================================== */
.fr-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.fr-page-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* =====================================================
   CARDS
   ===================================================== */
.fr-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: box-shadow 0.2s, transform 0.2s;
}
.fr-card:hover { box-shadow: var(--shadow); }

.fr-card-title {
    font-family: var(--font-head);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Stats cards */
.fr-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.fr-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}
.fr-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.fr-stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--r);
    background: linear-gradient(135deg, rgba(45,212,191,0.15) 0%, rgba(6,182,212,0.15) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--brand-2);
}
[data-theme="dark"] .fr-stat-icon {
    background: linear-gradient(135deg, rgba(45,212,191,0.12) 0%, rgba(6,182,212,0.12) 100%);
}

.fr-stat-info { flex: 1; min-width: 0; }
.fr-stat-label {
    font-size: 0.78rem;
    color: var(--text-2);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}
.fr-stat-value {
    font-family: var(--font-head);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    word-break: break-all;
}

/* =====================================================
   SECTION / PANEL
   ===================================================== */
.fr-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.fr-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.fr-section-title {
    font-family: var(--font-head);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* =====================================================
   TABS
   ===================================================== */
.fr-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.fr-tab-btn {
    padding: 0.7rem 1.2rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-body);
    color: var(--text-2);
    white-space: nowrap;
    transition: color 0.18s, border-color 0.18s;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.fr-tab-btn:hover { color: var(--brand-1); }
.fr-tab-btn.active {
    color: var(--brand-2);
    border-bottom-color: var(--brand-2);
    font-weight: 600;
}
.fr-tab-pane { display: none; }
.fr-tab-pane.active { display: block; }

/* =====================================================
   TABLE
   ===================================================== */
.fr-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--r);
    border: 1px solid var(--border);
}
.fr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.fr-table thead th {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.fr-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.fr-table tbody tr:last-child td { border-bottom: none; }
.fr-table tbody tr:hover td { background: var(--surface-2); }

/* =====================================================
   FORMS
   ===================================================== */
.fr-form-group {
    margin-bottom: 1rem;
}
.fr-label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.35rem;
}
.fr-label-hint {
    display: block;
    font-size: 0.775rem;
    color: var(--text-3);
    font-weight: 400;
    margin-top: 0.25rem;
}
.fr-input,
.fr-select,
.fr-textarea {
    display: block;
    width: 100%;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--r);
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    font-family: var(--font-body);
    color: var(--text);
    transition: border-color 0.18s, box-shadow 0.18s;
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}
.fr-input::placeholder, .fr-textarea::placeholder { color: var(--text-3); }
.fr-input:focus, .fr-select:focus, .fr-textarea:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(45,212,191,0.15);
}
.fr-textarea { resize: vertical; min-height: 80px; }
.fr-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%2394a3b8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.2rem;
    cursor: pointer;
}
.fr-select option { background: var(--surface); color: var(--text); }

/* Checkbox / switch */
.fr-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.fr-switch-row:last-child { border-bottom: none; }
.fr-switch-info { flex: 1; min-width: 0; }
.fr-switch-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}
.fr-switch-desc {
    font-size: 0.78rem;
    color: var(--text-2);
    margin-top: 2px;
}

.fr-switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}
.fr-switch input { opacity: 0; width: 0; height: 0; }
.fr-switch-track {
    position: absolute;
    inset: 0;
    background: var(--border-2);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}
.fr-switch-track::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.fr-switch input:checked + .fr-switch-track { background: var(--brand-1); }
.fr-switch input:checked + .fr-switch-track::after { transform: translateX(18px); }

.fr-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.fr-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}
.fr-grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1rem;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.fr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--r);
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
}
.fr-btn:hover:not(:disabled) { transform: translateY(-1px); }
.fr-btn:active:not(:disabled) { transform: translateY(0); }
.fr-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.fr-btn-primary {
    background: var(--brand-grad);
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(45,212,191,0.3);
}
.fr-btn-primary:hover:not(:disabled) { box-shadow: 0 4px 14px rgba(45,212,191,0.45); }

.fr-btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}
.fr-btn-secondary:hover:not(:disabled) { background: var(--surface-3); box-shadow: var(--shadow-sm); }

.fr-btn-danger {
    background: var(--danger);
    color: white;
}
.fr-btn-danger:hover:not(:disabled) { box-shadow: 0 4px 12px rgba(239,68,68,0.35); }

.fr-btn-success {
    background: var(--success);
    color: white;
}
.fr-btn-success:hover:not(:disabled) { box-shadow: 0 4px 12px rgba(16,185,129,0.35); }

.fr-btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
}
.fr-btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.fr-btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--r-sm);
}
.fr-btn-lg {
    padding: 0.8rem 1.6rem;
    font-size: 1rem;
    border-radius: var(--r);
}
.fr-btn-block { width: 100%; }

/* =====================================================
   BADGES
   ===================================================== */
.fr-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.fr-badge-success { background: var(--success-bg); color: var(--success-fg); }
.fr-badge-danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.fr-badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.fr-badge-info    { background: var(--info-bg);    color: var(--info-fg); }
.fr-badge-neutral { background: var(--surface-3);  color: var(--text-2); }

/* =====================================================
   MODAL (dialog nativo)
   ===================================================== */

/* Oculto por defecto — NO pisar display:none del elemento <dialog> */
dialog.fr-dialog:not([open]) {
    display: none !important;
}

/* Cuando está abierto: centrado, posicionado fijo */
dialog.fr-dialog[open] {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 0;
    width: 92vw;
    max-height: 90vh;
    overflow: hidden;
    color: var(--text);
    font-family: var(--font-body);
    z-index: 9000;
    animation: frDialogIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes frDialogIn {
    from { opacity:0; transform: translate(-50%, calc(-50% + 12px)) scale(0.96); }
    to   { opacity:1; transform: translate(-50%, -50%) scale(1); }
}
dialog.fr-dialog::backdrop {
    background: var(--overlay);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.fr-dialog-xl { width: 92vw; }
.fr-dialog-lg { width: 80vw; }

.fr-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.fr-dialog-title {
    font-family: var(--font-head);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.fr-dialog-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.18s;
    padding: 0;
}
.fr-dialog-close:hover { background: var(--border); color: var(--text); }
.fr-dialog-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.4rem;
}
.fr-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* =====================================================
   NOTIFICATIONS (toast)
   ===================================================== */
#fr-toast-container {
    position: fixed;
    top: 72px;
    right: 18px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.fr-toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand-2);
    border-radius: var(--r);
    padding: 0.75rem 1rem;
    min-width: 260px;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    pointer-events: all;
    animation: frToastIn 0.28s ease;
}
.fr-toast.success { border-left-color: var(--success); }
.fr-toast.error   { border-left-color: var(--danger);  }
.fr-toast.warning { border-left-color: var(--warning); }
@keyframes frToastIn {
    from { opacity:0; transform: translateX(30px); }
    to   { opacity:1; transform: translateX(0); }
}
@keyframes frToastOut {
    from { opacity:1; transform: translateX(0); }
    to   { opacity:0; transform: translateX(40px); }
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.fr-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}
[data-theme="dark"] .fr-login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(45,212,191,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(6,182,212,0.06) 0%, transparent 50%);
    pointer-events: none;
}

.fr-login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.25rem 2rem;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.fr-login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.fr-login-logo-icon {
    width: 56px;
    height: 56px;
    background: var(--brand-grad);
    border-radius: var(--r-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: #0f172a;
}
.fr-login-title {
    font-family: var(--font-head);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}
.fr-login-sub {
    font-size: 0.85rem;
    color: var(--text-2);
}

/* =====================================================
   CONVERSATIONS LIST
   ===================================================== */
.fr-conv-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.fr-conv-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 0.65rem 1rem;
    transition: border-color 0.18s, box-shadow 0.18s;
    cursor: default;
}
.fr-conv-item:hover {
    border-color: var(--brand-2);
    box-shadow: 0 2px 8px rgba(6,182,212,0.1);
}
.fr-conv-item.fr-conv-test {
    border-left: 3px solid var(--warning);
    background: var(--warning-bg);
}
[data-theme="dark"] .fr-conv-item.fr-conv-test { background: rgba(245,158,11,0.06); }

.fr-conv-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-3);
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}
.fr-conv-msg { font-size: 0.875rem; color: var(--text); margin-bottom: 0.2rem; line-height: 1.45; }
.fr-conv-resp { font-size: 0.875rem; color: var(--text-2); line-height: 1.45; }
.fr-conv-msg strong, .fr-conv-resp strong { color: var(--brand-2); margin-right: 0.3rem; }
.fr-conv-msg p, .fr-conv-resp p { margin-bottom: 0.15rem; }
.fr-conv-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.72rem;
    color: var(--text-3);
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

/* =====================================================
   PAGINATION
   ===================================================== */
.fr-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.25rem 0;
}
.fr-page-info { font-size: 0.875rem; color: var(--text-2); }

/* =====================================================
   CHAT (testing)
   ===================================================== */
.fr-chat-wrap {
    background: var(--surface-2);
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}
.fr-chat-messages {
    height: 460px;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.fr-chat-msg {
    max-width: 72%;
    padding: 0.75rem 1rem;
    border-radius: var(--r-lg);
    font-size: 0.875rem;
    line-height: 1.5;
    animation: frMsgIn 0.22s ease;
}
@keyframes frMsgIn {
    from { opacity:0; transform: translateY(8px); }
    to   { opacity:1; transform: translateY(0); }
}
.fr-chat-msg.user {
    align-self: flex-end;
    background: var(--brand-grad);
    color: #0f172a;
    border-bottom-right-radius: 4px;
}
.fr-chat-msg.bot {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}
.fr-chat-time { font-size: 0.7rem; opacity: 0.65; margin-top: 0.3rem; }

.fr-chat-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.fr-chat-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--brand-2);
    animation: frDot 1.3s infinite ease-in-out;
}
.fr-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.fr-chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes frDot {
    0%,60%,100% { transform: translateY(0); opacity:0.5; }
    30%          { transform: translateY(-6px); opacity:1; }
}

.fr-chat-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    align-items: flex-end;
}
.fr-chat-input-row textarea {
    flex: 1;
    border: 1.5px solid var(--input-border);
    border-radius: var(--r);
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    font-family: var(--font-body);
    background: var(--input-bg);
    color: var(--text);
    resize: none;
    outline: none;
    line-height: 1.5;
    min-height: 40px;
    max-height: 120px;
    transition: border-color 0.18s;
    -webkit-appearance: none;
    appearance: none;
}
.fr-chat-input-row textarea::placeholder { color: var(--text-3); }
.fr-chat-input-row textarea:focus { border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(45,212,191,0.12); }

.fr-chat-stats-row {
    display: flex;
    gap: 1.5rem;
    padding: 0.85rem 1rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-2);
}

/* =====================================================
   EMBED CODE
   ===================================================== */
.fr-code-block {
    background: #0d1117;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: var(--r);
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.6;
    font-family: 'Fira Mono', 'Consolas', monospace;
    margin: 0.75rem 0;
    border: 1px solid rgba(255,255,255,0.07);
}
.fr-code-hint {
    background: var(--warning-bg);
    color: var(--warning-fg);
    border-left: 3px solid var(--warning);
    padding: 0.85rem 1rem;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font-size: 0.8rem;
    line-height: 1.5;
}

/* =====================================================
   MISC UTILITIES
   ===================================================== */
.fr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
}
.fr-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--brand-2);
    border-radius: 50%;
    animation: frSpin 0.8s linear infinite;
}
@keyframes frSpin { to { transform: rotate(360deg); } }

.fr-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-3);
    font-size: 0.875rem;
    font-style: italic;
}

.fr-error-msg {
    background: var(--danger-bg);
    color: var(--danger-fg);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--r);
    padding: 0.7rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}
.fr-error-msg.show { display: block; }

.fr-summary-bar {
    display: flex;
    gap: 2rem;
    padding: 1rem 1.25rem;
    background: var(--surface-2);
    border-radius: var(--r);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    border: 1px solid var(--border);
}
.fr-summary-item { display: flex; flex-direction: column; gap: 2px; }
.fr-summary-label { font-size: 0.75rem; color: var(--text-3); }
.fr-summary-value { font-size: 1.1rem; font-weight: 700; font-family: var(--font-head); color: var(--text); }

/* Color inputs */
input[type="color"] {
    height: 44px;
    cursor: pointer;
    border: 1.5px solid var(--input-border);
    border-radius: var(--r-sm);
    background: var(--input-bg);
    padding: 2px;
    width: 100%;
}

.fr-color-preview {
    height: 72px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

/* Icon preview */
.fr-icon-preview {
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--r);
    text-align: center;
    border: 1px solid var(--border);
    margin-top: 0.75rem;
}
.fr-icon-preview img {
    max-width: 120px;
    border-radius: var(--r);
    box-shadow: var(--shadow);
}

/* Markdown content */
.fr-md h1, .fr-md h2, .fr-md h3 { margin: 0.75rem 0 0.4rem; font-weight: 600; }
.fr-md ul, .fr-md ol { margin: 0.4rem 0 0.4rem 1.4rem; }
.fr-md li { margin-bottom: 0.2rem; }
.fr-md p { margin-bottom: 0.5rem; }
.fr-md code {
    background: var(--surface-3);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.88em;
    color: var(--brand-2);
}
.fr-md pre {
    background: #0d1117;
    color: #e2e8f0;
    padding: 0.85rem;
    border-radius: var(--r-sm);
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.82em;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
    .fr-nav { padding: 0 1rem; }
    .fr-nav-links { display: none; }
    .fr-nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 58px;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        padding: 0.75rem 1rem;
        gap: 2px;
        box-shadow: var(--shadow-lg);
        z-index: 999;
    }
    .fr-nav-links.open .fr-nav-link { width: 100%; }
    .fr-hamburger { display: flex; }
    .fr-grid-2, .fr-grid-3, .fr-grid-4 { grid-template-columns: 1fr; }
    .fr-stats-grid { grid-template-columns: 1fr 1fr; }
    .fr-dialog-xl { width: min(96vw, 960px); }
}

@media (max-width: 560px) {
    .fr-page, .fr-page-wide { padding: 1rem; }
    .fr-stats-grid { grid-template-columns: 1fr; }
    .fr-login-box { padding: 1.75rem 1.25rem; }
    .fr-section { padding: 1rem; }
    .fr-dialog { width: 96vw; }
    .fr-dialog-footer { flex-direction: column-reverse; }
    .fr-dialog-footer .fr-btn { width: 100%; justify-content: center; }
}
