/* ============== VARIABLES ============== */
:root {
    --bg-primary: #08080d;
    --bg-secondary: #101018;
    --bg-tertiary: #17171f;
    --bg-card: #111119;
    --bg-hover: #1c1c28;
    --bg-elevated: #1a1a24;

    --text-primary: #ededf2;
    --text-secondary: #8888a0;
    --text-muted: #555568;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-dim: rgba(99, 102, 241, 0.12);

    --success: #22c55e;
    --success-dim: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.12);

    --border: #1e1e2e;
    --border-light: #2c2c3e;
    --border-subtle: #161622;

    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;

    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.08);

    --font-main: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-slow: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ============== RESET ============== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    letter-spacing: normal;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    font-size: 14px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

::selection {
    background: var(--accent);
    color: white;
}

/* ============== LAYOUT ============== */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.75rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
    backdrop-filter: blur(12px);
    background: rgba(16, 16, 24, 0.85);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
}

.header-company-selector {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.header-company-selector select {
    width: auto;
    min-width: 180px;
    max-width: 280px;
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%238888a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
}

.header-company-selector select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.header-company-selector select:hover {
    border-color: var(--border-light);
    background-color: var(--bg-hover);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent) 0%, #a855f7 50%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============== PANEL (for modals, etc) ============== */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1.15rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.15rem 0;
    border: none;
}

/* ============== INPUTS ============== */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    transition: var(--transition);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: var(--bg-hover);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    transition: var(--transition);
    resize: vertical;
    line-height: 1.5;
}

.input-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: var(--bg-hover);
}

.device-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.device-selector input {
    width: 80px;
    text-align: center;
}

.device-selector .helper {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============== BUTTONS ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.78rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-weight: 500;
}

.btn-sm:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-xs);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: #dc2626;
}

.icon {
    font-size: 1rem;
}

/* ============== CONTENT ============== */
.content {
    flex: 1;
    padding: 1.25rem 1.75rem;
    overflow-y: auto;
    height: calc(100vh - 52px);
    scroll-behavior: smooth;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.content-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============== DEVICES GRID ============== */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 0.75rem;
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    letter-spacing: 0.01em;
    animation: fadeIn 0.3s ease;
}

/* ============== DEVICE CARD ============== */
.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all var(--transition);
    position: relative;
}

.device-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.device-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim), var(--shadow-glow);
}

.device-card.offline {
    opacity: 0.55;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-title h4 {
    font-size: 1rem;
    font-weight: 600;
}

.card-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

.card-config-area {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    border: 1px solid var(--border-subtle);
}

.card-input-row {
    display: flex;
    gap: 0.5rem;
}

.card-input-row.multi .card-input {
    flex: 1;
}

.card-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.38rem 0.55rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    transition: var(--transition);
}

.card-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.card-input[type="date"],
.card-input[type="time"],
.card-input.time-input-24h {
    color-scheme: dark;
}

/* Time input 24h format */
.time-input-24h,
.input-group .time-input-24h {
    font-family: var(--font-mono);
    text-align: center;
    letter-spacing: 0.1em;
}

.time-input-24h::placeholder {
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* Override para garantir que inputs de texto de hora tenham estilo correto */
.input-group input.time-input-24h {
    font-family: var(--font-mono);
    text-align: center;
}

.btn-gps {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-xs);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
}

.btn-gps:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.btn-gps:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-gps.pending {
    background: var(--warning);
    border-color: var(--warning);
}

.btn-gps.pending:hover {
    background: #d97706;
}

.btn-gps .gps-icon {
    font-size: 1rem;
    line-height: 1;
}

/* ============== PENDING LOCATION BADGE ============== */
.pending-location-badge {
    background: var(--warning-dim);
    color: var(--warning);
    font-size: 0.7rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-xs);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-mono);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ============== SAVE/SCHEDULE BUTTON ============== */
.btn-save {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    color: var(--text-muted);
}

.btn-save:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-save.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-save.active:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.btn-save .save-icon {
    font-size: 1rem;
    line-height: 1;
}

/* ============== PROXY SYNC BUTTON (Download from SuperProxy) ============== */
.btn-proxy-sync {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.3rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.btn-proxy-sync:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--success);
    border-color: var(--success);
}

