/* Smart NCD pastel-blue borders + compact footer v2.28.0 */
:root{
  --line:#d6e9f8;
  --line-strong:#b8d9f3;
  --surface-soft:#f5faff;
  --blue-soft:#edf6ff;
}

body:not(.dark) input,
body:not(.dark) select,
body:not(.dark) textarea{
  border-color:#d6e9f8!important;
}
body:not(.dark) input:focus,
body:not(.dark) select:focus,
body:not(.dark) textarea:focus{
  border-color:#9cc9ee!important;
  box-shadow:0 0 0 3px rgba(123,183,230,.14)!important;
}

body:not(.dark) :is(
  .topbar,
  .app-footer,
  .dashboard-tabs,
  .patient-vital-tabs,
  .settings-tablist,
  .registry-filter-bar-v2,
  .registry-table-card-v2,
  .table-card,
  .filter-card,
  .panel,
  .summary-card,
  .profile-card,
  .medication-cost-card,
  .patient-med-kpi,
  .patient-med-change-card,
  .profile-table-wrap,
  .med-change-year-wrap
){
  border-color:#d6e9f8!important;
}

body:not(.dark) :is(
  .patient-tab-panel,
  .profile-overview-card,
  .profile-info-card,
  .patient-info-card,
  .detail-card,
  .metric-card:not(.danger):not(.warning):not(.risk):not(.abnormal)
){
  border-color:#dcecf9!important;
}

body:not(.dark) table th{
  border-color:#dbeaf7;
}
body:not(.dark) table td{
  border-color:#e5f0f9;
}

/* Keep clinical/semantic borders untouched. */
body:not(.dark) :is(
  .status-normal,.status-risk,.status-suspected,.status-newcase,
  .clinical-normal,.clinical-risk,.clinical-suspected,.clinical-new,
  .danger,.warning,.risk,.abnormal
){
  --line:initial;
}

.app-footer{
  display:flex!important;
  align-items:center!important;
  justify-content:space-between!important;
  flex-direction:row!important;
  flex-wrap:nowrap!important;
  gap:18px!important;
  min-height:54px!important;
  padding:7px 24px!important;
  background:rgba(255,255,255,.98)!important;
  border-top:1px solid #d6e9f8!important;
}

