:root {
  --aa-bg: #f5f7fa;
  --aa-surface: #ffffff;
  --aa-surface-soft: #f8fafc;
  --aa-border: #dfe5ec;
  --aa-border-soft: #edf1f5;
  --aa-text: #182433;
  --aa-text-muted: #667789;
  --aa-text-soft: #8a98a8;
  --aa-primary: #1f6feb;
  --aa-primary-strong: #1555b8;
  --aa-primary-soft: #eaf3ff;
  --aa-teal: #0f9f8f;
  --aa-teal-soft: #e7f8f4;
  --aa-success: #2f9e44;
  --aa-warning: #b7791f;
  --aa-danger: #d64545;
  --aa-sidebar: #092033;
  --aa-sidebar-2: #0d2b42;
  --aa-shadow: 0 8px 24px rgba(24, 36, 51, .07);
  --aa-shadow-soft: 0 2px 10px rgba(24, 36, 51, .05);
  --aa-radius: 8px;
  --aa-radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--aa-text);
  background: var(--aa-bg);
  font-size: 14px;
  letter-spacing: 0;
}
a { color: var(--aa-primary); text-decoration: none; }
a:hover { color: var(--aa-primary-strong); text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; background: var(--aa-bg); }
.sidebar {
  width: 232px;
  min-width: 232px;
  background: linear-gradient(180deg, var(--aa-sidebar) 0%, var(--aa-sidebar-2) 100%);
  color: rgba(255,255,255,.84);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand {
  min-height: 64px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, var(--aa-primary), var(--aa-teal));
  font-size: 15px;
}
.nav-list { flex: 1; padding: 10px 0 12px; overflow-y: auto; }
.nav-section-label {
  padding: 14px 20px 6px;
  color: rgba(255,255,255,.42);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  min-height: 38px;
  margin: 1px 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.active { color: #fff; background: rgba(31,111,235,.92); font-weight: 600; }
.nav-item i { width: 20px; margin-right: 9px; text-align: center; font-size: 14px; }
.sidebar-user {
  padding: 14px 18px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.56);
  font-size: 13px;
}
.sidebar-user a { color: rgba(255,255,255,.82); }
.sidebar-user a:hover { color: #fff; }
.sidebar-user .user-name { color: #fff; font-weight: 600; }

.content-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-header-bar {
  min-height: 56px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--aa-border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-search { flex: 1 1 360px; max-width: 560px; margin-right: auto; }
.topbar-search .input-group { max-width: 560px !important; }
.topbar-search .input-group-text,
.topbar-search .form-control {
  border-color: var(--aa-border);
  background: var(--aa-surface-soft);
}
.topbar-search .form-control:focus { background: #fff; box-shadow: 0 0 0 .2rem rgba(31,111,235,.10); }
.content-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.content-body { flex: 1; padding: 22px 28px 32px; overflow-y: auto; }

.page-header {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-header h4, .page-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--aa-text); }
.card, .section-card, .metric-card, .stat-card {
  background: var(--aa-surface);
  border: 1px solid var(--aa-border-soft);
  border-radius: var(--aa-radius);
  box-shadow: var(--aa-shadow-soft);
}
.card { margin-bottom: 16px; }
.card-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--aa-border-soft);
  background: var(--aa-surface-soft);
  font-weight: 700;
  border-radius: var(--aa-radius) var(--aa-radius) 0 0;
}
.card-body { padding: 18px; }
.metric-card { padding: 18px 20px; min-height: 112px; }
.metric-card .label, .stat-label { color: var(--aa-text-muted); font-size: 12px; font-weight: 600; }
.metric-card .value { color: var(--aa-text); font-size: 26px; font-weight: 800; margin-top: 5px; }
.metric-card .sub { color: var(--aa-text-soft); font-size: 12px; margin-top: 4px; }
.stat-card { padding: 16px; height: 100%; }
.section-card { overflow: hidden; margin-bottom: 16px; }
.section-card .section-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--aa-border-soft);
  background: var(--aa-surface-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}
.section-card .section-body { padding: 16px 18px; }

.action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.action-bar form { gap: 8px !important; }
.form-control, .form-select {
  border-color: var(--aa-border);
  border-radius: var(--aa-radius-sm);
  color: var(--aa-text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--aa-primary);
  box-shadow: 0 0 0 .2rem rgba(31,111,235,.12);
}
.btn { border-radius: var(--aa-radius-sm); font-weight: 600; }
.btn-primary { background: var(--aa-primary); border-color: var(--aa-primary); }
.btn-primary:hover { background: var(--aa-primary-strong); border-color: var(--aa-primary-strong); }
.btn-outline-primary { color: var(--aa-primary); border-color: rgba(31,111,235,.45); }
.btn-outline-primary:hover { background: var(--aa-primary); border-color: var(--aa-primary); }
.btn-sm { padding: .28rem .62rem; }

.table { color: var(--aa-text); margin-bottom: 0; }
.table th {
  background: var(--aa-surface-soft) !important;
  color: var(--aa-text-muted);
  font-size: 12px;
  font-weight: 700;
  border-top: none;
  border-bottom: 1px solid var(--aa-border);
  white-space: nowrap;
}
.table td { vertical-align: middle; border-color: var(--aa-border-soft); }
.table-hover tbody tr:hover { background: #f7fbff; }
.cell-wrap {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: break-word;
  line-height: 1.35;
}
.org-cell { min-width: 140px; max-width: 240px; }
.name-cell { max-width: 240px; display: inline-block; }
.pipeline-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.pipeline-summary-card {
  min-height: 92px;
  padding: 14px 16px;
  border-top: 3px solid var(--pipeline-color, var(--aa-primary));
}
.pipeline-summary-card .summary-value {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
  color: var(--pipeline-color, var(--aa-primary));
}
.pipeline-summary-card .summary-label {
  margin-top: 5px;
  color: var(--aa-text);
  font-size: 13px;
  font-weight: 700;
}
.pipeline-summary-card .summary-sub {
  margin-top: 4px;
  color: var(--aa-text-soft);
  font-size: 12px;
}
.stage-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
}
.stage-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--aa-border);
  border-radius: 999px;
  background: #fff;
  color: var(--aa-text-muted);
  font-size: 12px;
  font-weight: 700;
}
.stage-filter-chip.active, .stage-filter-chip:hover {
  border-color: rgba(31,111,235,.45);
  background: var(--aa-primary-soft);
  color: var(--aa-primary);
}
@media (max-width: 1100px) {
  .pipeline-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .pipeline-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .org-cell { min-width: 160px; max-width: 260px; }
}
.badge, .badge-status { border-radius: 999px; font-weight: 700; letter-spacing: 0; }
.badge-status { font-size: 12px; padding: 4px 10px; display: inline-flex; align-items: center; }
.empty-state { text-align: center; padding: 52px 20px; color: var(--aa-text-soft); }
.empty-state i { font-size: 42px; margin-bottom: 12px; color: #b7c2cf; }
.overdue { color: var(--aa-danger); font-weight: 700; }
.collected { color: var(--aa-success); }
.alert { border-radius: var(--aa-radius); border: 1px solid transparent; }
.flash-msg { position: fixed; top: 16px; right: 16px; z-index: 9999; min-width: 300px; }
.mobile-menu-btn { display: none; }

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15,159,143,.15), transparent 30%),
    linear-gradient(135deg, #eef6f8 0%, #f7fafc 46%, #eaf2ff 100%);
  display: flex;
  align-items: stretch;
}
.login-shell {
  width: min(1080px, calc(100% - 40px));
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) 420px;
  gap: 28px;
  align-items: stretch;
}
.login-brief {
  min-height: 560px;
  padding: 40px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, #092033 0%, #0b3650 54%, #0f6f73 100%);
  box-shadow: var(--aa-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; }
.login-brand i {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,.16);
}
.login-brief h1 { font-size: 32px; line-height: 1.25; font-weight: 800; margin: 44px 0 14px; }
.login-brief p { max-width: 520px; color: rgba(255,255,255,.78); font-size: 15px; line-height: 1.8; margin: 0; }
.login-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 34px; }
.login-point {
  padding: 14px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  min-height: 82px;
}
.login-point strong { display: block; font-size: 14px; margin-bottom: 6px; }
.login-point span { color: rgba(255,255,255,.68); font-size: 12px; line-height: 1.5; }
.login-card {
  align-self: center;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(223,229,236,.8);
  border-radius: 16px;
  box-shadow: var(--aa-shadow);
  padding: 34px;
}
.login-card h2 { font-size: 22px; font-weight: 800; margin: 0 0 8px; }
.login-card .login-subtitle { color: var(--aa-text-muted); margin-bottom: 24px; }
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
}
.login-field-label {
  display: block;
  margin: 0;
  color: var(--aa-text-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}
.login-card .login-input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  color: var(--aa-text);
  background: var(--aa-surface-soft);
  border: 1px solid var(--aa-border);
  border-radius: var(--aa-radius);
  box-shadow: none;
  font-size: 14px;
  line-height: 1.45;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-card .login-input:focus {
  outline: 0;
  background: #fff;
  border-color: var(--aa-primary);
  box-shadow: 0 0 0 3px rgba(31,111,235,.14);
}
.login-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  margin: 0;
  color: var(--aa-text-muted);
  font-size: 14px;
}
.login-check-row .form-check-input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
}
.login-check-row .form-check-label {
  margin: 0;
  font-weight: 500;
  line-height: 1.4;
}
.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--aa-radius);
  font-size: 15px;
  line-height: 1.3;
}
.login-submit i { margin: 0 !important; font-size: 14px; line-height: 1; }
.login-footnote { margin-top: 18px; color: var(--aa-text-soft); font-size: 12px; line-height: 1.6; }

@media (max-width: 992px) {
  .login-shell { grid-template-columns: 1fr; width: min(620px, calc(100% - 28px)); padding: 24px 0; }
  .login-brief { min-height: auto; padding: 30px; }
  .login-points { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 1040; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--aa-shadow); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .content-area { min-height: 100vh; }
  .content-header-bar { padding: 8px 12px; gap: 8px; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .content-header-actions { margin-left: auto; }
  .content-body { padding: 16px 14px 24px; }
  .mobile-menu-btn { display: inline-flex; }
  .page-header { align-items: flex-start !important; flex-direction: column; }
  .page-header > .d-flex { width: 100%; flex-wrap: wrap; }
  .action-bar .form-control, .action-bar .form-select { width: 100%; min-width: 0; }
  .action-bar form { width: 100%; }
  .table-responsive { overflow-x: auto; }
  .stat-card, .metric-card { min-height: 86px; }
  .login-card { padding: 24px; }
  .login-brief h1 { font-size: 25px; margin-top: 30px; }
}