.btn-proxy-sync:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-proxy-sync .proxy-icon {
    width: 14px;
    height: 14px;
}

/* ============== PROXY STATUS BUTTON (Upload to SuperProxy / Start / Stop) ============== */
.btn-proxy-status {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.3rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.btn-proxy-status:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-proxy-status:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-proxy-status .proxy-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* Status: Idle (círculo cinza) */
.btn-proxy-status.proxy-idle {
    color: var(--text-muted);
}

.btn-proxy-status.proxy-idle:hover:not(:disabled) {
    color: var(--text-secondary);
}

/* Status: Validating (spinner animado) */
.btn-proxy-status.proxy-validating {
    color: var(--accent);
    pointer-events: none;
}

.btn-proxy-status.proxy-validating .proxy-icon.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Status: Error (X vermelho) */
.btn-proxy-status.proxy-error {
    background: var(--danger-dim);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-proxy-status.proxy-error:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
}

/* Status: Configured (check verde, pronto para start) */
.btn-proxy-status.proxy-configured {
    background: var(--success-dim);
    border-color: var(--success);
    color: var(--success);
}

.btn-proxy-status.proxy-configured:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.25);
    transform: scale(1.05);
}

/* Status: Running (play azul/roxo, ativo) */
.btn-proxy-status.proxy-running {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-proxy-status.proxy-running:hover:not(:disabled) {
    background: var(--accent-hover);
}

/* Pulse animation para status running */
.btn-proxy-status.proxy-running::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: var(--radius-xs);
    border: 2px solid var(--accent);
    opacity: 0;
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
    0% {
        opacity: 0.6;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.15);
    }
}

/* Ajuste para o input de proxy ficar ao lado do botão */
.card-input-row .input-proxy {
    flex: 1;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
}

.status-badge.online {
    background: var(--success-dim);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.2);
}

