/* UI v2 - "Accounts Master" section (Society Profile, Financial Year, Group Head, Account Head,
   Opening Balance, Narration, Bank, Poll). Loaded by v2/head_v2.cfm after theme.css; v1 never sees it.
   Hooks: .v2-am on <section class="content">, .v2-am-head on <section class="content-header">,
   .v2-am-<page> per page, .v2-am-modal on the Opening Balance modal wrappers. Tokens only. */

/* ---------- layout ---------- */
.content.v2-am{padding:8px 24px 32px!important}
.content-header.v2-am-head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px 24px;flex-wrap:wrap;padding:24px 24px 10px}
.v2-am-head-text{min-width:0;flex:1 1 320px}
.v2-am-head-text h5{margin:0}
.v2-am-desc{margin:4px 0 0;color:var(--v2-text-2);font-size:.86rem;line-height:1.5;max-width:70ch}
.v2-am-head-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;flex:none}
.v2-am-head-actions .btn{text-decoration:none;white-space:nowrap}
.v2-am-head-actions .btn i{opacity:.85}
@media (max-width:991px){
  .content.v2-am{padding-left:14px!important;padding-right:14px!important}
  .content-header.v2-am-head{padding-left:14px;padding-right:14px}
}

/* ---------- cards: thin accent instead of the gradient banner, header as a toolbar ---------- */
.v2-am .card.card-primary{border-top:3px solid var(--v2-primary)}
.v2-am .card-primary:not(.card-outline)>.card-header{background:var(--v2-surface-2);color:var(--v2-text);border-bottom:1px solid var(--v2-border);padding:12px 16px}
.v2-am .card-body{padding:16px}

