/* AP Studio — aligned to Specification/Wireframes (navy #34446C · accent #B8D433 · bg #F4F4F4) */
:root {
  --color-navy: #34446c;
  --color-navy-deep: #283552;
  --color-navy-muted: #4a5d8a;
  --color-accent: #b8d433;
  --color-accent-dark: #9fb82a;
  --color-bg: #f4f4f4;
  --color-surface: #ffffff;
  --color-border: #e4e7ee;
  --color-text: #1c2433;
  --color-text-muted: #5c6678;
  --sidebar-width: 268px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(28, 36, 51, 0.06);
  --shadow-md: 0 8px 24px rgba(28, 36, 51, 0.08);
  --transition: 180ms ease;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--color-navy-muted); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-accent-dark); }

/* Buttons (wireframe) */
.btn-primary {
  background: var(--color-accent) !important;
  border-color: var(--color-accent-dark) !important;
  color: var(--color-navy-deep) !important;
  font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus {
  background: #c4dc4a !important;
  border-color: var(--color-accent-dark) !important;
  color: var(--color-navy-deep) !important;
}
.btn-secondary {
  background: var(--color-surface) !important;
  border-color: var(--color-border) !important;
  color: var(--color-navy) !important;
  font-weight: 600;
}
.btn-secondary:hover {
  border-color: var(--color-navy-muted) !important;
  background: #eef1f6 !important;
  color: var(--color-navy-deep) !important;
}
.btn-outline-secondary, .btn-outline-primary {
  font-weight: 600;
  border-color: var(--color-border);
  color: var(--color-navy);
}
.btn-outline-primary:hover {
  background: rgba(184, 212, 51, 0.2);
  border-color: var(--color-accent-dark);
  color: var(--color-navy-deep);
}
.btn-success {
  background: var(--color-navy) !important;
  border-color: var(--color-navy-deep) !important;
  font-weight: 600;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-navy-muted);
  box-shadow: 0 0 0 0.2rem rgba(184, 212, 51, 0.35);
}

/* ——— Auth (anonymous / Identity login) ——— */
.auth-simple {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-bg);
}
@media (max-width: 900px) {
  .auth-simple { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: auto !important; }
}
.auth-brand-panel {
  background: linear-gradient(160deg, var(--color-navy-deep) 0%, var(--color-navy) 45%, #3d5280 100%);
  color: #fff;
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.auth-brand-panel h1 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}
.auth-brand-panel p { opacity: 0.88; max-width: 36ch; margin: 0; }
.auth-brand-panel .auth-brand-footer { font-size: 0.8125rem; opacity: 0.65; margin-top: 2rem; }
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 4vw, 3rem);
  background: var(--color-bg);
  min-height: 100vh;
}
.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  padding: 2rem 2.25rem;
}
.auth-card .row,
.auth-card [class*="col-"] {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 0;
  margin: 0;
}
.auth-card .form-control,
.auth-card .form-select {
  width: 100%;
}
.auth-card h1, .auth-card h2, .auth-card .h1, .auth-card .h2 {
  margin: 0 0 0.25rem;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--color-navy);
}
.auth-card .subtitle, .auth-card > p { color: var(--color-text-muted); font-size: 0.9375rem; }

/* ——— App shell ——— */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-navy);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand img { border-radius: var(--radius-sm); width: 44px; height: auto; background: #fff; }
.sidebar-brand strong { display: block; font-size: 0.9375rem; font-weight: 600; }
.sidebar-brand span { font-size: 0.75rem; opacity: 0.7; }
.nav-section-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.5;
  padding: 1.25rem 1.25rem 0.5rem;
}
.nav-list { list-style: none; margin: 0; padding: 0 0.5rem; }
.nav-list a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: rgba(255,255,255,0.88);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-list a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-list a.is-active {
  background: var(--color-accent);
  color: var(--color-navy-deep);
  font-weight: 600;
}
.nav-list a.is-active .nav-icon { opacity: 0.85; color: var(--color-navy-deep); }
.nav-icon {
  width: 1.75rem;
  text-align: center;
  opacity: 0.55;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: ui-monospace, Consolas, monospace;
}
.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  font-size: 0.75rem;
  opacity: 0.55;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.app-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header .page-title { margin: 0; font-weight: 600; color: var(--color-navy); font-size: 1.125rem; }
.app-header .page-subtitle { margin: 0; font-size: 0.8125rem; color: var(--color-text-muted); font-weight: 400; }
.app-main { padding: 1.5rem; flex: 1; overflow-x: auto; }
.app-footer {
  padding: 0.75rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  background: #fff;
}