.status-badge.offline {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.status-badge.booting {
    background: var(--warning-dim);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.card-actions .btn {
    flex: 1;
    min-width: calc(50% - 0.25rem);
}

/* ============== DESTINATION AREA IN CARD ============== */
.card-destination-area {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid var(--border-light);
}

.card-destination-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-destination-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.card-search-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* ============== TOGGLE SWITCH ============== */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-direction: row !important;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.25);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: #fff;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Toggle small (cards) */
.toggle-sm {
    width: 28px;
    height: 16px;
}

.toggle-sm .toggle-slider::before {
    height: 10px;
    width: 10px;
    left: 2px;
    bottom: 2px;
}

.toggle-sm input:checked + .toggle-slider::before {
    transform: translateX(12px);
}

.toggle-label-sm {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.sync-icon {
    width: 18px;
    height: 18px;
}

/* ============== PROGRAMMING INDICATOR ============== */
.programming-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(8, 8, 13, 0.88);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    z-index: 10;
    border: 2px solid var(--accent);
    animation: pulse-border 2s infinite;
}

.programming-indicator span {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
    letter-spacing: -0.01em;
}

@keyframes pulse-border {
    0% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { border-color: var(--accent-hover); box-shadow: 0 0 15px 5px rgba(99, 102, 241, 0.2); }
    100% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
}

/* ============== TOASTS ============== */
.toasts {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.85rem 1.15rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    animation: slideIn 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    min-width: 280px;
    max-width: 400px;
    font-size: 0.85rem;
    backdrop-filter: blur(8px);
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.helper-text {
    line-height: 1.5;
    color: var(--text-muted);
    font-size: 0.82rem;
}

@keyframes slideIn {
    from {
        transform: translateX(30px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============== MODAL (HISTORY) ============== */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    width: min(980px, 100%);
    max-height: min(80vh, 760px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.35rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-body {
    padding: 1.25rem 1.35rem 1.35rem;
    overflow: auto;
    overscroll-behavior: contain;
}

.modal-body-flush-bottom {
    padding-bottom: 0.5rem;
}

.modal-footer {
    padding: 0.75rem 1.35rem 1.25rem;
    border-top: 1px solid var(--border);
}

.history-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.15rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.history-controls-actions {
    display: flex;
    gap: 0.4rem;
}

.history-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.15rem;
}

.history-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    transition: var(--transition);
}

.history-card:hover {
    border-color: var(--border);
}

.history-card .label {
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.history-card .value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 0.2rem;
    letter-spacing: -0.02em;
}

.history-runs {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.history-table th,
.history-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.history-table th {
    text-align: left;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.68rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.55rem 0.75rem;
}

.history-table tbody tr {
    transition: var(--transition);
}

.history-table tbody tr:hover {
    background: var(--bg-hover);
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-family: var(--font-main);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid var(--border);
}

.status-pill.success { background: var(--success-dim); color: var(--success); border-color: rgba(34, 197, 94, 0.25); }
.status-pill.failed { background: var(--danger-dim); color: var(--danger); border-color: rgba(239, 68, 68, 0.25); }
.status-pill.timeout { background: var(--warning-dim); color: var(--warning); border-color: rgba(245, 158, 11, 0.25); }
.status-pill.running { background: var(--accent-dim); color: var(--accent); border-color: rgba(99, 102, 241, 0.25); }
.status-pill.cancelled { background: rgba(144, 144, 160, 0.08); color: var(--text-muted); border-color: rgba(144, 144, 160, 0.15); }

.history-details {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
}

.history-details pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 0.65rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============== SCROLLBAR ============== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Show scrollbar only on hover for cleaner look */
.content::-webkit-scrollbar-thumb {
    background: transparent;
}

.content:hover::-webkit-scrollbar-thumb {
    background: var(--border-light);
}

/* ============== CARD COLLAPSIBLE SECTION ============== */
.card-section-collapsible {
    margin-bottom: 0.75rem;
}

.card-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color var(--transition), background var(--transition);
}

.card-section-toggle:hover {
    color: var(--accent-hover);
    background: var(--bg-hover);
}

.card-section-arrow {
    font-size: 0.8rem;
    transition: transform 0.25s ease;
    color: var(--text-muted);
}

.card-section-collapsible.collapsed .card-section-arrow {
    transform: rotate(-90deg);
}

.card-section-body {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    opacity: 1;
}

.card-section-collapsible.collapsed .card-section-body {
    max-height: 0;
    opacity: 0;
}

.card-section-collapsible .card-config-area {
    margin-bottom: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* ============== POOL DE COORDENADAS (in-card) ============== */
.pool-inline-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.pool-inline-header-static {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    font-family: var(--font-mono);
}

.pool-inline-section > .pool-card-textarea {
    border-top: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 0;
}

.pool-card-toggle {
    color: var(--text-secondary);
    font-weight: 600;
}

.pool-card-counter {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.7rem;
}

.pool-card-counter.exhausted {
    color: var(--success);
}

.pool-card-body {
    padding: 0.4rem 0.5rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.pool-card-textarea {
    width: 100%;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    resize: vertical;
    margin-bottom: 0.35rem;
}

.pool-card-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.pool-card-actions {
    display: flex;
    gap: 0.3rem;
}

.pool-card-progress-wrap {
    padding: 0 0.5rem 0.3rem;
}

.pool-card-progress {
    width: 100%;
    height: 3px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.pool-card-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.pool-card-progress-fill.done {
    background: linear-gradient(90deg, var(--success) 0%, #16a34a 100%);
}

.pool-card-coord {
    display: block;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-family: var(--font-mono);
    margin-top: 0.2rem;
}

/* ============== COLLAPSIBLE PANELS ============== */
.panel-collapsible .panel-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}

.panel-collapsible .panel-toggle:hover {
    color: var(--accent-hover);
}

.panel-arrow {
    font-size: 0.85rem;
    transition: transform 0.25s ease;
    color: var(--text-muted);
}

.panel-collapsible.collapsed .panel-arrow {
    transform: rotate(-90deg);
}

.panel-collapsible .panel-body {
    overflow: hidden;
    max-height: 600px;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    opacity: 1;
}

.panel-collapsible.collapsed .panel-body {
    max-height: 0;
    opacity: 0;
}

/* ============== PROXY MODAL ============== */
.modal-wide {
    width: min(1100px, 95%);
    max-height: min(85vh, 860px);
}

.proxy-modal-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.65rem;
    line-height: 1.5;
}

.proxy-modal-desc code {
    background: var(--bg-primary);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent);
    border: 1px solid var(--border-subtle);
}

.proxy-modal-textarea {
    width: 100%;
    min-height: 220px;
    max-height: 350px;
    resize: vertical;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.7;
    padding: 0.75rem;
    white-space: nowrap;
    overflow-x: auto;
    margin-top: 0.5rem;
    transition: var(--transition);
}

.proxy-modal-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: var(--bg-secondary);
}

.proxy-modal-textarea::placeholder {
    color: var(--text-muted);
}

.proxy-modal-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.85rem;
}

.proxy-modal-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.proxy-modal-divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

.proxy-modal-subtitle {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.proxy-device-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 280px;
    overflow-y: auto;
}

.proxy-device-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    font-size: 0.8rem;
    transition: var(--transition);
}

.proxy-device-row:hover {
    border-color: var(--border);
    background: var(--bg-hover);
}

.proxy-device-index {
    font-weight: 700;
    color: var(--text-muted);
    min-width: 55px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
}

.proxy-device-name {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 90px;
    font-size: 0.78rem;
}

.proxy-device-value {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proxy-device-value.empty {
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-main);
}

.proxy-device-city {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--warning);
    min-width: 100px;
    text-align: right;
    font-family: var(--font-mono);
}

/* ============== PROXY BADGE (DEVICE CARD) ============== */
.proxy-input-block {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.proxy-input-label {
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--warning);
}

.input-proxy-display {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    cursor: default;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* ============== COMPANY DROPDOWN (HEADER) ============== */
/* Company dropdown option styles are handled by the select element in .header-company-selector */

/* ============== COMPANY PANEL (MAIN AREA) ============== */
.company-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.company-panel.hidden {
    display: none;
}

/* ============== COMPANY INFO CARD (Header + Config unified) ============== */
.company-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.35rem;
}

.company-info-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.company-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.company-header-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.company-header-actions {
    display: flex;
    gap: 0.4rem;
}

.company-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.65rem;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.45rem 0.65rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-subtle);
}

