/* CourierPilot Extended Modules UI (AWB, Billing, Invoices, Master, Users, Public) */
/* Built strictly on top of CourierPilot Design Tokens from courierpilot.css */

.overdue-banner {
  background: linear-gradient(90deg, #d6321c, #ff4a06);
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  padding: .45rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.overdue-banner a, .overdue-banner button {
  background: #fff;
  color: #d6321c;
  padding: .22rem .7rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .74rem;
  white-space: nowrap;
}

.sidebar-nav-scroll {
  display: grid;
  gap: .15rem;
  margin-block: 1.4rem 1.25rem;
}
.navigation :is(a, button) i.fi {
  font-size: 1.08rem;
  width: 1.375rem;
  text-align: center;
  color: #a09f9e;
  line-height: 1;
}
.navigation :is(a, button)[aria-current="page"] i.fi {
  color: var(--ink);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: .65rem;
}
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  background: #f3f1f1;
  color: var(--ink);
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
}
.role-chip.is-vendor { background: #e6f1fd; color: #006fe8; }
.role-chip.is-super { background: #ffece8; color: #d6321c; }
.role-chip.is-driver { background: #e7f9eb; color: #159b36; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 2.35rem;
  padding: .45rem .95rem;
  border-radius: .68rem;
  font-size: .8rem;
  font-weight: 700;
  border: 1px solid transparent;
  transition: filter .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.95); }
.btn-orange { background: var(--orange-gradient); color: #fff; }
.btn-dark { background: var(--black); color: #fff; }
.btn-outline { background: #fff; border-color: #dad6d4; color: var(--ink); }
.btn-outline:hover { background: #f5f3f2; filter: none; }
.btn-green { background: #159b36; color: #fff; }
.btn-blue { background: #006fe8; color: #fff; }
.btn-amber { background: #ee7600; color: #fff; }
.btn-danger { background: #d6321c; color: #fff; }
.btn-sm { min-height: 1.9rem; padding: .28rem .62rem; font-size: .74rem; border-radius: .5rem; }
.btn-xs { min-height: 1.65rem; padding: .2rem .45rem; font-size: .71rem; border-radius: .42rem; }

.main {
  min-width: 0;
  overflow-x: clip;
}

.page-wrap > *,
form,
.awb-grid-3 > *,
.awb-grid-2 > *,
.awb-span-2,
.awb-span-2 > *,
.billing-layout > *,
.purchase-layout > *,
.cp-card,
.cp-form-rows,
.cp-row > *,
.cp-split-2 > *,
.cp-split-3 > *,
.cp-table-wrap {
  min-width: 0;
  max-width: 100%;
}

.order-table td:nth-child(2) {
  padding-right: 1.15rem;
}

.page-wrap {
  padding: 1.45rem 2rem 2.25rem;
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 1.25rem;
}

.page-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}
.page-bar-title {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
}
.page-bar-title h2 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-bar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

/* Sub-tabs (AWB Details / Sales Billing / Purchase Billing / Attachments / Delivery / KYC / etc.) */
.cp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .35rem;
  background: #f5f4f4;
  border-radius: .85rem;
  border: 1px solid var(--line);
  overflow-x: auto;
}
.cp-tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .9rem;
  border-radius: .65rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.cp-tab:hover { background: #eae7e6; color: var(--ink); }
.cp-tab.is-active {
  background: var(--black);
  color: #fff;
}
.cp-tab.is-active-green {
  background: #159b36;
  color: #fff;
}

/* Cards & Form Panels */
.cp-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.15rem 1.25rem;
  min-width: 0;
}
.cp-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding-bottom: .75rem;
  margin-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}
.cp-card-head h3 {
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: -.015em;
  display: flex;
  align-items: center;
  gap: .45rem;
}

.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border-radius: .5rem;
  font-size: .74rem;
  font-weight: 700;
  background: #006fe8;
  color: #fff;
}
.balance-pill.is-negative { background: #d6321c; }

/* 3-Column AWB Grid & Billing Grids */
.awb-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.awb-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.awb-span-2 {
  grid-column: span 2;
}
.billing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.purchase-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.25fr);
  gap: 1rem;
  align-items: start;
}

/* Form Field Rows (Reference-faithful compact alignment) */
.cp-form-rows {
  display: grid;
  gap: .52rem;
}
.cp-row {
  display: grid;
  grid-template-columns: 9.75rem minmax(0, 1fr);
  gap: .5rem;
  align-items: center;
}
.cp-row label, .cp-label {
  font-size: .73rem;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: .01em;
}
.cp-row label.req, .cp-label.req {
  color: #d6321c;
}
.cp-inline {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
}
.cp-inline > * { min-width: 0; }
.cp-split-2 {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: .35rem;
}
.cp-split-3 {
  display: grid;
  grid-template-columns: .75fr 1.25fr .95fr;
  gap: .35rem;
  align-items: center;
}

.cp-input, .cp-select, .cp-textarea {
  width: 100%;
  min-width: 0;
  min-height: 2.25rem;
  padding: .38rem .6rem;
  line-height: 1.35;
  border: 1px solid #dad6d4;
  border-radius: .5rem;
  background: #fff;
  color: var(--ink);
  font-size: .78rem;
}
.cp-input[readonly], .cp-input:disabled, .cp-select:disabled {
  background: #f3f1f1;
  color: #514e4d;
}
.cp-textarea {
  min-height: 3.35rem;
  resize: vertical;
}
.cp-check {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  font-size: .72rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
}
.cp-form-rows .cp-check {
  white-space: normal;
  align-items: flex-start;
  line-height: 1.35;
}
.cp-check input { accent-color: var(--orange); width: .95rem; height: .95rem; flex-shrink: 0; margin-top: .1rem; }
.cp-input[type="file"] { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Filter Grid (67-field AWB List / Invoice List) */
.filter-grid-6 {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .6rem .75rem;
}
.filter-field {
  display: grid;
  gap: .24rem;
  min-width: 0;
}
.filter-field label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  margin-top: .85rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}

/* Dense Operational Tables */
.cp-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: #fff;
}
.cp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: .76rem;
  white-space: nowrap;
}
.cp-table th {
  background: #140e0a;
  color: #fff;
  font-weight: 700;
  font-size: .71rem;
  padding: .58rem .65rem;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.cp-table.light-head th {
  background: #f5f4f4;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.cp-table td {
  padding: .52rem .65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.cp-table tbody tr:hover td {
  background: #faf9f8;
}
.cp-table .cp-input, .cp-table .cp-select {
  min-height: 1.9rem;
  padding: .22rem .45rem;
  font-size: .75rem;
}

.weights-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .5rem;
  margin-bottom: .75rem;
}
.weights-summary-item {
  display: grid;
  gap: .22rem;
}
.weights-summary-item label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.flash-alert {
  padding: .75rem 1rem;
  border-radius: .75rem;
  font-size: .82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.flash-success { background: #e7f9eb; color: #159b36; border: 1px solid #bce8c6; }
.flash-error { background: #ffece8; color: #d6321c; border: 1px solid #f7c3ba; }

.doc-tile {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .8rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: #fcfcfc;
}
.doc-badge {
  width: 2.6rem;
  height: 2.8rem;
  border-radius: .55rem;
  display: grid;
  place-items: center;
  font-size: .68rem;
  font-weight: 700;
  color: #fff;
  flex: none;
}
.doc-badge.pdf { background: #d6321c; }
.doc-badge.html { background: #140e0a; }

/* AWB Attachments Reference Document Cards */
.att-doc-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .65rem .8rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: #fcfcfc;
}
.att-file-icon {
  width: 4.5rem;
  height: 5rem;
  border-radius: .55rem;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: .55rem;
  flex: none;
  overflow: hidden;
  border: 1px solid #e2dedc;
  background: #fff;
}
.att-file-icon::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1.15rem;
  height: 1.15rem;
  background: linear-gradient(225deg, #ece8e6 50%, #d5cfcc 50%);
  border-bottom-left-radius: .25rem;
}
.att-file-icon.is-pdf .att-file-ext {
  display: block;
  width: 100%;
  text-align: center;
  background: #c63b2b;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .28rem 0;
}
.att-file-icon.is-html {
  background: #140e0a;
  border-color: #140e0a;
}
.att-file-icon.is-html::before {
  background: linear-gradient(225deg, #2d2520 50%, #3d332d 50%);
}
.att-file-icon.is-html .att-file-ext {
  display: block;
  width: 100%;
  text-align: center;
  color: #fff;
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .35rem 0;
}
.att-file-meta {
  display: grid;
  gap: .28rem;
  min-width: 0;
}
.att-file-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}
.att-file-link {
  font-size: .78rem;
  font-weight: 700;
  color: #1d4ed8;
  text-decoration: none;
}
.att-file-link:hover {
  text-decoration: underline;
}
.att-trash-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: .38rem;
  color: #d6321c;
  background: #ffece8;
}
.att-trash-btn:hover {
  background: #fbd5ce;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
}
.perm-group {
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: .8rem .95rem;
  background: #fcfcfc;
}
.perm-group h4 {
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: .55rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--line);
}
.perm-list {
  display: grid;
  gap: .4rem;
}

@media (max-width: 1480px) {
  .filter-grid-6 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1280px) {
  .awb-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .awb-span-2 { grid-column: span 2; }
  .billing-layout { grid-template-columns: 1fr 1fr; }
  .filter-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .perm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .page-wrap { padding: 1rem 1rem 1.75rem; }
  .awb-grid-3, .awb-grid-2, .billing-layout, .purchase-layout, .perm-grid { grid-template-columns: 1fr; }
  .awb-span-2 { grid-column: span 1; }
  .filter-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .weights-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar-meta .role-chip { display: none; }
}

@media (max-width: 550px) {
  .cp-row { grid-template-columns: 1fr; gap: .25rem; }
  .filter-grid-6 { grid-template-columns: 1fr; }
  .weights-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-split-3 { grid-template-columns: 1fr 1fr; }
  .cp-input, .cp-select, .cp-textarea { font-size: 16px; }
}
