/* ============================================
   Nemesys Client Portal — Design System v2.0
   ============================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Surfaces */
    --bg-base: #0f172a;
    --bg-card: #1e293b;
    --bg-elevated: #334155;
    --bg-sidebar: #0d1117;
    --bg-input: #0f172a;
    --border: #334155;
    --border-subtle: #1e293b;

    /* Text */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-on-accent: #ffffff;

    /* Accents */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows (subtle on dark) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Sidebar */
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
    --header-height: 60px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-base) !important;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

/* --- Layout Shell --- */
#nemesys-portal-root {
    display: flex;
    min-height: 100vh;
    background: var(--bg-base);
}

/* --- Sidebar --- */
.nemesys-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition-slow);
}

.nemesys-sidebar .sidebar-logo {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nemesys-sidebar .sidebar-logo img {
    height: 36px;
    max-width: 100%;
}

.nemesys-sidebar nav {
    flex: 1;
    padding: var(--space-md) var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.nemesys-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nemesys-sidebar .nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nemesys-sidebar .nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.nemesys-sidebar .nav-item .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.nemesys-sidebar .nav-divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-sm) var(--space-md);
}

.nemesys-sidebar .sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
}

.nemesys-sidebar .sidebar-footer .nav-item {
    color: var(--text-muted);
}

.nemesys-sidebar .sidebar-footer .nav-item:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* --- Main Content --- */
.nemesys-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

/* --- Header --- */
.nemesys-header {
    height: var(--header-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nemesys-header .header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nemesys-header .header-left h1 {
    font-size: 18px;
    font-weight: 600;
}

.nemesys-header .header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nemesys-header .user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: 13px;
}

.nemesys-header .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

/* --- Page Content --- */
.nemesys-content {
    flex: 1;
    padding: var(--space-lg);
    max-width: 1200px;
    width: 100%;
}

/* Dashboard de Setores: usa toda a largura e altura disponiveis */
.nemesys-content.is-fullwidth {
    max-width: none;
    padding: var(--space-sm, 12px);
}

.section-card.setores-card {
    padding: 0;
    overflow: hidden;
    margin: 0;
}

.section-card.setores-card .section-header {
    padding: 12px 20px;
    margin: 0;
}

.setores-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 150px);
    min-height: 600px;
    border: 0;
    background: #09111c;
}

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
    animation: fadeInUp 0.4s ease both;
}

.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 60ms; }
.kpi-card:nth-child(3) { animation-delay: 120ms; }
.kpi-card:nth-child(4) { animation-delay: 180ms; }

.kpi-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.1);
}

.kpi-card .kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-sm);
}

.kpi-card .kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.kpi-card .kpi-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.kpi-card .kpi-sub.positive { color: var(--success); }
.kpi-card .kpi-sub.negative { color: var(--danger); }

/* --- Section Cards --- */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    animation: fadeInUp 0.4s ease both;
    animation-delay: 240ms;
}

.section-card .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.section-card .section-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-card .section-header .section-action {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.section-card .section-header .section-action:hover {
    color: var(--accent-hover);
}

.section-card .section-header .section-action a {
    color: var(--accent);
    text-decoration: none;
}

.section-card .section-header .section-action a:hover {
    color: var(--accent-hover);
}

/* --- Market Ticker --- */
.market-ticker {
    display: flex;
    gap: var(--space-md);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-xl);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    animation: fadeInUp 0.4s ease both;
    animation-delay: 60ms;
}

.ticker-item {
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 180px;
    transition: border-color var(--transition-fast);
}

.ticker-item:hover {
    border-color: var(--accent);
}

.ticker-item .ticker-symbol {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
}