.footer-developer,
.footer-system{
  display:flex;
  align-items:center;
  gap:7px;
  min-width:0;
  white-space:nowrap;
}
.footer-developer{
  justify-content:flex-start;
  overflow:hidden;
}
.footer-system{
  justify-content:flex-end;
  margin-left:auto;
  flex:0 0 auto;
}
.footer-developer span,
.footer-developer a,
.footer-system>span{
  font-size:10px;
}
.footer-developer strong{
  font-size:10px;
  flex:0 0 auto;
}
.footer-developer a{
  flex:0 0 auto;
}
.footer-divider{color:#9eb6cc}
#appVersion{color:#1565d8!important;font-weight:800}
#footerBuildDate{font-weight:700;color:#647b94}

.footer-sync-status.connection-status{
  min-height:34px!important;
  height:34px;
  padding:3px 8px!important;
  gap:6px!important;
  border:1px solid #d6e9f8!important;
  border-radius:9px!important;
  background:#f5faff!important;
  box-shadow:none!important;
}
.footer-sync-status.connection-status strong{
  font-size:10px!important;
  line-height:1.1;
}
.footer-sync-status.connection-status small{
  font-size:9px!important;
  line-height:1.1;
  color:#647b94!important;
}
.footer-sync-status .dot{
  width:9px;
  height:9px;
}

body.dark .app-footer{
  background:#08203a!important;
  border-top-color:#1f4668!important;
}
body.dark .footer-sync-status.connection-status{
  background:#0f2c49!important;
  border-color:#2c5c83!important;
}
body.dark #footerBuildDate{color:#9bb2ca}

@media(max-width:1180px){
  .app-footer{
    flex-wrap:wrap!important;
    align-content:center;
    gap:4px 12px!important;
    min-height:66px!important;
  }
  .footer-developer,.footer-system{white-space:normal}
}
@media(max-width:768px){
  .app-footer{
    align-items:flex-start!important;
    flex-direction:column!important;
    flex-wrap:nowrap!important;
    min-height:auto!important;
    padding:8px 12px!important;
  }
  .footer-system{
    width:100%;
    margin-left:0;
    justify-content:flex-start;
    flex-wrap:wrap;
  }
  .footer-developer{width:100%;flex-wrap:wrap}
}

/* Medication analysis year/month grid v2.29.0 */
.med-analysis-v2{padding:14px!important}
.med-analysis-head{align-items:flex-start;gap:12px;margin-bottom:12px}
.med-analysis-toggle{
  display:flex;align-items:center;gap:4px;
  padding:4px;border:1px solid #d6e9f8;border-radius:11px;background:#f5faff
}
.med-analysis-toggle button{
  min-height:34px;padding:6px 12px;border:0;border-radius:8px;
  background:transparent;color:var(--muted);font-size:11px;font-weight:800;cursor:pointer
}
.med-analysis-toggle button.active{
  background:#1565d8;color:#fff;box-shadow:0 5px 12px rgba(21,101,216,.16)
}

.med-fy-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(175px,1fr));
  gap:10px;
  margin-bottom:14px
}
.med-fy-card{
  min-width:0;min-height:112px;padding:12px;
  text-align:left;border:1px solid #d6e9f8;border-radius:12px;
  background:#fff;color:var(--text);cursor:pointer;
  transition:border-color .15s ease,box-shadow .15s ease,transform .15s ease
}
.med-fy-card:hover{border-color:#9cc9ee;box-shadow:0 7px 18px rgba(21,101,216,.09);transform:translateY(-1px)}
.med-fy-card.selected{border:2px solid #55a9ec;background:#f8fcff;box-shadow:0 7px 18px rgba(21,101,216,.10)}
.med-fy-card-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:9px}
.med-fy-card-head strong{font-size:14px;color:#0f2747}
.med-fy-card-head span{font-size:21px;color:#1565d8;line-height:1}
.med-fy-card-badges{display:flex;flex-wrap:wrap;gap:5px;min-height:27px}
.med-fy-card>small{display:block;margin-top:10px;color:#1565d8;font-size:10px;font-weight:800}

.med-summary-pill{
  display:inline-flex;align-items:center;min-height:23px;padding:3px 7px;
  border-radius:999px;font-size:10px;font-weight:800;white-space:nowrap
}
.med-summary-pill.increase{background:#dcfce7;color:#15803d}
.med-summary-pill.decrease{background:#fee2e2;color:#b91c1c}
.med-summary-pill.changed{background:#fef3c7;color:#b45309}
.med-summary-pill.switch{background:#ede9fe;color:#6d28d9}

.med-analysis-detail-grid{
  display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:12px;align-items:start
}
.med-analysis-detail,.med-month-panel{
  min-width:0;border:1px solid #d6e9f8;border-radius:12px;background:#fff;padding:12px
}
.med-detail-head{margin-bottom:8px}
.med-detail-head h3,.med-month-panel h3{font-size:14px}
.med-detail-head span,.med-month-panel .patient-section-head span{font-size:10px;color:var(--muted)}

.med-month-list{display:grid;gap:8px}
.med-month-card{
  width:100%;display:grid;grid-template-columns:88px minmax(0,1fr) 18px;
  align-items:center;gap:7px;padding:9px 10px;
  border:1px solid #d6e9f8;border-radius:10px;background:#f8fcff;
  color:var(--text);text-align:left;cursor:pointer
}
.med-month-card:hover{border-color:#9cc9ee;background:#f2f9ff}
.med-month-card.selected{border-color:#55a9ec;background:#eaf5ff;box-shadow:0 4px 12px rgba(21,101,216,.08)}
.med-month-card>strong{font-size:11px;color:#0f2747}
.med-month-card>i{font-style:normal;font-size:18px;color:#1565d8;text-align:right}
.med-month-badges{display:flex;gap:4px;flex-wrap:wrap;min-width:0}
.med-month-badges .med-summary-pill{font-size:9px;min-height:21px;padding:2px 6px}

.med-change-table-v2{min-width:1120px}
.med-change-table-v2 th,.med-change-table-v2 td{vertical-align:top}
.med-change-table-v2 .med-dose-cell{min-width:190px;max-width:280px;white-space:normal}

body.dark .med-analysis-toggle{background:#0f2c49;border-color:#2c5c83}
body.dark .med-fy-card,
body.dark .med-analysis-detail,
body.dark .med-month-panel{background:#0b2239;border-color:#1f4668;color:#eaf4ff}
body.dark .med-fy-card.selected{background:#0f2c49;border-color:#3b82f6}
body.dark .med-fy-card-head strong,
body.dark .med-month-card>strong{color:#eaf4ff}
body.dark .med-month-card{background:#0f2c49;border-color:#2c5c83}
body.dark .med-month-card.selected{background:#123b66;border-color:#3b82f6}

@media(max-width:1200px){
  .med-analysis-detail-grid{grid-template-columns:1fr}
  .med-month-panel{order:-1}
  .med-month-list{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:760px){
  .med-analysis-head{flex-direction:column}
  .med-analysis-toggle{width:100%}
  .med-analysis-toggle button{flex:1}
  .med-fy-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .med-month-list{grid-template-columns:1fr}
}
@media(max-width:520px){
  .med-fy-grid{grid-template-columns:1fr}
}
