/* public/css/app.css */

:root {
  --ink: #0A0E1A;
  --ink2: #1A2240;
  --ink3: #3A4570;
  --surface: #FFFFFF;
  --surface2: #F0F3FF;
  --surface3: #E4E9FF;
  --blue: #1845F5;
  --blue-light: #E8EDFF;
  --red: #E8002D;
  --red-light: #FFE0E7;
  --green: #00A550;
  --green-light: #E0F8EE;
  --amber: #F57C00;
  --amber-light: #FFF0D6;
  --cyan: #00B4D8;
  --cyan-light: #E0F7FC;
  --purple: #7B2FBE;
  --purple-light: #F0E5FF;
  --r: 14px;
  --r2: 10px;
  --container-width: 1400px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background: #EEF1FF;
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
}

/* ============================================ */
/* TOPBAR */
/* ============================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--ink);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.topbar-inner {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--blue);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon i {
  color: #fff;
  font-size: 18px;
}

.logo-text .t1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.logo-text .t2 {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-top: -2px;
}

.topbar-company {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  padding: 5px 12px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notif-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.09);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.notif-btn i {
  color: rgba(255,255,255,0.7);
  font-size: 20px;
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--ink);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================ */
/* NAV TABS */
/* ============================================ */

.nav-scroll {
  background: var(--surface);
  border-bottom: 1.5px solid var(--surface3);
  overflow-x: auto;
  position: sticky;
  top: 58px;
  z-index: 90;
  -webkit-overflow-scrolling: touch;
}

.nav-scroll::-webkit-scrollbar {
  display: none;
}

.nav-tabs-inner {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 8px;
}

.nav-tabs {
  display: flex;
  gap: 0;
  white-space: nowrap;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink3);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  text-decoration: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--blue);
}

.nav-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.nav-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.nav-badge.b {
  background: var(--blue);
}

/* ============================================ */
/* PAGE LAYOUT */
/* ============================================ */