.ticker-item .ticker-price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.ticker-item .ticker-change {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.ticker-item .ticker-change.up {
    color: var(--success);
    background: var(--success-bg);
}

.ticker-item .ticker-change.down {
    color: var(--danger);
    background: var(--danger-bg);
}

/* --- MC List --- */
.mc-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.mc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.mc-item:hover {
    border-color: var(--accent);
    background: var(--bg-card);
}

.mc-item .mc-info h4 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.mc-item .mc-info .mc-date {
    font-size: 12px;
    color: var(--text-muted);
}

.mc-item .mc-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.mc-item .mc-status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.mc-item .mc-status.new {
    color: var(--accent);
    background: var(--accent-glow);
}

.mc-item .mc-status.read {
    color: var(--text-muted);
    background: var(--bg-elevated);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-decoration: none;
    line-height: 1;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* --- Forms --- */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.form-input.success {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-bg);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.form-hint.error {
    color: var(--danger);
}

.form-hint.success {
    color: var(--success);
}

/* Input with icon */
.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .form-input {
    padding-left: 40px;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
}

/* --- Login/Auth Pages (split layout: hero left, form panel right) --- */
.auth-page {
    --auth-bg: #111213;
    --auth-panel: #181a1b;
    --auth-input: #111213;
    --auth-border: #1f2223;
    --auth-label: #e2e2e2;
    --auth-text: #c1c1c1;
    --auth-muted: #7c8183;
    --auth-accent: #6ca5ae;
    --auth-accent-hover: #5b939c;
    display: flex;
    min-height: 100vh;
    background: var(--auth-bg);
    color: #fff;
}

/* Hero */
.auth-hero {
    position: relative;
    flex: 2 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(ellipse 38% 45% at 50% 48%, rgba(8, 20, 28, 0.95) 0%, rgba(8, 20, 28, 0.6) 55%, transparent 75%),
        radial-gradient(ellipse 70% 80% at 50% 50%, #1d6f80 0%, #0e3a47 45%, #07161c 100%);
    background-size: cover;
    background-position: center;
}

.auth-hero.has-photo::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
}

.auth-hero-rings span {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 1px solid rgba(140, 225, 240, 0.18);
    box-shadow: 0 0 40px rgba(90, 200, 225, 0.15), inset 0 0 40px rgba(90, 200, 225, 0.12);
    transform: translate(-50%, -50%);
    animation: authPulse 8s ease-in-out infinite;
}
.auth-hero-rings span:nth-child(1) { width: 38vmin; height: 38vmin; }
.auth-hero-rings span:nth-child(2) { width: 58vmin; height: 58vmin; animation-delay: -2s; }
.auth-hero-rings span:nth-child(3) { width: 80vmin; height: 80vmin; animation-delay: -4s; }
.auth-hero-rings span:nth-child(4) { width: 104vmin; height: 104vmin; animation-delay: -6s; }

@keyframes authPulse {
    0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
}

.auth-hero-brand {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0 var(--space-lg);
}

.auth-hero-brand img {
    width: min(420px, 60%);
    height: auto;
    filter: drop-shadow(0 0 24px rgba(108, 165, 174, 0.35));
}

.auth-hero-brand p {
    margin-top: var(--space-lg);
    color: rgba(255, 255, 255, 0.75);
    font-size: 15px;
}

.auth-hero-caption {
    position: absolute;
    z-index: 2;
    left: 0;
    right: 0;
    bottom: 40px;
    text-align: center;
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* Form panel */
.auth-card {
    flex: 1 1 0;
    min-width: 360px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 48px 24px;
    background: var(--auth-panel);
    color: var(--auth-label);
}

/* Form column capped at 488px, centered inside the panel */
.auth-card > * {
    width: 100%;
    max-width: 488px;
}

.auth-card .auth-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.auth-card .auth-logo img {
    height: 36px;
    max-width: 100%;
}

/* Logo already shown large in the hero */
.auth-page:has(.auth-hero-brand) .auth-card .auth-logo {
    display: none;
}

.auth-card .auth-title {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin-bottom: var(--space-xs);
}

.auth-card .auth-subtitle {
    text-align: center;
    color: var(--auth-muted);
    font-size: 13px;
    margin-bottom: var(--space-lg);
}

.auth-card form {
    padding-top: var(--space-md);
}

.auth-card .form-group {
    margin-bottom: 20px;
}

.auth-card .form-group label {
    color: var(--auth-label);
    font-size: 12.8px;
    font-weight: 400;
    margin-bottom: 6px;
}

.auth-card .input-icon-wrapper .input-icon {
    display: none;
}

.auth-card .form-input,
.auth-card .input-icon-wrapper .form-input {
    height: 45px;
    padding: 12px;
    background: var(--auth-input);
    border: 1px solid var(--auth-border);
    border-radius: 7px;
    color: var(--auth-text);
    font-size: 12.8px;
    box-shadow: none;
}

.auth-card .form-input:focus {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px rgba(108, 165, 174, 0.15);
}

.auth-card .form-input::placeholder {
    color: #5c6163;
}

.auth-card .form-input:-webkit-autofill {
    -webkit-text-fill-color: var(--auth-text);
    -webkit-box-shadow: 0 0 0 1000px var(--auth-input) inset;
    caret-color: var(--auth-text);
}

.auth-card .form-hint {
    color: var(--auth-muted);
    font-size: 12px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    padding: 4px;
    background: none;
    border: 0;
    color: #8a8f91;
    cursor: pointer;
}

.password-toggle:hover,
.password-toggle.is-visible {
    color: #fff;
}

.auth-card .input-icon-wrapper:has(.password-toggle) .form-input {
    padding-right: 40px;
}

.auth-card .auth-remember {
    display: flex;
    justify-content: center;
    margin: 28px 0 20px;
}

.auth-card .checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--auth-text);
    font-size: 12.8px;
    cursor: pointer;
}

.auth-card .checkbox-label input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    border: 1px solid var(--auth-border);
    border-radius: 4px;
    background: var(--auth-input);
    cursor: pointer;
    display: grid;
    place-content: center;
}