/* ---------- toolbar (merge form, opening-balance actions) ---------- */
.v2-am-toolbar{display:flex;align-items:flex-end;gap:10px 14px;flex-wrap:wrap;margin:0;width:100%}
.v2-am-toolbar-label{display:inline-flex;align-items:center;gap:8px;font-size:.72rem;font-weight:800;text-transform:uppercase;letter-spacing:.1em;color:var(--v2-muted);align-self:center;padding-top:16px}
.v2-am-toolbar-label i{color:var(--v2-primary)}
.v2-am-field{display:flex;flex-direction:column;gap:4px;margin:0;min-width:0}
.v2-am-field>label{margin:0;font-size:.7rem;text-transform:uppercase;letter-spacing:.08em;color:var(--v2-muted)}
.v2-am-field>.form-control{min-width:220px;max-width:100%}
.v2-am-toolbar .form-control-sm{min-height:34px}
.v2-am-toolbar-group{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.v2-am-toolbar-group.is-end{margin-left:auto}
.v2-am-toolbar .btn,.v2-am-toolbar-group .btn{white-space:nowrap}
.v2-am-toolbar .form-inline .form-group{align-items:stretch}
.v2-am-warn,.v2-am-ok{display:inline-flex;align-items:center;gap:8px;padding:6px 12px;border-radius:999px;font-size:.78rem;font-weight:700;align-self:center;margin-left:auto}
.v2-am-warn{background:color-mix(in srgb,var(--v2-danger) 12%,transparent);color:var(--v2-danger)}
.v2-am-ok{background:color-mix(in srgb,var(--v2-success) 12%,transparent);color:var(--v2-success)}

/* ---------- list tables (DataTables) ---------- */
.v2-am .table-responsive{overflow-x:auto}
.v2-am #listTable{width:100%!important}
.v2-am #listTable tbody td{font-size:.86rem}
.v2-am #listTable td[style*="text-align:center"],.v2-am #listTable th[style*="text-align:center"]{white-space:nowrap}
.v2-am #listTable td>a{display:inline-block;text-decoration:none}
.v2-am #listTable .btn-sm{padding:.28rem .6rem;line-height:1.2}
.v2-am #listTable tbody .btn-primary,.v2-am #listTable tbody .btn-danger,.v2-am #listTable tbody .btn-success,.v2-am #listTable tbody .btn-info,.v2-am #listTable tbody .btn-warning{box-shadow:none}
.v2-am #listTable tfoot th{font-size:.72rem;text-transform:none;letter-spacing:0;color:var(--v2-text-2);vertical-align:middle;padding:10px 12px}
.v2-am #listTable tfoot select{min-height:32px;padding:0 24px 0 10px;border:1px solid var(--v2-border-strong);border-radius:var(--v2-radius-xs);background:var(--v2-surface);color:var(--v2-text);font-size:.8rem;max-width:200px}
.v2-am #listTable tfoot select:focus{outline:0;border-color:var(--v2-primary);box-shadow:var(--v2-ring)}
.v2-am #listTable tfoot .btn{white-space:nowrap}
.v2-am .dataTables_wrapper>.row:first-child{margin-bottom:8px}
.v2-am .dataTables_wrapper>.row:last-child{margin-top:4px;align-items:center}
.v2-am .table-danger>td,.v2-am tr.table-danger:hover>td{background:color-mix(in srgb,var(--v2-danger) 9%,transparent)!important;color:var(--v2-text)}

/* ---------- Society Profile: inline flex rows -> definition grid ---------- */
.v2-am-profile>.row>.col-md-10{flex:0 0 100%;max-width:100%}
.v2-am-profile .col-md-10>br{display:none}
.v2-am-profile .card-body{display:grid;grid-template-columns:repeat(auto-fit,minmax(340px,1fr));gap:0 32px;padding:6px 20px}
.v2-am-profile .card-body>div[style]{display:flex!important;align-items:baseline;gap:12px;margin:0!important;padding:10px 0;border-bottom:1px solid var(--v2-border);font-size:.86rem}
.v2-am-profile .card-body>div[style]>div{width:auto!important}
.v2-am-profile .card-body>div[style]>div:first-child{flex:0 0 44%;color:var(--v2-text-2);font-weight:600;font-size:.78rem;text-transform:uppercase;letter-spacing:.04em}
.v2-am-profile .card-body>div[style]>div:last-child{flex:1;min-width:0;word-break:break-word}
.v2-am-profile .card-body>div[style]>div:last-child strong{font-weight:600;color:var(--v2-text)}
.v2-am-profile .card-body>div[style]:last-child strong{font-family:var(--v2-mono);font-size:.82rem;color:var(--v2-primary)}
@media (max-width:767px){.v2-am-profile .card-body{grid-template-columns:1fr;padding:4px 16px}}

/* ---------- Financial Year ---------- */
.v2-am-fy .card{max-width:720px}
.v2-am-fy .card-body>div[style]{display:grid!important;grid-template-columns:minmax(160px,200px) minmax(220px,1fr);gap:12px;align-items:center;margin:0!important}
.v2-am-fy .card-body>div[style]>div{width:auto!important}
.v2-am-fy .card-body>div[style]>div:first-child strong{font-weight:600;color:var(--v2-text-2);font-size:.84rem}
.v2-am-fy .card-body>br{display:none}
.v2-am-fy .card-body>.row{margin:18px 0 0}
.v2-am-fy .card-body>.row>.col-md-7{flex:0 0 100%;max-width:100%;margin-left:0;padding:14px 18px;background:var(--v2-surface-2);border:1px solid var(--v2-border);border-radius:var(--v2-radius-sm)}
.v2-am-fy .card-body h1{font-size:.7rem!important;font-weight:800!important;text-transform:uppercase;letter-spacing:.12em;color:var(--v2-muted);margin:0 0 4px}
.v2-am-fy #acctperiod{font-family:var(--v2-mono);font-size:1.2rem;font-weight:600;margin:0;color:var(--v2-primary)}

/* ---------- Opening Balance ---------- */
.v2-am-ob .card-header .v2-am-field>.form-control{min-width:200px}
.v2-am-ob #listTable tbody tr.sm{cursor:pointer}
.v2-am-ob #listTable tbody tr.sm:hover>td{background:var(--v2-row-hover)}
.v2-am-ob #listTable td[align="right"]{font-family:var(--v2-mono);font-size:.82rem;white-space:nowrap}
.v2-am-ob #listTable tbody tr.text-success>td{color:var(--v2-success)!important}
.v2-am-ob #listTable tbody tr.text-primary>td{color:var(--v2-primary)!important}
.v2-am-ob #listTable tbody tr.text-info>td{color:var(--v2-info)!important}
.v2-am-ob #listTable tbody tr.text-danger>td{color:var(--v2-danger)!important}
.v2-am-ob #listTable tbody tr>td:nth-child(3){font-family:var(--v2-mono);font-size:.72rem;font-weight:700;letter-spacing:.06em}
.v2-am-ob #listTable tfoot td{background:var(--v2-surface-2);font-weight:700;border-top:2px solid var(--v2-border-strong)!important}
.v2-am-modal .modal-content>form>div[style]{padding:18px 20px 20px!important}
.v2-am-modal .modal-content>form>div[style]>.row[style]{padding:0!important;margin:0 -8px 8px}
.v2-am-modal .modal-content>form>div[style]>.row[style]>.form-group{padding:0 8px;margin-bottom:14px}
.v2-am-modal .modal-content>form>div[style]>.btn{margin-right:6px}
.v2-am-modal .modal-content>form>div[style]>.btn-info{background:var(--v2-surface);border-color:var(--v2-border-strong);color:var(--v2-text-2);box-shadow:none}
.v2-am-modal .modal-content>form>div[style]>.btn-info:hover{background:var(--v2-surface-2);color:var(--v2-text)}
.v2-am-modal .modal-header{padding:14px 20px}
.v2-am-modal .modal-title{font-weight:700;font-size:1rem}

/* ---------- responsive (section-specific; global phone/tablet rules live in theme.css) ---------- */
/* DataTables pagination: the inner .pagination is nowrap by default and was clipping "Previous"/"1" on phones */
.v2-am .dataTables_paginate .pagination{flex-wrap:wrap;justify-content:center;gap:4px;margin:0}
.v2-am .dataTables_paginate .paginate_button{min-height:40px;min-width:40px;display:inline-flex;align-items:center;justify-content:center}
/* ultra-wide: keep the master lists readable instead of stretching to the theme's 1700px cap */
@media (min-width:1800px){.content.v2-am,.content-header.v2-am-head{max-width:1500px;margin-left:auto;margin-right:auto}}
/* tablets: wrap the merge/opening-balance toolbars without dead space, cap the selects to a sensible width */
@media (min-width:768px) and (max-width:1199px){
  .v2-am-toolbar{gap:10px 12px}
  .v2-am-field{flex:1 1 260px}
  .v2-am-field>.form-control{min-width:0;width:100%}
  .v2-am-toolbar-label{flex:0 0 100%;padding-top:0}
  .v2-am-profile .card-body{grid-template-columns:repeat(2,minmax(0,1fr));gap:0 24px}
}
/* phones and small tablets (< 768px): stack toolbars, full-width controls, sticky code column */
@media (max-width:767px){
  .content-header.v2-am-head{padding-top:14px;gap:10px}
  .v2-am-head-text{flex:1 1 100%}
  .v2-am-head-actions{width:100%}
  .v2-am-head-actions .btn{flex:1 1 auto;justify-content:center;min-height:40px}
  .v2-am-toolbar{flex-direction:column;align-items:stretch;gap:10px}
  .v2-am-toolbar-label{padding-top:0;align-self:flex-start}
  .v2-am-field{width:100%}
  .v2-am-field>.form-control,.v2-am-ob .card-header .v2-am-field>.form-control{min-width:0;width:100%;min-height:40px}
  .v2-am-toolbar-group{width:100%;gap:8px}
  .v2-am-toolbar-group.is-end{margin-left:0}
  .v2-am-toolbar .btn,.v2-am-toolbar-group .btn{min-height:40px;white-space:normal}
  .v2-am-warn,.v2-am-ok{align-self:flex-start;margin-left:0}
  .v2-am-fy .card-body>div[style]{grid-template-columns:1fr;gap:6px}
  .v2-am-fy .card-body>div[style]>div:last-child .form-control{width:100%;min-height:40px}
  .v2-am #listTable thead th:first-child,.v2-am #listTable tbody td:first-child{position:sticky;left:0;z-index:1;background:var(--v2-surface);box-shadow:1px 0 0 var(--v2-border)}
  .v2-am #listTable thead th:first-child{z-index:2;background:var(--v2-surface-2)}
  .v2-am #listTable tbody tr.odd>td:first-child,.v2-am .table-striped tbody tr:nth-of-type(odd)>td:first-child{background:var(--v2-surface-2)}
  .v2-am #listTable tbody tr:hover>td:first-child{background:var(--v2-row-hover)}
  .v2-am #listTable tfoot th:first-child,.v2-am #listTable tfoot td:first-child{position:static}
  .v2-am #listTable tbody td{font-size:.84rem}
  .v2-am #listTable .btn-sm{min-height:36px;min-width:40px}
  .v2-am #listTable tfoot select{max-width:160px}
}
@media (max-width:575px){
  .v2-am-head-actions .btn{flex:1 1 100%}
  .v2-am-toolbar-group .btn{flex:1 1 100%}
  .v2-am-profile .card-body>div[style]{flex-direction:column;align-items:flex-start;gap:2px}
  .v2-am-profile .card-body>div[style]>div:first-child{flex:none;font-size:.7rem}
  .v2-am-profile .card-body>div[style]>div:last-child{width:100%}
}
