.account-filter-panel,
.account-register-panel {
  margin-top: 14px;
  overflow: visible;
}

.account-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) 150px 150px;
  gap: 18px;
  padding: 24px 20px;
}

.account-filter-grid label,
.account-table-meta label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.account-filter-grid select,
.account-table-meta select,
.account-table-meta input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.account-filter-grid select:focus,
.account-table-meta select:focus,
.account-table-meta input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(13,116,69,.1);
}

.account-quick-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.account-quick-toolbar .account-quick:nth-child(2) { margin-right: auto; }
.account-quick.active { border-color: var(--red); background: #fff3f1; color: var(--red); }
.account-quick span { margin-left: 6px; font-weight: 900; }

.estimate-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
}

.estimate-switch input { position: absolute; opacity: 0; pointer-events: none; }
.estimate-switch span { position: relative; width: 32px; height: 18px; border-radius: 18px; background: #cfd8d3; transition: .2s; }
.estimate-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: .2s; }
.estimate-switch input:checked + span { background: var(--green); }
.estimate-switch input:checked + span::after { transform: translateX(14px); }

.account-estimate {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 20px;
  padding: 15px 20px;
  border-bottom: 1px solid #b9ddca;
  background: var(--green-soft);
}
.account-estimate[hidden] { display: none; }
.account-estimate span,.account-estimate small { color: var(--muted); font-size: 9px; }
.account-estimate strong { grid-row: 1 / 3; grid-column: 2; align-self: center; color: var(--green); font-size: 20px; }

.account-table-meta {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 20px;
  background: #fafbf9;
}
.account-table-meta label:first-child { grid-template-columns: auto 75px auto; align-items: center; }
.account-table-meta .account-search-label { width: min(430px, 100%); }

.account-export-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.account-export-toolbar span { margin-left: auto; color: var(--muted); font-size: 9px; }

.account-register-table { min-width: 1700px; }
.account-register-table th:first-child,.account-register-table td:first-child { width: 48px; text-align: center; }
.account-register-table th:nth-child(2),.account-register-table td:nth-child(2) { width: 38px; text-align: center; }
.account-register-table td { vertical-align: top; }
.account-register-table td:nth-child(9),.account-register-table td:nth-child(12) { min-width: 200px; max-width: 290px; white-space: normal; line-height: 1.45; }
.account-register-table input[type="checkbox"] { width: 14px; height: 14px; }
.account-register-table .row-actions { min-width: 168px; flex-wrap: wrap; }
.account-register-table .account-primary { color: var(--green); font-weight: 900; }
.account-register-table .account-subline { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.account-register-table .sync-badge { display: inline-flex; margin-top: 5px; padding: 3px 6px; border-radius: 10px; background: #edf2ef; color: var(--muted); font-size: 7px; font-weight: 900; text-transform: uppercase; }
.account-register-table .sync-badge.synced { background: var(--green-soft); color: var(--green); }
.account-register-table .sync-badge.failed { background: #ffefed; color: var(--red); }
.account-register-table .status.waiting { background: #fff4d9; color: #8b6a24; }
.account-dialog { width: min(820px, 100%); }

@media (max-width: 1200px) {
  .account-filter-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 820px) {
  .account-filter-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .account-table-meta { align-items: stretch; flex-direction: column; }
  .account-table-meta .account-search-label { width: 100%; }
}

@media (max-width: 620px) {
  .account-filter-grid { grid-template-columns: 1fr; }
  .account-quick-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .account-quick-toolbar .account-quick:nth-child(2) { margin-right: 0; }
  .estimate-switch { width: 100%; justify-content: flex-end; }
  .account-export-toolbar { overflow-x: auto; }
  .account-export-toolbar span { display: none; }
}

/* ACCOUNT REGISTER FIT FIX v1 */

/*
 * Fit the 13-column account register into a normal desktop workspace.
 * Smaller screens continue to use the existing table-wrap scrollbar.
 */
#account-register-table {
  width: 100%;
  min-width: 1360px;
  table-layout: fixed;
}

#account-register-table th,
#account-register-table td {
  min-width: 0;
  max-width: none;
  padding: 10px 7px;
  vertical-align: top;
}

#account-register-table th {
  font-size: 8px;
  line-height: 1.25;
}

#account-register-table td {
  font-size: 10px;
}

/* No */
#account-register-table th:nth-child(1),
#account-register-table td:nth-child(1) {
  width: 34px;
  text-align: center;
}

/* Select */
#account-register-table th:nth-child(2),
#account-register-table td:nth-child(2) {
  width: 32px;
  text-align: center;
}

/* Account number */
#account-register-table th:nth-child(3),
#account-register-table td:nth-child(3) {
  width: 92px;
}

/* Name */
#account-register-table th:nth-child(4),
#account-register-table td:nth-child(4) {
  width: 108px;
}

/* Phone */
#account-register-table th:nth-child(5),
#account-register-table td:nth-child(5) {
  width: 86px;
}

/* Due date and payment type */
#account-register-table th:nth-child(6),
#account-register-table td:nth-child(6) {
  width: 118px;
}

