/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:      #fd7e14;
  --accent2:     #e8670a;
  --accent-soft: rgba(253,126,20,.1);
  --bg:          #f4f5f7;
  --sidebar-bg:  #1a1d27;
  --sidebar-w:   240px;
  --header-h:    60px;
  --surface:     #ffffff;
  --border:      #e8eaed;
  --text:        #1a1d27;
  --text-muted:  #6b7280;
  --success:     #10b981;
  --error:       #ef4444;
  --warning:     #f59e0b;
  --info:        #3b82f6;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --font-body:   'DM Sans', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ── Login ─────────────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1d27 0%, #252836 100%);
}

.login-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo__brand {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.login-logo__brand span { color: var(--accent); }

.login-logo__badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: .05em;
}

.login-box h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-box p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
  width: 100%;
}

.form-control:focus { border-color: var(--accent); background: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all .2s;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 13px;
  margin-top: 8px;
  font-size: 15px;
}

.btn-primary:hover { background: var(--accent2); }
.btn-primary:active { transform: scale(.98); }

/* ── App Shell ─────────────────────────────────────────────────────── */
#app { display: none; height: 100vh; overflow: hidden; }
#app.ready { display: flex; }

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.sidebar-brand span { color: var(--accent); }

.sidebar-company {
  margin-top: 6px;
  font-size: 11px;
  color: rgba(255,255,255,.4);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section {
  padding: 0 12px;
  margin-bottom: 4px;
}

.nav-section__label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.25);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 1px;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active i { color: var(--accent); }

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: rgba(255,255,255,.35);
  transition: color .15s;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}

.user-card:hover { background: rgba(255,255,255,.06); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; overflow: hidden; }
.user-info__name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info__role { font-size: 11px; color: rgba(255,255,255,.35); }

.btn-logout-icon { color: rgba(255,255,255,.3); font-size: 14px; transition: color .15s; flex-shrink: 0; }
.btn-logout-icon:hover { color: var(--error); }

/* ── Main ──────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.header-title { font-size: 16px; font-weight: 700; color: var(--text); }
.header-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.badge-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-status--trial    { background: #fef3c7; color: #92400e; }
.badge-status--active   { background: #d1fae5; color: #065f46; }
.badge-status--inactive { background: #fee2e2; color: #991b1b; }
.badge-status--pending  { background: #e0e7ff; color: #3730a3; }

/* ── Content ───────────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Cards KPI ─────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.kpi-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.kpi-card__label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-card__icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.kpi-card__value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.kpi-card__sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Tables ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 14px; font-weight: 700; }

.card-body { padding: 20px; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge--success  { background: #d1fae5; color: #065f46; }
.badge--error    { background: #fee2e2; color: #991b1b; }
.badge--warning  { background: #fef3c7; color: #92400e; }
.badge--info     { background: #dbeafe; color: #1e40af; }
.badge--gray     { background: #f3f4f6; color: #374151; }
.badge--orange   { background: #ffedd5; color: #9a3412; }

/* ── Botões ────────────────────────────────────────────────────────── */
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); transition: all .15s; }
.btn-icon:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.4);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { color: var(--text-muted); font-size: 18px; transition: color .15s; }
.modal-close:hover { color: var(--error); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Loading ───────────────────────────────────────────────────────── */
#global-loading {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(255,255,255,.7);
  display: none; align-items: center; justify-content: center;
}
#global-loading.show { display: flex; }
.spinner-lg { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ─────────────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; min-width: 280px; transform: translateX(120%); transition: transform .3s ease; }
.toast.show { transform: translateX(0); }
.toast--success { border-color: var(--success); }
.toast--success i { color: var(--success); }
.toast--error   { border-color: var(--error); }
.toast--error i { color: var(--error); }
.toast--warning { border-color: var(--warning); }
.toast--warning i { color: var(--warning); }

/* ── Empty state ───────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Pagination ────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; padding: 16px 20px; border-top: 1px solid var(--border); }
.page-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; border: 1px solid var(--border); color: var(--text-muted); transition: all .15s; }
.page-btn:hover, .page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-info { font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* ── 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: #c0c4cc; }

/* ── Settings Tabs ── */
.settings-tab { padding: 10px 20px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-pane { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── KPI icon fix ── */
.kpi-card__icon i { font-size: 16px; line-height: 1; }