.page {
  padding: 20px 20px 24px;
  max-width: var(--container-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ============================================ */
/* ALERT BANNER */
/* ============================================ */

.alert-banner {
  background: #fff;
  border-radius: var(--r);
  padding: 14px 16px;
  border-left: 4px solid var(--red);
  display: flex;
  align-items: center;
  gap: 14px;
}

.alert-icon {
  width: 42px;
  height: 42px;
  background: var(--red-light);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-icon i {
  color: var(--red);
  font-size: 22px;
}

.alert-text {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--red);
}

.alert-sub {
  font-size: 13px;
  color: var(--ink3);
  margin-top: 2px;
}

.alert-action {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================ */
/* HEADER STRIP */
/* ============================================ */

.header-strip {
  background: var(--ink);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.header-strip::before {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--blue);
  opacity: 0.18;
  pointer-events: none;
}

.header-strip::after {
  content: '';
  position: absolute;
  left: -20px;
  bottom: -20px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.10;
  pointer-events: none;
}

.header-icon {
  width: 48px;
  height: 48px;
  background: rgba(24,69,245,0.25);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  flex-shrink: 0;
}

.header-icon i {
  font-size: 26px;
  color: var(--cyan);
}

.header-info {
  flex: 1;
  z-index: 1;
  min-width: 0;
}

.header-info h1,
.header-info h1.display {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.header-info p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-top: 5px;
  line-height: 1.5;
}

.header-badges {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.hbadge {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.hb-blue {
  background: rgba(24,69,245,0.25);
  color: #89ABFF;
}

.hb-green {
  background: rgba(0,165,80,0.25);
  color: #4AE08A;
}

/* ============================================ */
/* SECTION LABEL */
/* ============================================ */

.sec-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink3);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sec-label::after {
  content: '';
  flex: 1;
  height: 1.5px;
  background: var(--surface3);
}

/* ============================================ */
/* KPI GRID */
/* ============================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 16px;
  border: 1.5px solid var(--surface3);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
}

.kpi-card:active {
  transform: scale(0.97);
}

.kpi-card .k-ico {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.kpi-card .k-ico i {
  font-size: 22px;
}

.kpi-card .k-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.kpi-card .k-label {
  font-size: 13px;
  color: var(--ink3);
  margin-top: 5px;
  font-weight: 500;
}

.kpi-card .k-delta {
  font-size: 12px;
  font-weight: 700;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 99px;
  display: inline-block;
}

.kpi-card .k-sub {
  font-size: 12px;
  color: var(--ink3);
  margin-top: 5px;
  font-weight: 500;
}

.kpi-card .k-stripe {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
}

/* KPI Color Themes */
.kpi-blue .k-ico  { background: var(--blue-light);   color: var(--blue); }
.kpi-blue .k-stripe { background: var(--blue); }
.kpi-blue .k-delta  { background: var(--blue-light);  color: var(--blue); }
.kpi-blue .k-val    { color: var(--blue); }

.kpi-green .k-ico   { background: var(--green-light); color: var(--green); }
.kpi-green .k-stripe { background: var(--green); }
.kpi-green .k-delta  { background: var(--green-light); color: var(--green); }
.kpi-green .k-val    { color: var(--green); }

.kpi-red .k-ico   { background: var(--red-light);   color: var(--red); }
.kpi-red .k-stripe { background: var(--red); }
.kpi-red .k-delta  { background: var(--red-light);  color: var(--red); }
.kpi-red .k-val    { color: var(--red); }

.kpi-amber .k-ico   { background: var(--amber-light); color: var(--amber); }
.kpi-amber .k-stripe { background: var(--amber); }
.kpi-amber .k-delta  { background: var(--amber-light); color: var(--amber); }
.kpi-amber .k-val    { color: var(--amber); }

.kpi-cyan .k-ico   { background: var(--cyan-light);   color: var(--cyan); }
.kpi-cyan .k-stripe { background: var(--cyan); }
.kpi-cyan .k-delta  { background: var(--cyan-light);  color: var(--cyan); }
.kpi-cyan .k-val    { color: var(--cyan); }

.kpi-purple .k-ico   { background: var(--purple-light); color: var(--purple); }
.kpi-purple .k-stripe { background: var(--purple); }
.kpi-purple .k-delta  { background: var(--purple-light); color: var(--purple); }
.kpi-purple .k-val    { color: var(--purple); }

/* ============================================ */
/* SCORE RINGS */
/* ============================================ */

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.score-card {
  background: var(--surface);
  border: 1.5px solid var(--surface3);
  border-radius: var(--r);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}

.ring-wrap svg {
  width: 80px;
  height: 80px;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.ring-unit {
  font-size: 10px;
  color: var(--ink3);
  font-weight: 600;
  text-transform: uppercase;
}

.score-label {
  font-size: 13px;
  color: var(--ink3);
  text-align: center;
  font-weight: 600;
  line-height: 1.3;
}

/* ============================================ */
/* CARD */
/* ============================================ */

.card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 18px;
  border: 1.5px solid var(--surface3);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.card-head-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-head-icon.red  { background: var(--red-light); }
.card-head-icon.red i  { color: var(--red);  font-size: 18px; }
.card-head-icon.blue { background: var(--blue-light); }
.card-head-icon.blue i { color: var(--blue); font-size: 18px; }
.card-head-icon.amber { background: var(--amber-light); }
.card-head-icon.amber i { color: var(--amber); font-size: 18px; }

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i {
  color: var(--blue);
}

.card-action {
  font-size: 13px;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================ */
/* MID & BOTTOM COLS */
/* ============================================ */

.mid-cols,
.bottom-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* ============================================ */
/* INCIDENT LIST */
/* ============================================ */

.inc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: var(--r2);
  border-left: 3.5px solid transparent;
}

.inc-row.sev-high { border-left-color: var(--red); }
.inc-row.sev-med  { border-left-color: var(--amber); }
.inc-row.sev-low  { border-left-color: var(--green); }

.inc-row > div:first-child {
  min-width: 0;
  flex: 1;
}

.inc-row > div:nth-child(2) {
  flex: 2;
  min-width: 0;
}

.inc-id {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink3);
  white-space: nowrap;
}

.inc-desc {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================ */
/* PERMIT LIST */
/* ============================================ */

.permit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.permit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: var(--r2);
}

.permit-type {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 99px;
  white-space: nowrap;
  min-width: 60px;
  text-align: center;
  flex-shrink: 0;
}

.pt-red   { background: var(--red-light);   color: var(--red); }
.pt-amber { background: var(--amber-light); color: var(--amber); }
.pt-blue  { background: var(--blue-light);  color: var(--blue); }

.permit-desc {
  flex: 1;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================ */
/* STATUS BADGES (spill) */
/* ============================================ */

.spill {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sp-open   { background: var(--red-light);   color: var(--red); }
.sp-inv    { background: var(--amber-light); color: var(--amber); }
.sp-closed { background: var(--green-light); color: var(--green); }
.sp-capa   { background: var(--blue-light);  color: var(--blue); }
.sp-act    { background: var(--green-light); color: var(--green); }
.sp-pend   { background: var(--amber-light); color: var(--amber); }

/* ============================================ */
/* AREA LIST (Inspection Score) */
/* ============================================ */

.area-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.area-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.area-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.area-name {
  font-size: 14px;
  color: var(--ink2);
  font-weight: 600;
}

.area-pct {
  font-size: 15px;
  font-weight: 700;
}

.bar-track {
  height: 9px;
  background: var(--surface3);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* ============================================ */
/* CAPA LIST */
/* ============================================ */

.capa-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.capa-row {
  padding: 13px 14px;
  background: var(--surface2);
  border-radius: var(--r2);
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 3.5px solid var(--red);
}

.capa-row.ok {
  border-left-color: var(--amber);
}

.capa-row > div:first-child {
  flex: 1;
  min-width: 0;
}

.capa-id {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink3);
}

.capa-desc {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capa-pic {
  font-size: 12px;
  color: var(--ink3);
  margin-top: 3px;
}

.capa-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  white-space: nowrap;
  flex-shrink: 0;
}

.capa-time.ok {
  color: var(--amber);
}

/* ============================================ */
/* BADGES (generic) */
/* ============================================ */

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  display: inline-block;
}

.badge-injury      { background: var(--red-light);    color: var(--red); }
.badge-nearmiss    { background: var(--amber-light);  color: var(--amber); }
.badge-damage      { background: var(--purple-light); color: var(--purple); }
.badge-environmental { background: var(--cyan-light); color: var(--cyan); }
.badge-high { background: var(--red-light);   color: var(--red); }
.badge-med  { background: var(--amber-light); color: var(--amber); }
.badge-low  { background: var(--green-light); color: var(--green); }

/* ============================================ */
/* AI BAR */
/* ============================================ */

.ai-bar {
  background: var(--ink);
  border-radius: var(--r);
  padding: 20px;
}

.ai-bar-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.ai-bar-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(24,69,245,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-bar-icon i {
  color: #89ABFF;
  font-size: 22px;
}

.ai-bar-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.ai-bar-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}

.ai-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}

.ai-chips::-webkit-scrollbar {
  display: none;
}

.ai-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  border: 1.5px solid rgba(255,255,255,0.12);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.ai-chip:active {
  background: rgba(255,255,255,0.16);
}

.ai-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ai-input {
  flex: 1;
  padding: 13px 18px;
  border-radius: 99px;
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.ai-input::placeholder {
  color: rgba(255,255,255,0.3);
}

.ai-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-send i {
  color: #fff;
  font-size: 20px;
}

/* ============================================ */
/* TABLE */
/* ============================================ */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px;
  background: var(--surface2);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--surface3);
  font-size: 14px;
}

.data-table tr:hover {
  background: var(--surface2);
}

/* ============================================ */
/* PAGINATION */
/* ============================================ */

.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 8px 14px;
  background: var(--surface2);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink2);
  font-size: 13px;
  font-weight: 500;
}

.pagination .active {
  background: var(--blue);
  color: #fff;
}

.pagination a:hover {
  background: var(--surface3);
}

/* ============================================ */
/* FILTER BAR */
/* ============================================ */

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter-select,
.filter-search {
  padding: 10px 14px;
  border: 1.5px solid var(--surface3);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
}

.filter-search {
  flex: 1;
  min-width: 180px;
}

.filter-btn {
  padding: 10px 18px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.filter-reset {
  padding: 10px 18px;
  background: var(--surface3);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink2);
  font-size: 14px;
  font-weight: 500;
}

/* ============================================ */
/* CHART */
/* ============================================ */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.chart-container {
  width: 100%;
  height: 280px;
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 280px;
}

canvas {
  display: block;
  box-sizing: border-box;
}

/* ============================================ */
/* TAB NAV (secondary tabs inside pages) */
/* ============================================ */

.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1.5px solid var(--surface3);
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink3);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================ */
/* MODAL */
/* ============================================ */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  border-radius: 18px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