/* Tax */
#account-register-table th:nth-child(7),
#account-register-table td:nth-child(7) {
  width: 76px;
}

/* Register date */
#account-register-table th:nth-child(8),
#account-register-table td:nth-child(8) {
  width: 92px;
}

/* Remark */
#account-register-table th:nth-child(9),
#account-register-table td:nth-child(9) {
  width: 80px;
  min-width: 0;
  max-width: none;
}

/* Bill per month */
#account-register-table th:nth-child(10),
#account-register-table td:nth-child(10) {
  width: 108px;
}

/* Status */
#account-register-table th:nth-child(11),
#account-register-table td:nth-child(11) {
  width: 112px;
}

/* Address */
#account-register-table th:nth-child(12),
#account-register-table td:nth-child(12) {
  width: 228px;
  min-width: 0;
  max-width: none;
}

/* Action */
#account-register-table th:nth-child(13),
#account-register-table td:nth-child(13) {
  width: 194px;
}

/* Wrap only descriptive columns. */
#account-register-table td:nth-child(4),
#account-register-table td:nth-child(6),
#account-register-table td:nth-child(9),
#account-register-table td:nth-child(10),
#account-register-table td:nth-child(11),
#account-register-table td:nth-child(12) {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

#account-register-table td:nth-child(11) > span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}

/* Keep all four account actions together on one line. */
#account-register-table .row-actions {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
  align-items: center;
  gap: 3px;
}

#account-register-table .account-row-action {
  flex: 0 0 auto;
  min-width: 0;
  padding: 5px 5px;
  font-size: 8px;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 1400px) {
  #account-register-table {
    /*
     * The surrounding .table-wrap supplies horizontal scrolling,
     * preventing the entire administration page from overflowing.
     */
    min-width: 1360px;
  }
}

/* =========================================================
   RMCJJ_ACCOUNT_NO_RESPONSIVE_V1

   Account No register only.
   The old table has min-width:1700px.
   On wide desktop we fit the complete 13-column register
   inside the panel instead.

   Tablet/mobile keeps controlled horizontal scrolling.
   ========================================================= */


/* ---------------------------------------------------------
   COMMON
   --------------------------------------------------------- */

#account-register-table {
    box-sizing:
        border-box !important;
}


#account-register-table th,
#account-register-table td {
    box-sizing:
        border-box !important;

    min-width:
        0 !important;

    vertical-align:
        middle !important;
}


/*
 * Global app TD styling is nowrap.
 * These information-heavy Account No columns may wrap.
 */

#account-register-table td:nth-child(4),
#account-register-table td:nth-child(6),
#account-register-table td:nth-child(9),
#account-register-table td:nth-child(10),
#account-register-table td:nth-child(12),
#account-register-table td:nth-child(13) {
    white-space:
        normal !important;
}


/* =========================================================
   WIDE DESKTOP
   ========================================================= */