.config-item label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.config-value {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 500;
}

.config-value:empty::after {
    content: '\2014';
    color: var(--text-muted);
}

/* ============== COMPANY DATA SECTION (Proxies + Pool unified) ============== */
.company-data-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.company-data-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.35rem;
    cursor: pointer;
    transition: background var(--transition);
}

.company-data-header:hover {
    background: var(--bg-hover);
}

.company-data-toggle-arrow {
    transition: transform var(--transition);
    pointer-events: none;
}

.company-data-toggle-arrow.open {
    transform: rotate(180deg);
}

.company-data-header h4 {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.company-data-badges {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.company-data-body {
    padding: 0.15rem 1.35rem 1.15rem;
}

.company-data-body.hidden {
    display: none;
}

.company-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.company-data-col {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.company-data-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.company-data-label .text-muted {
    font-weight: 400;
    color: var(--text-muted);
}

.company-data-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: flex-end;
}

.company-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 200px;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    resize: vertical;
    line-height: 1.6;
    flex: 1;
    transition: var(--transition);
}

.company-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: var(--bg-hover);
}

.company-textarea::placeholder {
    color: var(--text-muted);
}

.company-section-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Keep old class for backward compat with device section header */
.company-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.35rem;
    border-bottom: 1px solid var(--border);
}

.company-section-header h4 {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

@media (max-width: 700px) {
    .company-data-grid {
        grid-template-columns: 1fr;
    }
}

/* ============== COMPANY DEVICES SECTION ============== */
.company-devices-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
}

.company-devices-section .company-section-header {
    padding: 0.85rem 1.35rem;
}

.company-devices-section .devices-grid,
.company-devices-section .devices-list {
    margin-top: 0;
    padding: 0 1.35rem 1.15rem;
}

/* ============== SCHEDULE DROPDOWN ============== */
.schedule-dropdown-wrapper {
    position: relative;
}

.schedule-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 50;
    margin-top: 0.35rem;
    width: 240px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem;
    animation: modalIn 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.schedule-dropdown.hidden {
    display: none;
}