h1.h3, .app-main > h1, .page-header h1 {
  color: var(--color-navy);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.lead-muted, .text-muted { color: var(--color-text-muted) !important; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 576px) { .kpi-row { grid-template-columns: 1fr; } }
.kpi {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.kpi .label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); }
.kpi .value { font-size: 1.75rem; font-weight: 700; color: var(--color-navy); line-height: 1.2; margin-top: 0.25rem; }
.kpi .meta { font-size: 0.8125rem; color: var(--color-text-muted); margin-top: 0.35rem; }

.card-ap, .card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  overflow: hidden;
}
.card-ap .card-ap-header, .card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: 0.75rem;
}
.card-ap .card-ap-header h2, .card .card-header h2 {
  margin: 0; font-size: 1rem; font-weight: 600; color: var(--color-navy);
}
.card-ap .card-ap-body, .card .card-body { padding: 1.25rem; }

.progress-ap {
  height: 0.45rem;
  background: #e8ebf2;
  border-radius: 99px;
  overflow: hidden;
  margin: 0.25rem 0;
}
.progress-ap > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-navy-muted), var(--color-accent));
}

/* Data tables */
.app-main > .table,
.app-main > .dataTables_wrapper,
.app-main .table-responsive > .table {
  background: #fff;
  box-shadow: var(--shadow-sm);
}
table.table, table.data-table {
  background: #fff;
  border: 1px solid var(--color-border);
  --bs-table-bg: #fff;
}
.card-ap-body.p-0 > .table,
.card-ap-body.p-0 > .dataTables_wrapper .table,
.card-ap-body.p-0 table {
  border: none !important;
  border-radius: 0 !important;
  margin-bottom: 0 !important;
  box-shadow: none !important;
}
table.table thead th, table.data-table thead th {
  background: #f8f9fb;
  color: var(--color-navy);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  border-bottom-color: var(--color-border);
  white-space: nowrap;
  vertical-align: middle;
}
table.table tbody td { vertical-align: middle; }
table.dataTable { width: 100% !important; border-collapse: collapse !important; }
.dataTables_wrapper {
  margin-bottom: 1rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem 1rem;
  box-shadow: var(--shadow-sm);
}
.card-ap-body.p-0 > .dataTables_wrapper {
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0.75rem 1rem 1rem;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--color-navy) !important;
  color: #fff !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
}
.badge-ap-warning { background: #fff8e6; color: #8a6d1d; border: 1px solid #f0e0a8; font-weight: 600; }
.badge-ap-ok { background: #eef6d4; color: #4a6420; border: 1px solid #d5e89a; font-weight: 600; }
.alert {
  border-radius: var(--radius-sm);
  border-width: 1px;
}
.alert-success { background: #eef6d4; border-color: #d5e89a; color: #3d5220; }
.alert-info { background: #eef1f8; border-color: #c5cee0; color: var(--color-navy); }
.alert-warning { background: #fff8e6; border-color: #f0e0a8; color: #6b5420; }
.alert-danger { background: #fdeaea; border-color: #f0c4c4; color: #7a2e2e; }

/* Forms */
.app-main form.col-lg-6,
.app-main form.col-lg-7 {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  max-width: 36rem;
}
.btn-link {
  color: var(--color-navy-muted);
  font-weight: 600;
  text-decoration: none;
}
.btn-link:hover { color: var(--color-accent-dark); }

/* Admin hub tiles */
.admin-tile {
  display: block;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  height: 100%;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  color: inherit;
}
.admin-tile:hover {
  border-color: var(--color-navy-muted);
  box-shadow: var(--shadow-md);
  color: inherit;
}
.admin-tile h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-navy);
}
.admin-tile p { margin: 0; font-size: 0.875rem; color: var(--color-text-muted); }

.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.menu-toggle {
  display: none;
  width: 42px; height: 42px;
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: var(--radius-sm);
  color: var(--color-navy);
  font-size: 1.25rem;
  align-items: center;
  justify-content: center;
}
.sidebar-backdrop { display: none; }
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 36, 51, 0.45);
    z-index: 150;
  }
  .sidebar-backdrop.show { display: block; }
}

/* Identity UI inside auth card */
.auth-card .form-floating > .form-control,
.auth-card .form-control { margin-bottom: 0.5rem; }
.auth-card .btn-primary { width: 100%; padding: 0.75rem 1rem; margin-top: 0.5rem; }
