/*
 * records.css - Orders, Quotes and Customers: a list with per-column filters
 * (ui-grid, unchanged behaviour) and the records opened from it as tabs.
 * Loaded after pages.css; everything is scoped under .records.
 */

.records { max-width: var(--pp-container); margin: 0 auto; padding: 32px 24px 48px; background: #fff; }
.records-head { padding-bottom: 16px; }
.records-head h1 { margin: 0; font-size: 34px; font-weight: 300; color: var(--pp-heading); }
.records-sub { font-size: 14px; color: var(--pp-muted); }

/* ---------- Record tabs: the list first, opened records beside it ---------- */
.rtabs { display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--pp-line); margin: 0 0 20px; overflow-x: auto; }
.rtabs .rt {
    display: flex; align-items: center; gap: 8px; flex: 0 0 auto; max-width: 220px; height: 38px;
    padding: 0 10px 0 14px; margin-bottom: -1px;
    border: 1px solid var(--pp-line); border-bottom: 0; border-radius: 6px 6px 0 0;
    background: var(--pp-band); color: var(--pp-text-2); font-size: 14px; cursor: pointer;
}
.rtabs .rt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtabs .rt b { font-weight: 400; font-size: 12px; color: var(--pp-muted); }
.rtabs .rt-list { font-weight: 600; padding-right: 14px; }
.rtabs .rt.on { height: 40px; background: #fff; color: var(--pp-heading); font-weight: 600; box-shadow: inset 0 3px 0 var(--pp-red); }
.rtabs .rt-x { font-style: normal; font-size: 18px; line-height: 1; padding: 0 4px 2px; border-radius: 3px; color: var(--pp-muted); }
.rtabs .rt-x:hover { background: var(--pp-line); color: var(--pp-heading); }
.rtabs .rt-sp { flex: 1; }
.rtabs .rt-closeall { flex: 0 0 auto; padding: 0 4px 10px; font-size: 13px; color: var(--pp-muted); text-decoration: underline; }

/* ---------- The list ---------- */
.records .ui-grid-cell.is-open { box-shadow: inset 0 0 0 9999px var(--pp-tint); }
.records .ui-grid-cell.is-open:first-child { box-shadow: inset 3px 0 0 var(--pp-red), inset 0 0 0 9999px var(--pp-tint); }
.records .ui-grid-row { cursor: pointer; }
.records .ui-grid-cell.num .ui-grid-cell-contents,
.records .ui-grid-header-cell.num .ui-grid-cell-contents { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; line-height: 1.6; vertical-align: middle; background: #efefed; color: var(--pp-muted); }
.pill-wait { background: #fdf3dc; color: #8a5a00; }
.pill-ok { background: #eaf5ee; color: #2f7d4f; }
.pill-bad { background: #fbeaea; color: #8f1f1f; }
.pill-staff { background: var(--pp-tint); color: var(--pp-red); border: 1px solid var(--pp-tint-border); }

/* ---------- An opened record ---------- */
.record-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--pp-line); }
.record-head h2 { margin: 0 0 4px; font-size: 26px; font-weight: 700; color: var(--pp-heading); }
.record-acts { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; }
.record-acts .btn { display: inline-flex; align-items: center; gap: 8px; }

.record-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
.record-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 28px; }
.rcard { border: 1px solid var(--pp-line); border-radius: var(--pp-radius-card, 6px); padding: 16px 18px; background: #fff; margin-bottom: 16px; }
.record-cards .rcard { margin-bottom: 0; }
.rcard-soft { background: var(--pp-panel); }
.rcard h4, .rsum h4, .rstaff h4 { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--pp-muted); }
.rdl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.rdl dt { font-weight: 400; color: var(--pp-muted); }
.rdl dd { margin: 0; color: var(--pp-heading); }

.record-h { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: var(--pp-heading); }
.record-items { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.record-items th { padding: 8px 10px; border-bottom: 1px solid var(--pp-line); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--pp-muted); text-align: left; }
.record-items td { padding: 14px 10px; border-bottom: 1px solid var(--pp-line); vertical-align: top; }
.record-items .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.record-items .ri-img { width: 84px; }
.record-items .ri-img img { width: 64px; height: 64px; object-fit: contain; background: #fff; border: 1px solid var(--pp-line); border-radius: 4px; padding: 4px; }
.ri-title { font-weight: 600; color: var(--pp-heading); }
.ri-opts { margin-top: 4px; font-size: 13px; color: var(--pp-muted); }
.ri-staff { margin-top: 6px; font-size: 13px; color: var(--pp-text-2); }

.rstaff { border: 1px solid var(--pp-tint-border); background: var(--pp-tint); border-radius: 6px; padding: 16px 18px; margin-top: 8px; }
.rstaff h4 { color: var(--pp-red); }
.rstaff .table { background: #fff; }

.rsum { border: 1px solid var(--pp-line); border-radius: 6px; background: var(--pp-panel); padding: 18px 20px; margin-bottom: 16px; }
.rsum-rows { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0 0 12px; }
.rsum-rows dt { font-weight: 400; color: var(--pp-text-2); }
.rsum-rows dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.rsum-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-top: 12px; border-top: 1px solid var(--pp-line); font-weight: 600; color: var(--pp-heading); }
.rsum-total b { font-size: 22px; font-variant-numeric: tabular-nums; }
.rsum-total small { font-size: 12px; font-weight: 400; color: var(--pp-muted); }

@media (max-width: 991px) {
    .record-grid { grid-template-columns: 1fr; }
    .record-cards { grid-template-columns: 1fr; }
}

/* ---------- Header actions, quote extras ---------- */
.records-head-acts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.records-head-acts .record-acts { align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--pp-input); border-radius: var(--pp-radius, 4px); overflow: hidden; }
.seg button { height: 38px; padding: 0 14px; border: 0; border-left: 1px solid var(--pp-input); background: #fff; color: var(--pp-text-2); font-size: 14px; font-weight: 500; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--pp-heading); color: #fff; }
.record-status { width: auto; min-width: 150px; height: 38px; }
.record-note { margin: -14px 0 20px; font-size: 13px; color: var(--pp-muted); text-align: right; }
.raddr { line-height: 1.6; }
.raddr b { color: var(--pp-heading); }
ul.ri-opts { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Customers: the existing contact / sales forms inside a tab ---------- */
.record-form .panel-body { padding: 0; border: 0; background: none; }
.record-form .ibox { margin-bottom: 20px; }
.record-form .ibox-title { padding: 0 0 8px; border: 0; background: none; min-height: 0; }
.record-form .ibox-title h3, .record-form .ibox-title h5 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--pp-muted); }
.record-form .ibox-content { display: flow-root; padding: 16px 18px; border: 1px solid var(--pp-line); border-radius: 6px; }   /* contain the floated bootstrap columns */
.record-form .tabs-container .nav-tabs,
.record-form > .nav-tabs { margin-bottom: 20px; }
.record-form .ibox-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.record-form .ibox-title > .pull-left,
.record-form .ibox-title > .pull-right { float: none !important; }
.record-form .ibox-title .checkbox { margin: 0; font-size: 14px; }

/* ---------- Reports ---------- */
.report-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.report-card { margin: 0; padding: 22px 24px; }
.report-card h3 { margin: 0 0 4px; font-size: 20px; font-weight: 700; color: var(--pp-heading); }
.report-card > .records-sub { margin: 0 0 18px; }
.report-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.report-fields .form-group { margin: 0; }
.report-fields .control-label { font-weight: 600; color: var(--pp-heading); }
.report-acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--pp-line); }
@media (max-width: 991px) {
    .report-cards, .report-fields { grid-template-columns: 1fr; }
}