/* ============================================ */
/* BOTTOM NAV (mobile) */
/* ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--ink);
  border-top: 1.5px solid rgba(255,255,255,0.08);
  padding-bottom: env(safe-area-inset-bottom);
  display: none;
}

.bottom-spacer {
  display: none;
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 11px 0 13px;
  gap: 4px;
  cursor: pointer;
  position: relative;
  text-decoration: none;
}

.bn-item i {
  font-size: 22px;
  color: rgba(255,255,255,0.35);
  transition: color 0.15s;
}

.bn-item span {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
  transition: color 0.15s;
}

.bn-item.active i   { color: var(--blue); }
.bn-item.active span { color: var(--blue); }

.bn-dot {
  position: absolute;
  top: 8px;
  right: calc(50% - 16px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--ink);
}

/* ============================================ */
/* ANIMATIONS */
/* ============================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page > * {
  animation: fadeIn 0.25s ease both;
}

.page > *:nth-child(1)  { animation-delay: 0.00s; }
.page > *:nth-child(2)  { animation-delay: 0.04s; }
.page > *:nth-child(3)  { animation-delay: 0.08s; }
.page > *:nth-child(4)  { animation-delay: 0.12s; }
.page > *:nth-child(5)  { animation-delay: 0.16s; }
.page > *:nth-child(6)  { animation-delay: 0.20s; }
.page > *:nth-child(7)  { animation-delay: 0.24s; }
.page > *:nth-child(8)  { animation-delay: 0.28s; }
.page > *:nth-child(9)  { animation-delay: 0.32s; }

/* ============================================ */
/* RESPONSIVE — TABLET (max 1024px) */
/* ============================================ */

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================ */
/* RESPONSIVE — MOBILE (max 768px) */
/* ============================================ */