@media (min-width: 1201px) {

    /*
     * KEY FIX:
     * override accounts.css min-width:1700px.
     */

    #account-register-table {
        width:
            100% !important;

        min-width:
            0 !important;

        max-width:
            100% !important;

        table-layout:
            fixed !important;
    }


    /*
     * 13 columns = 100%
     *
     *  1 No                   2.5
     *  2 Select               2.5
     *  3 Account No           7
     *  4 Name                 8
     *  5 Phone                6
     *  6 Due / Payment        9
     *  7 Tax                  5.5
     *  8 Register Date        6.5
     *  9 Remark               6
     * 10 Bill / Month         8
     * 11 Status               8
     * 12 Address             14
     * 13 Action              16.5
     */

    #account-register-table th:nth-child(1) {
        width:
            2.5% !important;
    }

    #account-register-table th:nth-child(2) {
        width:
            2.5% !important;
    }

    #account-register-table th:nth-child(3) {
        width:
            7% !important;
    }

    #account-register-table th:nth-child(4) {
        width:
            8% !important;
    }

    #account-register-table th:nth-child(5) {
        width:
            6% !important;
    }

    #account-register-table th:nth-child(6) {
        width:
            9% !important;
    }

    #account-register-table th:nth-child(7) {
        width:
            5.5% !important;
    }

    #account-register-table th:nth-child(8) {
        width:
            6.5% !important;
    }

    #account-register-table th:nth-child(9) {
        width:
            6% !important;
    }

    #account-register-table th:nth-child(10) {
        width:
            8% !important;
    }

    #account-register-table th:nth-child(11) {
        width:
            8% !important;
    }

    #account-register-table th:nth-child(12) {
        width:
            14% !important;
    }

    #account-register-table th:nth-child(13) {
        width:
            16.5% !important;
    }


    /*
     * Tiny control columns.
     */

    #account-register-table th:nth-child(1),
    #account-register-table td:nth-child(1),

    #account-register-table th:nth-child(2),
    #account-register-table td:nth-child(2) {
        text-align:
            center !important;

        padding-left:
            4px !important;

        padding-right:
            4px !important;
    }


    /*
     * Account, phone, tax and registration stay compact.
     */

    #account-register-table td:nth-child(3),
    #account-register-table td:nth-child(5),
    #account-register-table td:nth-child(7),
    #account-register-table td:nth-child(8) {
        white-space:
            nowrap !important;

        overflow:
            hidden !important;

        text-overflow:
            ellipsis !important;
    }


    /*
     * Name can wrap naturally.
     */

    #account-register-table td:nth-child(4) {
        overflow-wrap:
            anywhere !important;

        line-height:
            1.3 !important;
    }


    /*
     * Due Date / Payment Type + plan may wrap.
     */

    #account-register-table td:nth-child(6) {
        line-height:
            1.3 !important;

        overflow-wrap:
            anywhere !important;
    }


    /*
     * Remark.
     */

    #account-register-table td:nth-child(9) {
        min-width:
            0 !important;

        max-width:
            none !important;

        line-height:
            1.3 !important;

        overflow-wrap:
            anywhere !important;
    }


    /*
     * Monthly bill stays readable with subline below.
     */

    #account-register-table td:nth-child(10) {
        line-height:
            1.3 !important;

        overflow-wrap:
            anywhere !important;
    }


    /*
     * Status badges can wrap onto a second line.
     */

    #account-register-table td:nth-child(11) {
        white-space:
            normal !important;
    }


    #account-register-table td:nth-child(11)
    .status,

    #account-register-table td:nth-child(11)
    .sync-badge {
        margin:
            1px 2px 1px 0 !important;
    }


    /*
     * Address is the main wrapping column.
     */

    #account-register-table td:nth-child(12) {
        min-width:
            0 !important;

        max-width:
            none !important;

        white-space:
            normal !important;

        overflow-wrap:
            anywhere !important;

        line-height:
            1.3 !important;
    }


    /*
     * ACTION
     * Keep all:
     * View / Edit / Suspend or Activate /
     * Non-Active / Archive
     */

    #account-register-table td:nth-child(13) {
        min-width:
            0 !important;

        max-width:
            none !important;

        padding-left:
            6px !important;

        padding-right:
            6px !important;

        overflow:
            visible !important;
    }


    #account-register-table td:nth-child(13)
    .row-actions {
        display:
            flex !important;

        flex-wrap:
            wrap !important;

        align-items:
            center !important;

        justify-content:
            flex-start !important;

        gap:
            4px !important;

        width:
            100% !important;

        min-width:
            0 !important;
    }


    #account-register-table td:nth-child(13)
    .small-action {
        flex:
            0 0 auto !important;

        min-height:
            25px !important;

        padding:
            4px 6px !important;

        font-size:
            7.5px !important;

        line-height:
            1.05 !important;

        white-space:
            nowrap !important;
    }


    /*
     * Secondary lines should wrap instead of pushing
     * the table wider.
     */

    #account-register-table
    .account-subline {
        max-width:
            100% !important;

        white-space:
            normal !important;

        overflow-wrap:
            anywhere !important;
    }

}


/* =========================================================
   NORMAL LAPTOP / TABLET
   ========================================================= */

@media (min-width: 901px) and (max-width: 1200px) {

    /*
     * 13 columns become too small below this width.
     * Keep them readable and use the existing table-wrap.
     */

    #account-register-table {
        width:
            100% !important;

        min-width:
            1250px !important;

        table-layout:
            auto !important;
    }


    #account-register-table th:nth-child(9),
    #account-register-table td:nth-child(9) {
        min-width:
            120px !important;

        max-width:
            170px !important;
    }


    #account-register-table th:nth-child(12),
    #account-register-table td:nth-child(12) {
        min-width:
            210px !important;

        max-width:
            260px !important;

        white-space:
            normal !important;
    }


    #account-register-table th:nth-child(13),
    #account-register-table td:nth-child(13) {
        min-width:
            225px !important;
    }


    #account-register-table td:nth-child(13)
    .row-actions {
        flex-wrap:
            wrap !important;
    }

}


/* =========================================================
   SMALL TABLET / PHONE
   ========================================================= */

@media (max-width: 900px) {

    /*
     * Do not crush a 13-column register into a phone.
     */

    #account-register-table {
        width:
            100% !important;

        min-width:
            1180px !important;

        table-layout:
            auto !important;
    }


    #account-register-table th:nth-child(12),
    #account-register-table td:nth-child(12) {
        min-width:
            200px !important;

        white-space:
            normal !important;
    }


    #account-register-table th:nth-child(13),
    #account-register-table td:nth-child(13) {
        min-width:
            220px !important;
    }

}


/* =========================================================
   ACCOUNT FILTER / TOOLBAR RESPONSIVENESS
   ========================================================= */

@media (max-width: 1100px) {

    .account-filter-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr)) !important;
    }

}


@media (max-width: 620px) {

    .account-filter-grid {
        grid-template-columns:
            1fr !important;
    }


    .account-table-meta {
        align-items:
            stretch !important;

        flex-direction:
            column !important;
    }


    .account-table-meta
    .account-search-label {
        width:
            100% !important;
    }

}