/* ---------- Admin pages on the same frame (Audit log, Payment terms, Config migrations) ---------- */
.records-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0 0 16px; }
.records-bar-field { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; color: var(--pp-muted); }
.records-bar-field .form-control { width: auto; }
.records-bar .rt-closeall { padding: 0 4px; }
.records .alert { border-radius: 6px; }
.records .ibox { margin-bottom: 20px; }
.records .ibox-content { padding: 16px 18px; border: 1px solid var(--pp-line); border-radius: 6px; }
.records .ibox-title { padding: 0 0 8px; border: 0; background: none; min-height: 0; }

.terms-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.terms-cols .rcard { margin: 0; }
.terms-list { list-style: none; margin: 0; padding: 0; }
.terms-scroll { max-height: 540px; overflow-y: auto; }
.term { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--pp-line); border-radius: 6px; background: #fff; }
.term-drag { cursor: grab; background: var(--pp-panel); }
.term-grip { margin-top: 3px; color: var(--pp-muted); }
.term-text { flex: 1; min-width: 0; white-space: pre-line; }
.term-text strong { color: var(--pp-heading); }
.terms-search { margin-bottom: 12px; }
.records .formbar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; padding: 14px 0; border-top: 1px solid var(--pp-line); background: #fff; }
@media (max-width: 991px) { .terms-cols { grid-template-columns: 1fr; } }
