/* ContaFlow AI - protótipo SaaS contábil */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --text: #162033;
  --muted: #667085;
  --line: #dfe6f1;
  --primary: #2454ff;
  --primary-2: #e8edff;
  --success: #159957;
  --warning: #b7791f;
  --danger: #d92d20;
  --info: #0974b8;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --sidebar-width: 288px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background:
    radial-gradient(circle at 15% 20%, rgba(36, 84, 255, 0.22), transparent 34%),
    radial-gradient(circle at 80% 60%, rgba(21, 153, 87, 0.16), transparent 34%),
    #0d1324;
  color: #fff;
}

.login-hero {
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-hero h1 {
  font-size: clamp(2.4rem, 6vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
  margin: 32px 0;
}

.login-hero p {
  color: #cbd5e1;
  max-width: 660px;
  font-size: 1.1rem;
}

.login-panel {
  margin: 32px;
  padding: 40px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-2);
}

.primary-button,
.ghost-button,
.danger-button,
.success-button,
.icon-button,
.avatar-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  transition: 0.2s ease;
}

.primary-button {
  background: var(--primary);
  color: white;
}

.success-button {
  background: var(--success);
  color: white;
}

.danger-button {
  background: var(--danger);
  color: white;
}

.ghost-button {
  background: var(--surface-2);
  color: var(--text);
}

.primary-button:hover,
.ghost-button:hover,
.success-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  filter: brightness(0.98);
}

.icon-button,
.avatar-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: var(--surface-2);
}

.avatar-button {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #0f172a;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4f7cff, #31c48d);
  color: #fff;
  font-weight: 900;
}

.brand span,
.sidebar-card p {
  display: block;
  color: #94a3b8;
  font-size: 0.85rem;
}

.nav-menu {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
}

.nav-icon {
  width: 26px;
  text-align: center;
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 247, 251, 0.86);
  backdrop-filter: blur(14px);
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(223, 230, 241, 0.75);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  letter-spacing: -0.04em;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.search {
  width: min(380px, 42vw);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 0 12px;
}

.search input {
  border: 0;
  outline: 0;
  width: 100%;
  padding: 12px 0;
  background: transparent;
}

.content {
  padding: 32px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.04);
}

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

.card h2,
.card h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  right: -38px;
  top: -38px;
  background: var(--primary-2);
  border-radius: 50%;
}

.stat-value {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  margin: 12px 0 4px;
}

.stat-caption,
.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge.success {
  background: #e7f8ef;
  color: var(--success);
}

.badge.warning {
  background: #fff4df;
  color: var(--warning);
}

.badge.danger {
  background: #fff0ef;
  color: var(--danger);
}

.badge.info {
  background: #e8f3ff;
  color: var(--info);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tr:last-child td {
  border-bottom: 0;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  padding: 9px 12px;
  background: var(--surface-2);
  border-radius: 999px;
  font-weight: 800;
  color: var(--muted);
}

.document-dropzone {
  border: 2px dashed #b7c3d6;
  border-radius: 24px;
  padding: 34px;
  background: #f8fbff;
  text-align: center;
}

.document-dropzone.dragging {
  border-color: var(--primary);
  background: var(--primary-2);
}

.document-dropzone input {
  display: none;
}

.upload-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.file-row,
.alert-row,
.automation-row,
.client-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.file-icon,
.alert-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--surface-2);
  flex: 0 0 auto;
}

.alert-row.danger {
  border-left: 5px solid var(--danger);
}

.alert-row.warning {
  border-left: 5px solid var(--warning);
}

.alert-row.info {
  border-left: 5px solid var(--info);
}

.chart {
  height: 220px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding-top: 24px;
}

.chart-bar {
  flex: 1;
  min-width: 28px;
  border-radius: 12px 12px 4px 4px;
  background: linear-gradient(180deg, #2454ff, #9db2ff);
  position: relative;
}

.chart-bar span {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--muted);
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 8px;
}

.ai-panel {
  background: linear-gradient(135deg, #101828, #172554);
  color: #fff;
  border: 0;
}

.ai-panel .muted,
.ai-panel .eyebrow {
  color: #cbd5e1;
}

.chat-box {
  display: grid;
  gap: 12px;
}

.chat-message {
  padding: 14px;
  border-radius: 18px;
  max-width: 88%;
}

.chat-message.bot {
  background: rgba(255, 255, 255, 0.12);
}

.chat-message.user {
  background: #fff;
  color: var(--text);
  margin-left: auto;
}

.chat-input {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.chat-input input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.workflow-step {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  min-height: 124px;
}

.workflow-step strong {
  display: block;
  margin-bottom: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(520px, 100%);
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 20px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 18px;
  border-radius: 16px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 80;
  animation: fadeIn 0.2s ease;
}

.mobile-only {
  display: none;
}

.empty-state {
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  text-align: center;
}

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

@media (max-width: 1120px) {
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search {
    display: none;
  }
}

@media (max-width: 820px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  .login-hero {
    padding: 36px 24px 10px;
  }

  .login-panel {
    margin: 20px;
    padding: 24px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    width: min(320px, 88vw);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-grid;
  }

  .topbar {
    padding: 16px;
  }

  .topbar-actions .ghost-button {
    display: none;
  }

  .content {
    padding: 18px;
  }

  .grid.cols-4 {
    grid-template-columns: 1fr;
  }

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

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

  .file-row,
  .alert-row,
  .automation-row,
  .client-card {
    align-items: start;
    flex-direction: column;
  }
}