.auth-card .checkbox-label input[type="checkbox"]:checked {
    background: var(--auth-accent);
    border-color: var(--auth-accent);
}

.auth-card .checkbox-label input[type="checkbox"]:checked::after {
    content: "";
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translateY(-1px) rotate(45deg);
}

.auth-card .auth-btn {
    display: flex;
    min-width: 120px;
    height: 45px;
    margin: 24px auto 0;
    padding: 0 24px;
    background: var(--auth-accent);
    border: 0;
    border-radius: 30px;
    color: #fff;
    font-size: 12.8px;
    font-weight: 500;
    box-shadow: none;
}

.auth-card .auth-remember + .auth-btn {
    margin-top: 0;
}

.auth-card .auth-btn:hover:not(:disabled) {
    background: var(--auth-accent-hover);
    transform: none;
}

.auth-card .auth-forgot {
    display: block;
    margin-top: 28px;
    text-align: center;
    color: #fff;
    font-size: 14.4px;
    font-weight: 600;
    text-decoration: none;
}

.auth-card .auth-forgot:hover {
    color: var(--auth-accent);
}

.auth-card .alert {
    font-size: 13px;
}

.auth-card .auth-footer {
    text-align: center;
    margin-top: var(--space-xl);
    color: var(--auth-muted);
    font-size: 13px;
}

