:root {
  --bg-main: #090d16;
  --bg-panel: rgba(17, 24, 39, 0.82);
  --bg-card: rgba(24, 33, 52, 0.72);
  --bg-card-hover: rgba(31, 43, 68, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(99, 102, 241, 0.35);
  --text-primary: #f3f6fc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #ef4444;
  --corp-color: #38bdf8;
  --pers-color: #a78bfa;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top right, #16203a 0%, var(--bg-main) 55%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Login Screen */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #151f38 0%, #070a12 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 30px;
  backdrop-filter: blur(18px);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald), var(--accent));
  box-shadow: 0 0 12px var(--emerald);
}

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: rgba(11, 16, 28, 0.92);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-header {
  padding: 0 10px;
}

.sidebar-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-btn.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: var(--border-strong);
  color: #fff;
  font-weight: 600;
}

.badge-count {
  background: var(--rose);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
}

.security-pill {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 12px;
  padding: 12px;
  font-size: 0.76rem;
  color: #a7f3d0;
}

.main-area {
  padding: 28px 34px 60px;
  max-width: 1380px;
  width: 100%;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.scope-switcher {
  display: inline-flex;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px;
  gap: 4px;
}

.scope-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.scope-btn.active {
  background: var(--accent);
  color: #fff;
}

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

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  backdrop-filter: blur(10px);
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 6px;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Panels & Two-column grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

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

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.16s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.btn-emerald {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.78rem;
}

.input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(9, 13, 22, 0.75);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

/* Pills & Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.tag-corp {
  background: rgba(56, 189, 248, 0.14);
  color: var(--corp-color);
}

.tag-pers {
  background: rgba(167, 139, 250, 0.15);
  color: var(--pers-color);
}

.tag-alta {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.tag-media {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}

.tag-baixa {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}

/* Lists: Commitments & Threads */
.item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.item-row.done {
  opacity: 0.52;
}

.item-row.done .item-title {
  text-decoration: line-through;
}

.item-title {
  font-weight: 600;
  font-size: 0.94rem;
}

.item-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.thread-card {
  background: rgba(17, 24, 39, 0.78);
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.thread-card.urg-alta {
  border-left-color: var(--rose);
}

.thread-card.urg-baixa {
  border-left-color: var(--emerald);
}

.thread-bullets {
  margin: 10px 0;
  padding-left: 18px;
  color: #dbe4f3;
  font-size: 0.89rem;
}

.thread-bullets li {
  margin-bottom: 4px;
}

.thread-action {
  background: rgba(99, 102, 241, 0.11);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 0.83rem;
  color: #c7d2fe;
  margin-bottom: 12px;
}

/* Planner Photo Dropzone */
.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.45);
  background: rgba(99, 102, 241, 0.06);
  border-radius: 14px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
}

.dropzone:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent);
}

/* Chat Widget */
.chat-box {
  height: 290px;
  overflow-y: auto;
  background: rgba(9, 13, 22, 0.65);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.87rem;
  white-space: pre-wrap;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.msg-ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
}

/* Category Bars */
.cat-bar-row {
  margin-bottom: 11px;
}

.cat-bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  margin-bottom: 4px;
}

.cat-bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--emerald));
  border-radius: 99px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 18px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid var(--border-strong);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  z-index: 1200;
  font-size: 0.88rem;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }
  .nav-list {
    flex-direction: row;
    overflow-x: auto;
  }
  .nav-btn {
    white-space: nowrap;
    width: auto;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .main-area {
    padding: 18px 16px 50px;
  }
}
