* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: sans-serif; background: #f5f5f5; color: #333; }
header { background: #1a1a2e; color: #fff; padding: 1rem 2rem; display: flex; align-items: center; justify-content: space-between; }
header .header-brand { display: flex; align-items: center; gap: 1rem; }
header .logo { height: 60px; width: auto; border-radius: 6px; }
header .company-name { font-size: 1.2rem; font-weight: 600; letter-spacing: 0.05em; color: #fff; }
header nav a { color: #fff; text-decoration: none; }
main { padding: 0; }

/* Mensagens globais (django.contrib.messages) */
.messages-bar { padding: .5rem 2rem; }
.alert { padding: .65rem 1rem; border-radius: 4px; font-size: .9rem; margin-bottom: .4rem; }
.alert-error, .alert.error { background: #fde8e6; color: #c0392b; border: 1px solid #f5c6c2; }
.alert-success, .alert.success { background: #e6f4ea; color: #1e8e3e; border: 1px solid #b7dfbf; }
.alert-info, .alert.info { background: #e8f0fe; color: #1a56db; border: 1px solid #c3d4fb; }

/* Dashboard layout */
.dashboard-layout { display: flex; min-height: calc(100vh - 78px); }
.sidebar { width: 220px; background: #1a1a2e; color: #fff; padding: 1.5rem 0; flex-shrink: 0; }
.sidebar-nav ul { list-style: none; }
.sidebar-nav ul li a, .sidebar-module { display: block; padding: 0.65rem 1.25rem; color: #c5d0e0; text-decoration: none; font-size: 0.95rem; border-left: 3px solid transparent; transition: background 0.15s; }
.sidebar-module { cursor: default; }
.sidebar-nav ul li a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar-nav ul li a.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: #4a9eff; }
.sidebar-submenu { display: none; list-style: none; }
.sidebar-submenu.open { display: block; }
.sidebar-submenu li a { padding: 0.5rem 1.25rem 0.5rem 3.25rem; font-size: 0.88rem; color: #a0b0c8; border-left: 3px solid transparent; }
.sidebar-submenu li a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-submenu li a.active { color: #fff; border-left-color: #4a9eff; background: rgba(255,255,255,0.08); }
.dashboard-content { flex: 1; padding: 2rem; background: #f5f5f5; }

.card { background: #fff; border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 6px rgba(0,0,0,0.08); }
.card h3 { color: #1a1a2e; margin-bottom: 1rem; }
.card p { margin-bottom: 0.4rem; }
.card-section { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid #e8e8e8; }
.card-section strong { display: block; margin-bottom: 0.6rem; color: #1a1a2e; }
.user-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.user-table th { text-align: left; padding: 0.5rem 0.75rem; background: #f0f2f5; color: #555; font-weight: 600; }
.user-table td { padding: 0.5rem 0.75rem; border-top: 1px solid #eee; }
.user-table tr:hover td { background: #fafafa; }

.login-container { max-width: 400px; margin: 3rem auto; background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); }
.login-container h2 { margin-bottom: 1.5rem; color: #1a1a2e; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.6rem 0.8rem; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #1a1a2e; }
.form-error { color: #c0392b; margin-bottom: 1rem; font-size: 0.9rem; }
button[type="submit"] { width: 100%; padding: 0.75rem; background: #1a1a2e; color: #fff; border: none; border-radius: 4px; font-size: 1rem; cursor: pointer; margin-top: 0.5rem; }
button[type="submit"]:hover { background: #2d2d5e; }

/* Header nav (usuário + logout) */
.header-nav { display: flex; align-items: center; gap: 1.25rem; }
.header-nav a { color: #c5d0e0; font-size: 0.9rem; }
.header-nav a:hover { color: #fff; }
.header-nav .header-user { color: #fff; font-size: 0.9rem; font-weight: 600; }
.logout-form { margin: 0; }
.header-nav .logout-form button { width: auto; margin: 0; padding: 0.4rem 0.9rem; background: transparent; border: 1px solid rgba(255,255,255,0.4); color: #fff; border-radius: 4px; font-size: 0.85rem; cursor: pointer; }
.header-nav .logout-form button:hover { background: rgba(255,255,255,0.12); }

/* Login: logo no card */
.login-logo { display: block; height: 64px; width: auto; border-radius: 8px; margin: 0 auto 1rem; }
.login-container h2 { text-align: center; }

/* Landing pública */
.landing { max-width: 720px; margin: 4rem auto; text-align: center; padding: 0 1.5rem; }
.landing-logo { height: 96px; width: auto; border-radius: 10px; margin-bottom: 1.5rem; }
.landing h1 { color: #1a1a2e; font-size: 2rem; margin-bottom: 0.75rem; letter-spacing: 0.03em; }
.landing p { color: #555; font-size: 1.05rem; margin-bottom: 2rem; line-height: 1.5; }
.btn-primary { display: inline-block; padding: 0.75rem 2rem; background: #1a1a2e; color: #fff; text-decoration: none; border-radius: 6px; font-size: 1rem; transition: background 0.15s; }
.btn-primary:hover { background: #2d2d5e; }

/* Avisos */
.alert-warning { background: #fff8e1; border: 1px solid #ffe082; color: #8a6d3b; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1.25rem; font-size: 0.92rem; }
.alert-success { background: #e8f5e9; border: 1px solid #a5d6a7; color: #2e7d32; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1.25rem; font-size: 0.92rem; }
.alert-error { background: #fdecea; border: 1px solid #f5c6cb; color: #c0392b; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1.25rem; font-size: 0.92rem; }

/* Botão "Testar Conexão" (secundário) */
.testar-form { margin-top: 1rem; }
.testar-form .btn-test { width: auto; margin: 0; padding: 0.6rem 1.2rem; background: #417690; color: #fff; border: none; border-radius: 4px; font-size: 0.95rem; cursor: pointer; }
.testar-form .btn-test:hover { background: #345d73; }

/* Modal de confirmação */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 8px; padding: 1.5rem; width: 420px; max-width: 95vw; box-shadow: 0 4px 24px rgba(0,0,0,0.25); }
.btn-cancel { padding: 0.5rem 1.1rem; background: #ccc; color: #333; border: none; border-radius: 4px; font-size: 0.9rem; cursor: pointer; }
.btn-cancel:hover { background: #bbb; }
.modal-box .btn-danger { width: auto; margin: 0; padding: 0.5rem 1.1rem; background: #c0392b; color: #fff; border: none; border-radius: 4px; font-size: 0.9rem; cursor: pointer; }
.modal-box .btn-danger:hover { background: #a93226; }

/* ── Paginação ── */
.pagination { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }
.page-btn { padding: .4rem .9rem; background: #f0f2f5; border: 1px solid #d0d3d9; border-radius: 4px; text-decoration: none; color: #333; font-size: .88rem; }
.page-btn:hover { background: #e0e4ea; }
.page-info { font-size: .88rem; color: #666; }

/* Modal grande que hospeda criação/edição de fluxo num iframe */
.flow-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.flow-modal-overlay.open { display: flex; }
.flow-modal-box { background: #fff; border-radius: 10px; overflow: hidden; width: 95vw; height: 92vh; max-width: 1400px; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.flow-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.9rem; border-bottom: 1px solid #e6e6e6; background: #fafafa; }
.flow-modal-head h3 { margin: 0; font-size: 0.95rem; }
.flow-modal-close { border: none; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: #666; padding: 0 0.3rem; }
.flow-modal-close:hover { color: #c0392b; }
.flow-modal-frame { flex: 1; border: 0; width: 100%; }

/* Conteúdo renderizado dentro do iframe do modal (sem header/sidebar) */
body.modal-embed { background: #fff; }
body.modal-embed main { min-height: 100vh; }
body.modal-embed .flow-editor { height: 100vh; }
.modal-form-wrap { padding: 1.5rem; }

/* Menu do usuário (header) — dropdown com empresas */
.user-menu { position: relative; }
.user-menu-toggle { background: transparent; border: none; color: #fff; font-size: 0.9rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0; }
.user-menu-toggle .caret { font-size: 0.7rem; color: #c5d0e0; }
.user-menu-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 0.5rem); min-width: 230px; background: #fff; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,0.22); padding: 0.4rem 0; z-index: 1000; }
.user-menu-dropdown.open { display: block; }
.user-menu-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #999; padding: 0.4rem 1rem 0.3rem; }
.user-menu-divider { height: 1px; background: #eee; margin: 0.4rem 0; }
.user-menu-dropdown .user-menu-item { display: block; width: 100%; text-align: left; background: transparent; border: none; border-radius: 0; margin: 0; padding: 0.5rem 1rem; font-size: 0.88rem; color: #333; cursor: pointer; }
.user-menu-dropdown .user-menu-item:hover { background: #f0f2f5; }
.user-menu-dropdown .user-menu-item.active { color: #1a1a2e; font-weight: 600; }

/* ── Dashboard: métricas de uso ── */
.dash-section-title { font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #888; margin-bottom: .75rem; display: flex; align-items: center; gap: .6rem; }
.dash-plan-badge { background: #e8f0fe; color: #1a56db; font-size: .72rem; padding: 2px 8px; border-radius: 20px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.dash-plan-link { margin-left: auto; font-size: .8rem; color: #4a9eff; text-decoration: none; font-weight: 500; text-transform: none; letter-spacing: 0; }
.dash-plan-link:hover { text-decoration: underline; }
.dash-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric-card { background: #fff; border-radius: 10px; padding: 1.25rem; box-shadow: 0 1px 6px rgba(0,0,0,0.08); display: flex; flex-direction: column; gap: .6rem; }
.metric-icon { font-size: 1.4rem; line-height: 1; }
.metric-body { flex: 1; }
.metric-label { font-size: .78rem; color: #888; margin-bottom: .25rem; }
.metric-value { font-size: 1.6rem; font-weight: 700; color: #1a1a2e; line-height: 1.1; }
.metric-limit { font-size: 1rem; font-weight: 400; color: #aaa; }
.metric-bar { height: 6px; background: #eee; border-radius: 3px; margin-top: .5rem; overflow: hidden; }
.metric-bar-fill { height: 100%; background: #1e8e3e; border-radius: 3px; transition: width .3s; }
.metric-bar-fill.bar-warn { background: #e67e22; }
.metric-bar-fill.bar-danger { background: #c0392b; }
.metric-action { font-size: .8rem; color: #4a9eff; text-decoration: none; align-self: flex-end; }
.metric-action:hover { text-decoration: underline; }

/* Badges de status nas execuções recentes */
.run-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge-success { background: #e6f4ea; color: #1e8e3e; }
.badge-error { background: #fde8e6; color: #c0392b; }
.badge-running { background: #e8f0fe; color: #1a56db; }
.badge-queued { background: #f5f5f5; color: #777; }

/* ── Campo obrigatório (*) e dica de campo (?) ── */
.form-req { color: #c0392b; font-style: normal; text-decoration: none; cursor: default; margin-left: 2px; font-weight: 700; }
.form-help { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #e8eef7; color: #4285f4; font-size: .67rem; font-style: normal; font-weight: 700; text-decoration: none; cursor: help; margin-left: 3px; border: 1px solid #c3d4ff; vertical-align: middle; }