.auth-card .auth-footer a {
    color: var(--auth-accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-card .auth-footer a:hover {
    text-decoration: underline;
}

.auth-card .password-strength .bar {
    background: var(--auth-border);
}

/* Stacked on narrow screens: form first, hero becomes a short banner below */
@media (max-width: 900px) {
    .auth-page {
        flex-direction: column;
    }

    .auth-card {
        order: -1;
        flex: 1 0 auto;
        min-width: 0;
        padding: 40px 20px;
    }

    .auth-page:has(.auth-hero-brand) .auth-card .auth-logo {
        display: block;
    }

    .auth-hero {
        flex: 0 0 auto;
        min-height: 220px;
    }

    .auth-hero-brand {
        display: none;
    }

    .auth-hero-caption {
        bottom: 24px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-hero-rings span {
        animation: none;
    }
}

/* Password strength */
.password-strength {
    display: flex;
    gap: 4px;
    margin-top: var(--space-sm);
}

.password-strength .bar {
    flex: 1;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    transition: background var(--transition-fast);
}

.password-strength.weak .bar:nth-child(1) { background: var(--danger); }
.password-strength.fair .bar:nth-child(-n+2) { background: var(--warning); }
.password-strength.good .bar:nth-child(-n+3) { background: var(--accent); }
.password-strength.strong .bar { background: var(--success); }

/* --- Alerts & Toasts --- */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    animation: fadeIn 0.3s ease;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 14px;
    min-width: 280px;
}

/* --- Loading & Skeleton --- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-sm);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-md);
}

.skeleton-card {
    height: 120px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

/* --- MC Viewer (Encrypted Content) --- */
.mc-viewer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.mc-viewer .mc-viewer-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mc-viewer .mc-viewer-header h3 {
    font-size: 16px;
}

.mc-viewer .mc-locked {
    padding: var(--space-2xl);
    text-align: center;
}

.mc-viewer .mc-locked .lock-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    animation: pulse 2s infinite;
}

.mc-viewer .mc-locked p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.mc-viewer .mc-locked .decrypt-form {
    display: flex;
    gap: var(--space-sm);
    max-width: 320px;
    margin: 0 auto;
}

.mc-viewer .mc-locked .decrypt-form .form-input {
    flex: 1;
}

.mc-viewer .mc-content {
    display: none;
    padding: var(--space-lg);
}

.mc-viewer .mc-content iframe {
    width: 100%;
    height: 70vh;
    border: none;
    border-radius: var(--radius-md);
}

/* --- Pending State --- */
.pending-state {
    max-width: 480px;
    margin: var(--space-2xl) auto;
    text-align: center;
    padding: var(--space-2xl);
    background: var(--warning-bg);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-lg);
    animation: fadeInUp 0.5s ease both;
}

.pending-state .pending-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
}

.pending-state h2 {
    font-size: 20px;
    margin-bottom: var(--space-sm);
    color: var(--warning);
}

