/* MELAPORA V359 - contrast, overlay and finance page layout repair.
   This stylesheet is presentation-only. It does not change service calls,
   invoice issuance, subscription status, account access or payment records.
   html[data-melapora-theme] is the canonical preference.
   Print/PDF layouts are deliberately excluded. */
@media screen {
  /* Readable, consistent notification flyout independent of parent header rules. */
  html[data-melapora-theme] #melNotifyPanel {
    background:var(--theme-surface)!important;
    color:var(--theme-text)!important;
    border:1px solid var(--theme-border-strong)!important;
    box-shadow:0 18px 45px rgb(0 0 0 / 24%)!important;
    font-size:14px!important;
    line-height:1.5!important;
    isolation:isolate;
  }
  html[data-melapora-theme] #melNotifyPanel > header {
    background:#1c55ae!important;
    color:#fff!important;
    border-bottom:1px solid var(--theme-border)!important;
    min-height:44px!important;
    padding:10px 14px!important;
  }
  html[data-melapora-theme] #melNotifyPanel > header :is(strong,button) {
    color:#fff!important;
    font-size:14px!important;
  }
  html[data-melapora-theme] #melNotifyPanel .mel-notify-body {
    background:var(--theme-surface)!important;
    color:var(--theme-text)!important;
    font-size:14px!important;
    line-height:1.5!important;
  }
  html[data-melapora-theme] #melNotifyPanel :is(p,span,label,strong,legend) {
    color:var(--theme-text)!important;
  }
  html[data-melapora-theme] #melNotifyPanel :is(.mel-notify-muted,.mel-notify-event time,small) {
    color:var(--theme-muted)!important;
  }
  html[data-melapora-theme] #melNotifyPanel :is(.mel-notify-options,.mel-notify-event) {
    border-color:var(--theme-border)!important;
    color:var(--theme-text)!important;
  }
  html[data-melapora-theme] #melNotifyPanel .mel-notify-unread {
    background:var(--theme-selected)!important;
    color:var(--theme-text)!important;
    border-left:3px solid #4686ed!important;
  }
  html[data-melapora-theme] #melNotifyPanel .mel-notify-actions button {
    background:var(--theme-surface-2)!important;
    color:var(--theme-text)!important;
    border-color:var(--theme-border-strong)!important;
    font-size:13px!important;
    min-height:34px;
  }
  html[data-melapora-theme] #melNotifyPanel :is(input,select,textarea) {
    accent-color:#3577e7;
    color:var(--theme-text)!important;
    background:var(--theme-surface-2)!important;
    border-color:var(--theme-border)!important;
  }
  html[data-melapora-theme] #melNotifyPanel :is(button,input):focus-visible {
    outline:2px solid var(--theme-accent);outline-offset:2px;
  }
  /* Direct team chat: dark legacy status strip, composer, and menu overlay. */
  html[data-melapora-theme="dark"] #mt20DirectGroups :is(
    .mt20-chat-grid,.mt20-chat-sidebar,.mt20-chat-compose,.mt20-room-topbar,
    .mt20-room-history,.mt20-room-content,.mt20-room-settings,.mt20-app-rail,
    .mt20-whatsapp-heading,.mt20-msg-options,.mt20-chat-hint,.mt20-pending-choice
  ) {
    background-color:var(--theme-surface)!important;
    color:var(--theme-text)!important;
    border-color:var(--theme-border)!important;
  }
  html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-history {
    background-color:var(--theme-bg)!important;
    background-image:none!important;
  }
  html[data-melapora-theme="dark"] #mt20DirectGroups :is(#mt20RoomStatus,#mt20ViewOnly,.mt20-chat-hint) {
    background:var(--theme-surface)!important;
    color:var(--theme-muted)!important;
    border:0!important;
    margin:0!important;
    padding:7px 15px!important;
    min-height:24px;
  }
  html[data-melapora-theme="dark"] #mt20DirectGroups :is(.mt20-room-msg,.mt20-pending-choice,.mt20-msg-options) {
    background:var(--theme-surface-2)!important;
    color:var(--theme-text)!important;
    border:1px solid var(--theme-border)!important;
  }
  html[data-melapora-theme="dark"] #mt20DirectGroups .mt20-room-msg.mine {
    background:var(--theme-selected)!important;
    color:var(--theme-text)!important;
  }
  html[data-melapora-theme="dark"] #mt20DirectGroups :is(
    .mt20-room-meta,.mt20-room-meta b,.mt20-room-meta small,
    .mt20-room-msg small,.mt20-room-msg time,.mt20-msg-option
  ) {color:var(--theme-text)!important;}
  html[data-melapora-theme="dark"] #mt20DirectGroups :is(
    #mt20RoomMessage,#mt20RoomSearch,.mt20-chat-compose textarea,
    .mt20-chat-sidebar input,.mt20-msg-option:hover
  ) {background:var(--theme-surface-2)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important;}
  html[data-melapora-theme="dark"] #mt20DirectGroups #mt20RoomMessage::placeholder {color:var(--theme-hint)!important;}
  /* The Invoice Builder's labels and help boxes must remain legible on dark cards. */
  html[data-melapora-theme] #melaporaInvoices :is(.mi-v332-section,.mi-v332-metrics>div) {
    background:var(--theme-surface)!important;
    color:var(--theme-text)!important;
    border-color:var(--theme-border)!important;
  }
  html[data-melapora-theme] #melaporaInvoices :is(
    .mi-v332-section label,.mi-v332-head h3,.mi-v332-pay-label,.mi-v332-metrics b
  ) {color:var(--theme-text)!important;}
  html[data-melapora-theme] #melaporaInvoices :is(
    .mi-v332-section .mini,.mi-v332-head p,.mi-v332-help,.mi-v332-summary-pill
  ) {color:var(--theme-muted)!important;}
  html[data-melapora-theme="dark"] #melaporaInvoices :is(
    .mi-v332-help,.mi-v332-tax-hint
  ) {background:var(--theme-surface-2)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important;}
  html[data-melapora-theme="dark"] #melaporaInvoices .mi-v332-count {
    background:var(--theme-selected)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important;
  }
  html[data-melapora-theme] #melaporaInvoices :is(input:not([type="checkbox"]),textarea,select) {
    background:var(--theme-surface-2)!important;
    color:var(--theme-text)!important;
    border-color:var(--theme-border-strong)!important;
  }
  html[data-melapora-theme] #melaporaInvoices :is(.mi-v332-section label,.mi-grid label) {
    font-size:max(12px, .82rem);line-height:1.4;
  }
  /* Admin-only tab can use wider space than ordinary account settings. */
  @media(min-width:1000px) {
    #accountView > .wrap:has(#melAdminBillingPanel.active) {
      width:min(1460px,calc(100% - 48px))!important;
      max-width:1460px!important;
    }
  }
  html[data-melapora-theme] #melAdminBillingPanel {
    width:100%;min-width:0;max-width:none;box-sizing:border-box;
  }
  html[data-melapora-theme] #melAdminBillingPanel :is(.profileBox,#melAdmBilling,#melGstCenter,.mgc-panel) {
    max-width:100%;min-width:0;box-sizing:border-box;
    border-color:var(--theme-border)!important;
  }
  html[data-melapora-theme="dark"] #melAdminBillingPanel :is(.profileBox,#melAdmBilling,#melGstCenter,.mgc-panel,.gcp-tile) {
    background:var(--theme-surface)!important;
    color:var(--theme-text)!important;
  }
  html[data-melapora-theme="dark"] #melAdminBillingPanel #melGstCenter .mgc-status {
    background:#372b16!important;
    color:#ffe5b1!important;
    border-color:#a37a2c!important;
  }
  html[data-melapora-theme="dark"] #melAdminBillingPanel #melGstCenter .mgc-status :is(p,strong,span,a) {
    color:#ffe5b1!important;
  }
  html[data-melapora-theme="dark"] #melAdminBillingPanel #melGstCenter :is(
    .mgc-note,.mgc-step,.mgc-plain,.mgc-more summary
  ) {color:var(--theme-muted)!important;}
  html[data-melapora-theme="dark"] #melAdminBillingPanel :is(
    .mgc-panel,.mgc-more,#melGstr1Offline,details:not(.mel-export-menu)
  ) {background:var(--theme-surface-2)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important;}
  html[data-melapora-theme="dark"] #melAdminBillingPanel :is(
    .mgc-links a, a[href*="gst.gov.in"]
  ) {color:#a8caff!important;}
  html[data-melapora-theme] #melAdminBillingPanel :is(input:not([type="checkbox"]),select,textarea) {
    background:var(--theme-surface-2)!important;
    color:var(--theme-text)!important;
    border-color:var(--theme-border-strong)!important;
  }
  html[data-melapora-theme] #melAdminBillingPanel :is(.meladm-tablewrap,.gstscroll,.reconscroll) {
    width:100%;max-width:100%;min-width:0;overflow-x:auto;
  }
  html[data-melapora-theme] #melAdminBillingPanel :is(.meladm-note,.mgc-note,.gcp-muted) {line-height:1.55;}
  /* Document list shouldn't look like a blank light sheet on dark background. */
  html[data-melapora-theme="dark"] #md21Panel :is(.md21-item,.md21-surface,.md21-file,.md21-file-row) {
    background:var(--theme-surface-2)!important;
    color:var(--theme-text)!important;
    border-color:var(--theme-border)!important;
  }
  html[data-melapora-theme="dark"] #md21Panel :is(.md21-item,.md21-surface,.md21-file,.md21-file-row) :is(span,strong,b,small) {
    color:var(--theme-text)!important;
  }
  @media(max-width:700px){
    html[data-melapora-theme] #melNotifyPanel {right:10px!important;max-width:calc(100vw - 20px)!important;}
    #accountView > .wrap {width:calc(100% - 24px)!important;}
    html[data-melapora-theme] #melaporaInvoices .mi-v332-parties {grid-template-columns:1fr!important;}
  }
}