@media (max-width: 768px) {
  .page {
    padding: 12px 12px 16px;
    gap: 12px;
  }

  .topbar-inner {
    padding: 0 14px;
    height: 54px;
  }

  .topbar-company {
    max-width: 110px;
    font-size: 12px;
  }

  /* Header */
  .header-strip {
    padding: 16px;
    gap: 12px;
    flex-direction: row;
    align-items: flex-start;
  }

  .header-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .header-icon i {
    font-size: 20px;
  }

  .header-info h1,
  .header-info h1.display {
    font-size: 18px;
  }

  .header-info p {
    font-size: 12px;
  }

  .header-badges {
    gap: 6px;
  }

  .hbadge {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* KPI — 1 kolom full width di mobile */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 16px 18px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }

  .kpi-card .k-ico {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .kpi-card .k-ico i {
    font-size: 24px;
  }

  .kpi-card .k-body {
    flex: 1;
    min-width: 0;
  }

  .kpi-card .k-val {
    font-size: 28px;
    line-height: 1;
  }

  .kpi-card .k-label {
    font-size: 13px;
    margin-top: 3px;
  }

  .kpi-card .k-delta {
    font-size: 12px;
    margin-top: 6px;
    padding: 4px 10px;
  }

  .kpi-card .k-sub {
    font-size: 12px;
    margin-top: 4px;
  }

  /* Score rings — tetap 3 kolom tapi lebih compact */
  .score-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .score-card {
    padding: 12px 8px;
  }

  .ring-wrap,
  .ring-wrap svg {
    width: 64px;
    height: 64px;
  }

  .ring-num {
    font-size: 16px;
  }

  .score-label {
    font-size: 11px;
  }

  /* Mid / Bottom cols → 1 kolom */
  .mid-cols,
  .bottom-cols {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Card */
  .card {
    padding: 16px;
  }

  .card-title {
    font-size: 14px;
  }

  /* Inc row */
  .inc-row {
    padding: 11px 12px;
  }

  .inc-desc {
    font-size: 13px;
  }

  /* Permit */
  .permit-row {
    padding: 11px 12px;
  }

  .permit-desc {
    font-size: 13px;
  }

  /* CAPA */
  .capa-row {
    padding: 11px 12px;
  }

  .capa-desc {
    font-size: 13px;
  }

  /* Area */
  .area-name {
    font-size: 13px;
  }

  .area-pct {
    font-size: 14px;
  }

  /* Chart */
  .chart-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-container {
    height: 200px;
  }

  .chart-container canvas {
    max-height: 200px;
  }

  /* AI bar */
  .ai-bar {
    padding: 16px;
  }

  .ai-input {
    font-size: 14px;
    padding: 12px 16px;
  }

  /* Bottom nav */
  .bottom-nav {
    display: flex;
  }

  .bottom-spacer {
    display: block;
    height: 72px;
  }

  /* Pagination */
  .pagination {
    justify-content: center;
  }

  /* Filter */
  .filter-search {
    min-width: 100%;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    padding: 16px;
  }

  /* Sec label */
  .sec-label {
    font-size: 11px;
  }

  /* Alert */
  .alert-banner {
    padding: 12px 14px;
  }

  .alert-title {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page > * {
    animation: none;
  }
}