.pending-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .nemesys-sidebar {
        transform: translateX(-100%);
    }

    .nemesys-sidebar.open {
        transform: translateX(0);
    }

    .nemesys-main {
        margin-left: 0;
    }

    .nemesys-header .mobile-toggle {
        display: flex;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .market-ticker {
        gap: var(--space-sm);
    }

    .ticker-item {
        min-width: 150px;
        padding: var(--space-sm) var(--space-md);
    }

    .mc-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .mc-item .mc-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .mc-viewer .mc-locked .decrypt-form {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .nemesys-content {
        padding: var(--space-md);
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Mobile sidebar overlay --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* --- Mobile toggle button --- */
.mobile-toggle {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
    }
}

/* ============================================
   Responsividade v1.6.2 — login e area do cliente
   em qualquer proporcao de tela (320px a 4K,
   retrato e paisagem)
   ============================================ */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

img,
iframe {
    max-width: 100%;
}

/* Altura real da tela em celulares (barra do navegador) */
#nemesys-portal-root,
.nemesys-main,
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Flex item sem min-width:0 herdava a largura do conteudo (444px em celular) */
.nemesys-main {
    min-width: 0;
}

/* Conteudo centralizado em telas largas */
.nemesys-content {
    margin: 0 auto;
}

.nemesys-content.is-fullwidth {
    margin: 0;
}

/* Textos longos (titulos de MC, e-mails, nomes) quebram em vez de vazar */
.kpi-card,
.section-card,
.mc-item .mc-info,
.profile-meta,
.profile-note {
    min-width: 0;
    overflow-wrap: anywhere;
}

.kpi-card .kpi-value {
    overflow-wrap: anywhere;
}

/* Cabecalho: titulo com reticencias, usuario nunca empurra a pagina */
.nemesys-header {
    gap: var(--space-md);
}

.nemesys-header .header-left {
    min-width: 0;
    flex: 1 1 auto;
}

.nemesys-header .header-left h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.nemesys-header .header-right {
    flex: 0 0 auto;
    min-width: 0;
}

.nemesys-header .user-info span {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nemesys-header .user-avatar {
    flex-shrink: 0;
}

.mobile-toggle {
    flex-shrink: 0;
}

/* Cabecalho das secoes quebra linha quando falta espaco */
.section-card .section-header {
    flex-wrap: wrap;
    gap: var(--space-sm) var(--space-md);
}

.section-card .section-header h2 {
    min-width: 0;
}

.mc-item {
    gap: var(--space-md);
}

.mc-item .mc-info {
    flex: 1 1 auto;
}

.mc-item .mc-actions {
    flex-shrink: 0;
}

/* Menu lateral: rola quando a tela e baixa (celular deitado) */
.nemesys-sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: width var(--transition-slow), transform var(--transition-slow);
}

.setores-frame {
    height: calc(100vh - 150px);
    height: calc(100dvh - 150px);
}

.toast {
    min-width: 0;
    max-width: calc(100vw - 32px);
}

/* Tablet e notebook pequeno: perfil em 1 coluna antes de apertar */
@media (max-width: 1100px) {
    .profile-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .nemesys-header {
        padding: 0 var(--space-md);
    }

    .nemesys-header .header-left h1 {
        font-size: 16px;
    }

    .nemesys-header .user-info span {
        display: none;
    }

    .nemesys-content {
        padding: var(--space-md);
    }

    .nemesys-content.is-fullwidth {
        padding: var(--space-sm);
    }

    .section-card {
        padding: var(--space-md);
    }

    .kpi-card {
        padding: var(--space-md);
    }

    .kpi-card .kpi-value {
        font-size: 22px;
    }

    .setores-frame {
        min-height: 420px;
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px);
    }

    .sub-grid {
        grid-template-columns: 1fr !important;
    }

    /* 16px evita o zoom automatico do iPhone ao focar o campo */
    .form-input,
    .auth-card .form-input,
    .auth-card .input-icon-wrapper .form-input {
        font-size: 16px;
    }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        top: var(--space-md);
    }
}

@media (max-width: 420px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .nemesys-content {
        padding: 12px;
    }

    .mc-item {
        padding: 12px;
    }

    .mc-item .mc-actions {
        justify-content: space-between;
    }
}

/* Celular deitado: menu e iframe cabem na altura */
@media (max-height: 500px) and (orientation: landscape) {
    .setores-frame {
        min-height: 300px;
    }

    .nemesys-sidebar .sidebar-logo {
        padding: var(--space-md);
    }

    .nemesys-sidebar .nav-item {
        padding: 8px var(--space-md);
    }
}

/* --- Login / cadastro --- */
.auth-card {
    min-width: 0;
}

.auth-card .alert {
    overflow-wrap: anywhere;
}

/* Notebook entre 901 e 1200px: painel do formulario com largura util */
@media (min-width: 901px) and (max-width: 1200px) {
    .auth-hero {
        flex: 1 1 0;
    }

    .auth-card {
        flex: 1 1 0;
        min-width: 420px;
    }
}

/* Monitores grandes: formulario proporcional */
@media (min-width: 1800px) {
    .auth-card > * {
        max-width: 520px;
    }
}

@media (max-width: 900px) {
    .auth-card {
        justify-content: flex-start;
        padding: 40px 20px 32px;
    }

    .auth-card .auth-logo {
        margin-bottom: var(--space-lg);
    }

    .auth-hero {
        min-height: 160px;
    }
}

@media (max-width: 380px) {
    .auth-card {
        padding: 28px 16px 24px;
    }

    .auth-card .auth-btn {
        width: 100%;
    }

    .auth-card .auth-remember {
        margin: 20px 0 16px;
    }
}