.schedule-dropdown .input-group {
    margin-bottom: 0.5rem;
}

.schedule-dropdown .input-group label {
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
}

.schedule-dropdown .input-group input {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

/* ============== VIEW TOGGLE ============== */
.view-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.view-toggle-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.view-toggle-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3);
}

.view-toggle-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 1.8;
}

/* ============== STATUS DOT SMALL ============== */
.status-dot-sm {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot-sm.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot-sm.offline { background: var(--danger); }
.status-dot-sm.booting { background: var(--warning); animation: pulse-dot 1.5s infinite; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============== BUTTON REMOVE ============== */
.btn-remove {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-xs);
    transition: var(--transition);
    white-space: nowrap;
}

.btn-remove:hover {
    color: var(--danger);
    background: var(--danger-dim);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-remove-confirming {
    background: var(--danger) !important;
    color: white !important;
    border-color: var(--danger) !important;
    font-weight: 600;
    animation: shake-subtle 0.3s ease;
}

@keyframes shake-subtle {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* ============== SIMPLIFIED DEVICE CARD (Redesigned) ============== */
.device-card.simplified {
    padding: 0;
    border-left: 3px solid var(--border);
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.device-card.simplified:hover {
    transform: none;
}

.device-card.simplified.status-online  { border-left-color: var(--success); }
.device-card.simplified.status-offline { border-left-color: var(--danger); }
.device-card.simplified.status-booting { border-left-color: var(--warning); }

.device-card.simplified .card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem 0.45rem;
}

.device-card.simplified .card-identity {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.device-card.simplified .card-identity h4 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.device-card.simplified .device-mode-chip {
    font-size: 0.62rem;
    padding: 0.12rem 0.45rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.device-card.simplified .card-config-area {
    padding: 0.45rem 0.8rem;
    background: rgba(23, 23, 31, 0.5);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.device-card.simplified .device-mode-select {
    width: 100%;
    padding: 0.28rem 0.45rem;
    font-size: 0.72rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-main);
    transition: var(--transition);
}

.device-card.simplified .device-mode-select:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.device-card.simplified .card-schedule-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.device-card.simplified .card-schedule-row input {
    flex: 1;
    padding: 0.28rem 0.45rem;
    font-size: 0.72rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    min-width: 0;
    color-scheme: dark;
    transition: var(--transition);
}

.device-card.simplified .card-schedule-row input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.device-card.simplified .card-actions-new {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.8rem 0.55rem;
}

.device-card.simplified .card-btn-program {
    flex: 1;
    font-size: 0.72rem;
    padding: 0.38rem 0.5rem;
}

.device-card.simplified .card-btn-power {
    font-size: 0.72rem;
    padding: 0.38rem 0.5rem;
    flex-shrink: 0;
}

.device-card.simplified .card-actions-new .btn-remove {
    flex-shrink: 0;
    font-size: 0.68rem;
    padding: 0.38rem 0.45rem;
}

/* ============== DEVICE LIST VIEW ============== */
.devices-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.device-row-header {
    display: grid;
    grid-template-columns: 14px 1fr 130px 185px 110px;
    gap: 0.65rem;
    align-items: center;
    padding: 0.4rem 0.85rem;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.device-row {
    display: grid;
    grid-template-columns: 14px 1fr 130px 185px 110px;
    gap: 0.65rem;
    align-items: center;
    padding: 0.5rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    transition: var(--transition);
    position: relative;
}

.device-row:hover {
    border-color: var(--border);
    background: var(--bg-hover);
}

.device-row .row-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-row .device-mode-select-sm {
    width: 100%;
    padding: 0.25rem 0.4rem;
    font-size: 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-main);
    transition: var(--transition);
}

.device-row .device-mode-select-sm:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.device-row .row-schedule {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.device-row .row-schedule input {
    flex: 1;
    padding: 0.25rem 0.4rem;
    font-size: 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    min-width: 0;
    color-scheme: dark;
    transition: var(--transition);
}

.device-row .row-schedule input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.device-row .row-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: flex-end;
}

.btn-icon-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
    padding: 0;
}

.btn-icon-sm:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-icon-sm.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-icon-sm.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-icon-sm.btn-remove-icon {
    color: var(--text-muted);
}

.btn-icon-sm.btn-remove-icon:hover {
    color: var(--danger);
    background: var(--danger-dim);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-icon-sm.btn-remove-confirming {
    background: var(--danger) !important;
    color: white !important;
    border-color: var(--danger) !important;
    width: auto;
    padding: 0 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    animation: shake-subtle 0.3s ease;
}

/* Programming indicator for list view */
.device-row.is-programming {
    border-color: var(--accent);
    animation: pulse-border 2s infinite;
}

.device-row .row-prog-status {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

/* ============== RESPONSIVE: List view stacks on mobile ============== */
@media (max-width: 700px) {
    .device-row-header { display: none; }
    .device-row {
        grid-template-columns: 12px 1fr;
        gap: 0.35rem;
        padding: 0.65rem;
    }
    .device-row .device-mode-select-sm,
    .device-row .row-schedule,
    .device-row .row-actions {
        grid-column: 1 / -1;
    }
}

/* ============== BADGE ============== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent);
    letter-spacing: 0.01em;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.badge-sm {
    font-size: 0.62rem;
    padding: 0.12rem 0.42rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-success {
    background: var(--success-dim);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.15);
}

.badge-warning {
    background: var(--warning-dim);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.15);
}

.badge-danger {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.15);
}

/* ============== NO COMPANY STATE ============== */
.no-company-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 350px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    max-width: 320px;
}

.empty-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.85rem;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.empty-state p {
    font-size: 0.82rem;
    line-height: 1.5;
}

/* ============== UNALLOCATED DEVICES ============== */
.unallocated-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.unallocated-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.unallocated-header h4 {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.devices-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.4rem;
}

.devices-grid.compact .device-card {
    padding: 0.5rem 0.65rem;
    opacity: 0.45;
    border-color: var(--border-subtle);
    background: var(--bg-tertiary);
}

.devices-grid.compact .device-card:hover {
    opacity: 0.8;
    border-color: var(--border);
    background: var(--bg-card);
}

/* ============== DEVICE ALLOCATION MODAL ============== */
.device-allocation-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 45vh;
    overflow-y: auto;
    padding: 0.1rem;
}

.device-allocation-list label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.82rem;
    border: 1px solid transparent;
    background: var(--bg-tertiary);
}

.device-allocation-list label:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.device-allocation-list input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 3px;
}

.device-allocation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.device-allocation-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.device-allocation-item input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
}

.device-allocation-item .device-alloc-name {
    font-size: 0.82rem;
    flex: 1;
    font-weight: 500;
}

.device-allocation-item .device-alloc-status {
    font-size: 0.68rem;
    font-weight: 600;
}

/* ============== POOL PROGRESS BAR ============== */
.pool-progress-bar {
    margin-top: 0.5rem;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.pool-progress-bar:empty {
    display: none;
}

.pool-progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ============== RESPONSIVE ============== */
@media (max-width: 900px) {
    .header {
        flex-direction: column;
        gap: 0.65rem;
        padding: 0.65rem 1rem;
    }

    .header-left {
        flex-direction: column;
        gap: 0.65rem;
        width: 100%;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .header-company-selector {
        flex: 1;
        min-width: 0;
    }

    .header-company-selector select {
        min-width: 0;
        flex: 1;
    }

    .content {
        height: auto;
        padding: 0.85rem;
    }

    .company-info-card {
        padding: 0.85rem 1rem;
    }

    .company-config-grid {
        grid-template-columns: 1fr 1fr;
    }

    .company-section-header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .company-devices-section .devices-grid,
    .company-devices-section .devices-list {
        padding: 0 0.85rem 0.85rem;
    }

    .devices-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        border-radius: var(--radius-sm);
    }

    .modal-overlay {
        padding: 0.75rem;
    }
}

@media (max-width: 500px) {
    .company-config-grid {
        grid-template-columns: 1fr;
    }

    .company-section-header h4 {
        font-size: 0.78rem;
    }

    .logo-text {
        font-size: 1.1rem;
    }
}
