/* Gestor Streaming — interface */
:root {
  --brand: #6366f1; --brand-rgb: 99,102,241;
  --bg: #f4f5f9; --surface: #ffffff; --surface-2: #f8f9fc; --border: #e4e6ee;
  --text: #171a26; --text-2: #5b6177; --text-3: #8a90a6;
  --success: #12a150; --success-bg: #e7f7ee; --warn: #c27c0e; --warn-bg: #fdf3e1;
  --danger: #dc3545; --danger-bg: #fdecee; --info: #2563eb; --info-bg: #e8effd;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --sidebar-w: 260px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e1017; --surface: #161924; --surface-2: #1c2030; --border: #272c3d;
  --text: #e8eaf2; --text-2: #a3a9bd; --text-3: #737a92;
  --success: #34d27b; --success-bg: rgba(52,210,123,.12); --warn: #f2b24b; --warn-bg: rgba(242,178,75,.12);
  --danger: #ff6b78; --danger-bg: rgba(255,107,120,.12); --info: #6aa1ff; --info-bg: rgba(106,161,255,.12);
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
small, .muted { color: var(--text-2); }
.text-success { color: var(--success); } .text-danger { color: var(--danger); }
.nowrap { white-space: nowrap; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-xs { width: 12px; height: 12px; } .icon-lg { width: 40px; height: 40px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; transition: transform .2s ease; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: var(--text); font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--border); }
.brand:hover { text-decoration: none; }
.brand-logo { max-height: 32px; max-width: 140px; object-fit: contain; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-mark.lg { width: 52px; height: 52px; font-size: 22px; border-radius: 14px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; padding: 16px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(var(--brand-rgb), .1); color: var(--brand); }
.nav-item.soon { opacity: .6; }
.nav-badge { margin-left: auto; font-style: normal; font-size: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 0 6px; color: var(--text-3); white-space: nowrap; }
.sidebar-foot { padding: 12px 20px; font-size: 11px; color: var(--text-3); border-top: 1px solid var(--border); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.page-title { font-size: 19px; font-weight: 650; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 24px 28px 48px; max-width: 1360px; width: 100%; }
.backdrop { display: none; }
.icon-btn.only-mobile { display: none; }

.icon-btn { background: transparent; border: 1px solid transparent; color: var(--text-2); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
[data-theme="light"] .theme-dark, [data-theme="dark"] .theme-light { display: none; }

.dropdown { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 4px 8px; cursor: pointer; color: var(--text); text-align: left; font: inherit; }
.user-btn:hover { background: var(--surface); border-color: var(--border); }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(var(--brand-rgb), .15); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu form { margin: 0; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.card-head p { margin: 4px 0 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.span-2 { grid-column: span 2; }
.table-card { padding: 0; overflow: hidden; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: rgba(var(--brand-rgb), .1); color: var(--brand); }
.stat-icon.warn { background: var(--warn-bg); color: var(--warn); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-label { display: block; color: var(--text-2); font-size: 12.5px; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.stat-value small { font-size: 14px; color: var(--text-3); font-weight: 500; }
.stat-brand { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #000)); border: 0; color: #fff; }
.stat-brand .stat-label { color: rgba(255,255,255,.8); }
.stat-brand .stat-icon { background: rgba(255,255,255,.18); color: #fff; }

.kv { margin: 0; display: grid; gap: 2px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; font-weight: 600; text-align: right; }
.kv-total dd { font-size: 16px; }
.kv-inline { display: inline-block; margin-right: 10px; font-size: 12.5px; }

.progress { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; min-width: 140px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 20px; transition: width .3s; }
.progress.warn span { background: var(--warn); } .progress.danger span { background: var(--danger); }
.server-bars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; }
.server-bar-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-weight: 500; }

.setup-card .card-head { align-items: center; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 20px; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.checklist .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex-shrink: 0; }
.checklist .done .check { background: var(--success); border-color: var(--success); color: #fff; }
.checklist .check .icon { width: 13px; height: 13px; }
.checklist .done span:not(.check) { color: var(--text-3); text-decoration: line-through; }

.empty { text-align: center; padding: 36px 16px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty.compact { padding: 16px; }
.empty .icon-lg { color: var(--text-3); }
.empty h2 { color: var(--text); }
.empty .btn { margin-top: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* Forms */
.form .field, .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span:first-child { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.field small { font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search], input[type=time], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .18); }
input:disabled { background: var(--surface-2); color: var(--text-3); }
input[type=color] { width: 64px; height: 40px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
input[type=file] { font: inherit; color: var(--text-2); }
textarea { resize: vertical; min-height: 80px; }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon { border: 1px solid var(--border); border-left: 0; background: var(--surface-2); color: var(--text-2); border-radius: 0 10px 10px 0; padding: 0 12px; cursor: pointer; }
.input-code { font-size: 22px; letter-spacing: .3em; text-align: center; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-narrow { max-width: 820px; }
.form-section { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 10px 0 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 8px; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; min-width: 240px; }
.inline-check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); font-weight: 400; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; margin-bottom: 8px; border-bottom: 1px dashed var(--border); cursor: pointer; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { font-size: 12px; }
.switch { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 20px; background: var(--border); position: relative; cursor: pointer; flex-shrink: 0; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .25); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { display: none; }
.chip span { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; color: var(--text-2); background: var(--surface); user-select: none; }
.chip input:checked + span { background: rgba(var(--brand-rgb), .12); border-color: var(--brand); color: var(--brand); font-weight: 600; }

.image-field { display: flex; align-items: center; gap: 16px; }
.image-preview { max-height: 56px; max-width: 160px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: var(--surface-2); }

/* Settings */
.settings { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.tabs-vertical { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; }
.tabs-vertical a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.tabs-vertical a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.tabs-vertical a.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); border: 1px solid var(--border); }
.settings-form { max-width: 760px; }
.callout { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin: 16px 0; }
.callout p { margin: 6px 0 10px; color: var(--text-2); }
code.copy { display: block; padding: 8px 10px; margin-bottom: 6px; cursor: copy; word-break: break-all; position: relative; }
code.copy.copied::after { content: "copiado"; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: var(--success); color: #fff; font-family: var(--font); font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.secret-key { font-size: 16px; letter-spacing: .08em; margin: 8px 0; }

/* Tables */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.filters select { width: auto; min-width: 170px; }
.search { position: relative; flex: 0 1 320px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; }
.search input { padding-left: 34px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table .actions form { margin: 0; }
.row-muted td { opacity: .6; }
.empty-row { text-align: center; color: var(--text-3); padding: 32px !important; }
.cell-user { display: flex; gap: 10px; align-items: center; }
.cell-user div { display: flex; flex-direction: column; line-height: 1.3; }
.cell-user small { font-size: 12px; }
.details { max-width: 420px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; border-radius: 20px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); font-style: normal; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-muted { background: var(--surface-2); color: var(--text-3); }
.badge-role-admin { background: rgba(var(--brand-rgb), .12); color: var(--brand); border-color: transparent; }
.badge-role-financeiro { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-role-supervisor { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-role-atendente { background: var(--info-bg); color: var(--info); border-color: transparent; }

.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 8px; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); padding: 0 8px; }
.pagination a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination a:hover { text-decoration: none; }

.steps { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 10px; color: var(--text-2); }
.steps li strong { color: var(--text); }
.list-plain { padding-left: 18px; }

/* Alerts */
.alert { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; font-weight: 500; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-warning { background: var(--warn-bg); color: var(--warn); }
.alert-close { background: none; border: 0; color: inherit; font-size: 20px; cursor: pointer; line-height: 1; opacity: .7; }

/* Auth */
.auth-body { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, rgba(var(--brand-rgb), .18), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(var(--brand-rgb), .12), transparent 60%), var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 32px; }
.auth-card.wide { max-width: 620px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 8px; text-align: center; }
.auth-brand h1 { font-size: 20px; }
.auth-logo { max-height: 56px; max-width: 220px; object-fit: contain; }
.auth-sub { text-align: center; color: var(--text-2); margin-bottom: 22px; }
.auth-foot { text-align: center; margin: 16px 0 0; font-size: 13px; }

/* Installer */
.install-steps { display: flex; gap: 6px; margin: 8px 0 22px; }
.install-steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.install-steps span.on { background: var(--brand); }
.req-list { list-style: none; padding: 0; margin: 0 0 18px; }
.req-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.req-ok { color: var(--success); font-weight: 600; } .req-fail { color: var(--danger); font-weight: 600; }

/* Responsive */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { margin-left: 0; }
  .icon-btn.only-mobile { display: grid; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .tabs-vertical { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 4px; }
  .tabs-vertical a { white-space: nowrap; }
  .server-bars { grid-template-columns: minmax(0, 1fr); }
  .user-meta { display: none; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table td { border: 0; padding: 6px 16px; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
  .table .actions { justify-content: flex-start; }
}
@media (max-width: 520px) { .stats { grid-template-columns: minmax(0, 1fr); } .page-title { font-size: 17px; } }