/* Celular deitado: login sem faixa decorativa ocupando a tela */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    .auth-card {
        padding: 24px 20px;
    }

    .auth-hero {
        min-height: 120px;
    }

    .auth-hero-rings {
        display: none;
    }
}

/* --- LGPD: aviso, aceite e documentos legais --- */
.auth-card .lgpd-notice {
    margin: 4px 0 18px;
    padding: 12px 14px;
    border: 1px solid var(--auth-border);
    border-left: 3px solid var(--auth-accent);
    border-radius: 7px;
    background: var(--auth-input);
    color: var(--auth-muted);
    font-size: 12px;
    line-height: 1.55;
}

.auth-card .lgpd-notice strong {
    display: block;
    margin-bottom: 4px;
    color: var(--auth-label);
    font-size: 12.8px;
    font-weight: 600;
}

.auth-card .lgpd-notice p {
    margin: 0;
}

.auth-card .lgpd-notice a,
.auth-card .consent-label a,
.auth-card .auth-privacy-note a {
    color: var(--auth-accent);
}

.auth-card .consent-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-card .consent-label {
    align-items: flex-start;
    line-height: 1.5;
}

.auth-card .consent-label input[type="checkbox"] {
    flex: 0 0 16px;
    margin-top: 2px;
}

.auth-card .consent-label em {
    color: var(--auth-muted);
    font-style: normal;
}

.auth-card .auth-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.auth-card .auth-privacy-note {
    margin: 16px 0 0;
    text-align: center;
    color: var(--auth-muted);
    font-size: 11.5px;
    line-height: 1.5;
}

.auth-card .auth-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
    margin-top: var(--space-lg);
    color: var(--auth-muted);
    font-size: 12px;
}

.auth-card .auth-legal a {
    color: var(--auth-muted);
    text-decoration: none;
}

.auth-card .auth-legal a:hover {
    color: var(--auth-accent);
    text-decoration: underline;
}

.legal-page {
    flex: 1 1 auto;
    width: 100%;
    min-height: 100vh;
    padding: 48px 16px;
    background: #111213;
    color: #c1c1c1;
}

.legal-doc {
    max-width: 760px;
    margin: 0 auto;
    font-size: 14.5px;
    line-height: 1.7;
}

.legal-doc h1 {
    color: #fff;
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 4px;
}

.legal-doc h2 {
    color: #e2e2e2;
    font-size: 16px;
    font-weight: 600;
    margin: 28px 0 8px;
}

.legal-doc p,
.legal-doc ul {
    margin: 0 0 10px;
}

.legal-doc ul {
    padding-left: 20px;
}

.legal-doc a {
    color: #6ca5ae;
}

.legal-doc .legal-meta {
    color: #7c8183;
    font-size: 13px;
}

.legal-doc .legal-back {
    display: inline-block;
    margin-bottom: 24px;
    color: #7c8183;
    font-size: 13px;
    text-decoration: none;
}

.legal-doc .legal-back:hover {
    color: #6ca5ae;
}

.legal-doc table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 12px;
    font-size: 13.5px;
}

.legal-doc th,
.legal-doc td {
    padding: 8px 10px;
    border: 1px solid #1f2223;
    text-align: left;
    vertical-align: top;
}

.legal-doc th {
    background: #181a1b;
    color: #e2e2e2;
    font-weight: 600;
}

@media (max-width: 600px) {
    .legal-page {
        padding: 28px 16px;
    }

    .legal-doc h1 {
        font-size: 22px;
    }
}

/* A pagina de login fica dentro de #nemesys-portal-root (flex em linha):
   sem isto ela encolhia para a largura do formulario (celular deitado, tablet) */
#nemesys-portal-root > .auth-page,
#nemesys-portal-root > .pending-state {
    flex: 1 1 auto;
    width: 100%;
}
