.mlai-app, .mlai-app * {
  box-sizing: border-box;
}

.mlai-app {
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  color: #1f2937;
}

.mlai-loading {
  padding: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

.mlai-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 16px;
  min-height: 820px;
}

.mlai-sidebar {
  background: #0f172a;
  color: #f8fafc;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mlai-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 10px 8px 14px;
}

.mlai-nav-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
}

.mlai-nav-btn:hover {
  background: #111827;
  color: #fff;
}

.mlai-nav-btn.active {
  background: #1d4ed8;
  color: #fff;
}

.mlai-side-note {
  margin-top: auto;
  font-size: 12px;
  color: #cbd5e1;
  border-top: 1px solid rgba(255,255,255,0.14);
  padding-top: 12px;
}

.mlai-main {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
}

.mlai-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.mlai-header-left h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.mlai-header-left p {
  margin: 6px 0 0;
  color: #475569;
}

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

.mlai-header-right label {
  font-size: 13px;
  color: #374151;
  display: grid;
  gap: 4px;
}

.mlai-header-right select,
.mlai-header-right input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 14px;
}

.mlai-status {
  min-height: 20px;
  font-size: 13px;
  margin-bottom: 12px;
}

.mlai-status.ok { color: #065f46; }
.mlai-status.err { color: #b91c1c; }

.mlai-btn, .mlai-file-btn {
  border: 1px solid #cbd5e1;
  background: #0f172a;
  color: #fff;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.mlai-btn.light {
  background: #fff;
  color: #0f172a;
}

.mlai-mini-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 6px;
}

.mlai-mini-btn.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.mlai-view { display: none; }
.mlai-view.active { display: block; }

.mlai-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.mlai-kpi-grid.compact {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.mlai-kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
}

.mlai-kpi-card span {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}

.mlai-kpi-card strong {
  font-size: 26px;
  line-height: 1;
  color: #111827;
}

.mlai-2col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
  margin-bottom: 12px;
}

.mlai-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
}

.mlai-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.mlai-card p {
  margin: 0 0 12px;
  color: #475569;
}

.mlai-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mlai-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mlai-inline input,
.mlai-inline select {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
}

.mlai-sub {
  font-size: 13px;
  color: #475569;
  margin-bottom: 8px;
}

.mlai-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.mlai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mlai-table th,
.mlai-table td {
  border-bottom: 1px solid #eef2f7;
  padding: 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.mlai-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.mlai-empty {
  text-align: center;
  color: #64748b;
  padding: 16px;
}

.mlai-empty-block {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 14px;
  color: #64748b;
  background: #fff;
}

.mlai-muted {
  color: #64748b;
  font-size: 12px;
}

.mlai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.mlai-badge.good {
  border-color: #bbf7d0;
  color: #166534;
  background: #f0fdf4;
}

.mlai-badge.neutral {
  border-color: #e2e8f0;
  color: #334155;
  background: #f8fafc;
}

.mlai-form-grid {
  display: grid;
  gap: 10px;
}

.mlai-form-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #475569;
}

.mlai-form-grid input,
.mlai-form-grid select,
.mlai-form-grid textarea {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
}

.mlai-form-grid textarea {
  min-height: 70px;
  resize: vertical;
}

.mlai-chart-wrap {
  height: 260px;
}

.mlai-file-btn {
  position: relative;
  overflow: hidden;
  background: #0f172a;
  color: #fff;
}

.mlai-file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.mlai-small {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
}

.mlai-month-group {
  margin-top: 12px;
}

.mlai-month-group h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

@media (max-width: 1160px) {
  .mlai-shell {
    grid-template-columns: 1fr;
  }

  .mlai-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .mlai-brand {
    width: 100%;
    padding-bottom: 8px;
  }

  .mlai-side-note {
    width: 100%;
    border-top: 0;
    padding-top: 4px;
  }

  .mlai-kpi-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .mlai-kpi-grid.compact {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .mlai-2col {
    grid-template-columns: 1fr;
  }
}
