:root {
    --bg: #eef3f6;
    --panel: #ffffff;
    --panel-soft: #f8fbfc;
    --ink: #17252c;
    --muted: #667780;
    --brand: #116a63;
    --brand-strong: #0c4f4a;
    --brand-soft: #e5f4f1;
    --line: #d9e3e6;
    --line-strong: #bfd2d6;
    --danger: #bd3b16;
    --danger-soft: #fff1ea;
    --warning: #a45a10;
    --warning-soft: #fff7e6;
    --info: #2358a8;
    --info-soft: #edf5ff;
    --success: #14743a;
    --success-soft: #e8f7ee;
    --shadow: 0 16px 36px rgba(23, 37, 44, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(140deg, rgba(17, 106, 99, .09), transparent 34%),
        linear-gradient(20deg, rgba(35, 88, 168, .08), transparent 38%),
        var(--bg);
    color: var(--ink);
    font: 15px/1.55 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a { color: var(--brand); text-decoration: none; }
small { color: var(--muted); }

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(180deg, #0e3437, #09282b);
    color: #eaf7f5;
    padding: 24px 18px;
}

.brand {
    display: grid;
    gap: 3px;
    margin-bottom: 22px;
    font-size: 22px;
    font-weight: 900;
    line-height: 1.1;
}

.brand span {
    color: #99cac4;
    font-size: 12px;
    font-weight: 700;
}

.user-card {
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    background: rgba(255,255,255,.07);
}

.user-card span {
    display: block;
    color: #9fcfca;
    font-size: 12px;
}

nav {
    display: grid;
    gap: 6px;
    margin-bottom: 20px;
}

.nav-label {
    margin: 14px 8px 3px;
    color: #8abbb5;
    font-size: 12px;
    font-weight: 800;
}

nav a,
.link-button {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    color: #eaf7f5;
    padding: 9px 11px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

nav a:hover,
nav a.active,
.link-button:hover {
    background: rgba(255,255,255,.12);
}

nav a.active {
    box-shadow: inset 3px 0 0 #80d8ce;
}

.content {
    width: 100%;
    max-width: 1480px;
    padding: 28px;
}

.page-head {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

h1, h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 { font-size: 26px; line-height: 1.25; }
h2 { margin-bottom: 14px; font-size: 17px; }
p { margin: 4px 0 0; color: var(--muted); }

.meta-line {
    margin-top: 5px;
    color: var(--muted);
    font-size: 14px;
}

.card,
.login-panel {
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
}

.login-panel {
    max-width: 380px;
    margin: 14vh auto;
}

label {
    display: block;
    margin: 8px 0 4px;
    color: #263940;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid #c9d8dc;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fbfefe;
    color: var(--ink);
    font: inherit;
    outline: none;
    transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

textarea { resize: vertical; }

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(17, 106, 99, .14);
}

button,
.primary {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    background: var(--brand);
    color: white;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

button:hover,
.primary:hover {
    background: var(--brand-strong);
    box-shadow: 0 8px 18px rgba(17, 106, 99, .18);
}

button:active,
.primary:active { transform: translateY(1px); }

.block { width: 100%; }

.secondary,
.primary.ghost {
    background: var(--brand-soft);
    color: var(--brand-strong);
    border: 1px solid #b7d9d4;
}

.secondary:hover,
.primary.ghost:hover {
    background: #d7eee9;
}

.danger-button,
.quiet-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #f4c7b2;
}

.danger-button:hover,
.quiet-danger:hover { background: #ffe5d7; }
.danger { color: var(--danger); }

.toast {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 800;
}

.toast.success { background: var(--success-soft); color: var(--success); }
.toast.error { background: #fff1f2; color: #b42342; }

.grid.two {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

.table-card { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: #51676f;
    background: var(--panel-soft);
    font-size: 13px;
    font-weight: 900;
}

tbody tr:hover td { background: #fbfdfd; }

.empty {
    padding: 38px;
    color: var(--muted);
    text-align: center;
}

.empty-inline {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #edf2f7;
    color: #334155;
    font-size: 13px;
    font-weight: 900;
}

.badge.department_review { background: var(--warning-soft); color: var(--warning); }
.badge.finance_review { background: var(--info-soft); color: var(--info); }
.badge.posted,
.badge.approved { background: var(--success-soft); color: var(--success); }
.badge.rejected,
.badge.posting_failed { background: #fff1f2; color: #b42342; }
.badge.posting { background: #fef3c7; color: #d97706; }

.status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.status-tabs a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    color: #52646d;
    font-weight: 800;
}

.status-tabs .active {
    border-color: var(--brand);
    background: var(--brand);
    color: white;
}

.form-card {
    max-width: 1180px;
}

.recharge-compact {
    max-width: 1440px;
}

.recharge-create-head {
    align-items: flex-start;
}

.segmented-actions {
    display: inline-flex;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
}

.segmented-actions a {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 900;
}

.segmented-actions a.active {
    background: var(--brand);
    color: white;
}

.compact-card {
    margin-bottom: 10px;
    padding: 12px;
}

.compact-section-head,
.submit-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.compact-section-head h2 {
    margin-bottom: 0;
}

.compact-grid {
    display: grid;
    gap: 8px;
    align-items: start;
}

.recharge-split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
    gap: 12px;
    align-items: start;
}

.recharge-main-panel {
    min-width: 0;
}

.customer-overview-grid {
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
    gap: 12px;
}

.customer-left {
    display: grid;
    gap: 8px;
}

.customer-coupons-side {
    position: sticky;
    top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
}

.coupon-card-list {
    display: grid;
    gap: 8px;
    max-height: calc(100vh - 120px);
    overflow: auto;
    padding-right: 2px;
}

.coupon-item-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.coupon-item-name {
    font-size: 14px;
    font-weight: 900;
    color: var(--ink);
    margin-bottom: 4px;
}

.coupon-item-meta {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: 13px;
}

.customer-grid {
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
}

.item-grid {
    grid-template-columns: minmax(280px, 2fr) minmax(120px, .55fr) minmax(120px, .55fr) minmax(130px, .6fr);
}

.compact-row {
    margin-bottom: 8px;
    padding: 10px;
}

.compact-row .row-title {
    margin-bottom: 6px;
}

.compact-items:empty::before {
    content: "选择客户后自动添加第一行明细";
    display: block;
    padding: 10px;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    color: var(--muted);
    background: var(--panel-soft);
}

.slim-button {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 13px;
}

.inline-warning {
    display: inline-flex;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--warning-soft);
    color: var(--warning);
    font-weight: 900;
}

.compact-profile {
    margin-top: 0;
    padding: 8px;
}

.readonly-car-line {
    min-height: 38px;
    display: flex;
    align-items: center;
    border: 1px solid #c9d8dc;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fbfefe;
    color: var(--ink);
}

.compact-profile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 6px;
}

.compact-profile-grid span {
    padding: 6px;
}

.upload-drop {
    min-height: 56px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 10px 12px;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: var(--panel-soft);
    cursor: pointer;
}

.upload-drop span {
    color: var(--brand-strong);
    font-weight: 800;
}

.upload-drop small {
    color: var(--muted);
    font-size: 12px;
}

.attachment-preview-grid {
    margin-top: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.attachment-preview-item {
    min-height: 120px;
    display: grid;
    gap: 6px;
    align-content: start;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.attachment-preview-item img {
    width: 100%;
    height: 88px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: white;
}

.attachment-file-ext {
    width: 100%;
    height: 88px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #f0f5ff;
    color: var(--info);
    font-weight: 900;
}

.attachment-preview-item small {
    word-break: break-all;
}

.attachment-link {
    color: var(--ink);
    text-decoration: none;
}

.attachment-link:hover {
    border-color: var(--brand);
    box-shadow: 0 4px 12px rgba(17, 106, 99, .12);
}

.existing-attachments {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.existing-attachment-item {
    margin: 0;
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.existing-attachment-item input {
    width: 16px;
    min-height: 16px;
    margin: 0;
}

.logs-details summary {
    cursor: pointer;
    color: var(--brand-strong);
    font-weight: 800;
    margin-bottom: 10px;
}

.badge.kind-coupon { background: var(--brand-soft); color: var(--brand-strong); }
.badge.kind-balance { background: var(--info-soft); color: var(--info); }
.badge.kind-mixed { background: #f1f5f9; color: #475569; }

.form-toolbar,
.submit-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.submit-bar {
    justify-content: flex-end;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.item-row {
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.row-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.row-label {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.lookup-box { position: relative; }

.lookup-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 300px;
    overflow: auto;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 36px rgba(23, 37, 44, .16);
}

.lookup-option {
    width: 100%;
    min-height: auto;
    display: block;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid #edf3f7;
    border-radius: 0;
    background: #fff;
    color: var(--ink);
    text-align: left;
    white-space: normal;
}

.lookup-option:hover {
    background: #eff8f6;
    box-shadow: none;
}

.lookup-option strong,
.lookup-option span { display: block; }

.lookup-option span,
.lookup-selected,
.lookup-empty {
    color: var(--muted);
    font-size: 13px;
}

.lookup-selected {
    margin-top: 7px;
    min-height: 24px;
}

.lookup-selected.is-selected {
    color: var(--brand-strong);
    font-weight: 800;
}

.lookup-empty { padding: 12px 14px; }

.field-invalid {
    border-color: var(--danger) !important;
    background: #fff9f6 !important;
    box-shadow: 0 0 0 3px rgba(189, 59, 22, .12) !important;
}

.customer-profile {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid #cfe3e0;
    border-radius: 8px;
    background: #f5fbfa;
}

.customer-profile label { margin-top: 0; }

.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.profile-grid span {
    min-width: 0;
    display: block;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    word-break: break-word;
}

.profile-grid strong {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.profile-empty { color: var(--danger); font-weight: 800; }

.action-card {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.action-card h2 {
    width: 100%;
    margin-bottom: 0;
}

.action-card form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

/* --- Recharge show detail page --- */
.recharge-show-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
    gap: 14px;
    align-items: start;
}

.recharge-show-main {
    min-width: 0;
    display: grid;
    gap: 14px;
}

.recharge-show-main .card {
    margin-bottom: 0;
}

.detail-side-panel {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 14px;
}

.detail-side-panel .card {
    margin-bottom: 0;
}

.order-customer-bar {
    display: grid;
    gap: 10px;
}

.order-customer-bar .profile-grid {
    margin-top: 0;
}

.order-items-table th,
.order-items-table td {
    vertical-align: middle;
}

.order-items-table .col-amount {
    font-weight: 900;
    color: var(--brand-strong);
    white-space: nowrap;
}

.approval-actions-panel {
    display: grid;
    gap: 14px;
}

.approval-action-block {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.approval-action-block--danger {
    border-color: #f4c7b2;
    background: #fff9f6;
}

.approval-action-block h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--ink);
}

.approval-action-form {
    display: grid;
    gap: 10px;
}

.approval-action-form label {
    margin: 0;
    font-size: 13px;
}

.approval-action-form input {
    width: 100%;
}

.approval-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-side-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.attachment-side-item {
    width: 100%;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: var(--panel-soft);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    font: inherit;
    font-weight: inherit;
    min-height: auto;
    box-shadow: none;
}

.attachment-side-item:hover {
    border-color: var(--brand);
    background: #fff;
    transform: none;
}

.attachment-side-thumb {
    width: 72px;
    height: 56px;
    display: block;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: #fff;
    overflow: hidden;
}

.attachment-side-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attachment-side-thumb-pdf {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--info);
    font-size: 13px;
    font-weight: 900;
}

.attachment-side-item--missing {
    cursor: default;
    border-style: dashed;
    background: #fff9f6;
}

.attachment-side-item--missing:hover {
    border-color: var(--line);
    background: #fff9f6;
}

.attachment-side-thumb-missing {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--danger);
    font-size: 12px;
    font-weight: 900;
    background: var(--danger-soft);
}

.attachment-side-name {
    display: block;
    overflow: hidden;
    font-size: 13px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-side-meta {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.approval-button-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.attachment-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    padding: 28px;
    background: rgba(10, 20, 24, .72);
}

.attachment-modal.open {
    display: grid;
    place-items: center;
}

.attachment-modal-inner {
    width: min(1100px, 96vw);
    height: min(760px, 90vh);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
    overflow: hidden;
}

.attachment-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.attachment-modal-title {
    overflow: hidden;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-modal-body {
    min-height: 0;
    display: grid;
    place-items: center;
    background: #f5f8f9;
}

.attachment-modal-body img,
.attachment-modal-body iframe {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border: 0;
    object-fit: contain;
}

.timeline {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-left: 3px solid #8ecdc5;
    border-radius: 0 8px 8px 0;
    background: var(--panel-soft);
}

.timeline span,
.timeline small {
    display: block;
    color: var(--muted);
}

.approver-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.approver-row {
    display: grid;
    grid-template-columns: minmax(120px, .6fr) minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.approver-row select {
    min-height: 92px;
}

/* --- UI iteration 1: table actions & filters --- */
.page-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 18px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow);
}

.filter-group {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.filter-group-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.filter-group .status-tabs {
    margin-bottom: 0;
}

.batch-action-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px 18px;
    border: 2px solid var(--brand);
    border-radius: 8px;
    background: var(--brand-soft);
    box-shadow: var(--shadow);
}

.batch-action-bar.is-visible {
    display: flex;
    flex-wrap: wrap;
}

.batch-action-bar strong {
    color: var(--brand-strong);
    font-size: 15px;
}

.batch-action-bar .count {
    font-size: 18px;
}

.batch-action-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-chip {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    background: transparent;
    font-family: inherit;
}

.btn-chip--view {
    background: var(--info-soft);
    color: var(--info);
    border-color: #bfdbfe;
}

.btn-chip--edit {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: #ffd8a8;
}

.btn-chip--success {
    background: var(--success-soft);
    color: var(--success);
    border-color: #c2ebd0;
}

.btn-chip--danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #f4c7b2;
}

.btn-chip--brand {
    background: var(--brand-soft);
    color: var(--brand-strong);
    border-color: #b7d9d4;
}

.btn-chip--muted {
    background: #f1f5f9;
    color: #475569;
    border-color: var(--line);
}

.btn-chip:hover {
    filter: brightness(.97);
}

.table-actions details {
    position: relative;
}

.table-actions details summary {
    list-style: none;
    cursor: pointer;
}

.table-actions details summary::-webkit-details-marker {
    display: none;
}

.table-actions-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    right: 0;
    min-width: 120px;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(23, 37, 44, .14);
}

.table-actions-menu form {
    margin: 0;
}

.table-actions-menu .btn-chip {
    width: 100%;
    margin-bottom: 4px;
}

.table-actions-menu .btn-chip:last-child {
    margin-bottom: 0;
}

.cell-mono {
    font-weight: 800;
    color: var(--brand-strong);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 14px;
}

.hover-trigger {
    position: relative;
    cursor: help;
}

.hover-trigger.is-open,
.hover-trigger:hover {
    background-color: var(--panel-soft) !important;
}

.hover-details-card {
    display: none;
    position: absolute;
    z-index: 999;
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
    width: min(320px, 70vw);
    padding: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(23, 37, 44, .18);
    text-align: left;
    pointer-events: none;
}

.hover-trigger.is-open .hover-details-card,
.hover-trigger:hover .hover-details-card {
    display: block;
}

.hover-details-card::before,
.hover-details-card::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 100%;
    border-style: solid;
    border-color: transparent;
}

.hover-details-card::before {
    margin-top: -6px;
    border-width: 6px;
    border-right-color: var(--line-strong);
}

.hover-details-card::after {
    margin-top: -5px;
    border-width: 5px;
    border-right-color: #fff;
}

.hover-details-card .card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    color: var(--brand-strong);
    font-size: 13px;
    font-weight: 800;
}

.hover-details-card .card-list {
    display: grid;
    gap: 8px;
    max-height: 240px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.hover-details-card .card-list li {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--line);
    font-size: 12px;
    line-height: 1.4;
}

.hover-details-card .card-list li:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.hover-details-card .type-tag {
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.hover-details-card .type-tag.coupon {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.hover-details-card .type-tag.balance {
    background: var(--info-soft);
    color: var(--info);
}

.hover-details-card .name {
    color: var(--ink);
    font-weight: 500;
    word-break: break-all;
}

.hover-details-card .val {
    color: var(--brand-strong);
    font-weight: 900;
    white-space: nowrap;
}

.customer-cell-label {
    border-bottom: 1px dashed var(--muted);
    padding-bottom: 2px;
}

.role-label {
    color: #9fcfca;
    font-size: 12px;
}

@media (max-width: 900px) {
    .shell,
    .grid.two,
    .recharge-split-layout,
    .recharge-show-layout,
    .approver-grid,
    .approver-row {
        grid-template-columns: 1fr;
    }

    .detail-side-panel {
        position: static;
    }

    .approval-action-buttons {
        flex-direction: column;
    }

    .approval-action-buttons .primary,
    .approval-action-buttons .secondary,
    .approval-action-buttons .danger-button {
        width: 100%;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .content { padding: 18px; }
    .page-head { align-items: stretch; flex-direction: column; }
    .page-head .primary { width: 100%; }
    .profile-grid,
    .customer-overview-grid,
    .customer-grid,
    .item-grid { grid-template-columns: 1fr; }
    .customer-coupons-side { position: static; }
    .attachment-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .compact-section-head,
    .submit-line { align-items: stretch; flex-direction: column; }
    .segmented-actions { width: 100%; }
    .segmented-actions a { flex: 1; justify-content: center; }
    .action-card form { width: 100%; flex-direction: column; align-items: stretch; }
    .submit-bar .primary,
    .form-toolbar button { width: 100%; }
}

/* --- Iteration 2/3: guest, nav, dialog, stepper, search --- */
.guest-body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(140deg, rgba(17, 106, 99, .09), transparent 34%),
        var(--bg);
}

.guest-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    min-height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-radius: 999px;
    background: #ffd8a8;
    color: #8a4b00;
    font-size: 11px;
    font-weight: 900;
}

nav a {
    justify-content: space-between;
}

.nav-group {
    margin: 2px 0;
}

.nav-group summary {
    list-style: none;
    cursor: pointer;
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 9px 11px;
    border-radius: 8px;
    color: #eaf7f5;
    font-weight: 800;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group[open] summary,
.nav-group summary:hover {
    background: rgba(255, 255, 255, .12);
}

.nav-group a {
    margin-left: 10px;
    font-size: 14px;
}

.search-bar .search-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-group--grow {
    flex: 1 1 280px;
}

.filter-select {
    min-height: 36px;
    min-width: 160px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.section-subtitle {
    margin: 14px 0 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.prewrap {
    margin: 0;
    white-space: pre-wrap;
    color: var(--ink);
}

.approval-stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.approval-step {
    flex: 1 1 120px;
    display: grid;
    gap: 6px;
    justify-items: center;
    text-align: center;
    padding: 8px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.approval-step-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #cbd5e1;
}

.approval-step-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
}

.approval-step--done {
    border-color: #b7d9d4;
    background: var(--brand-soft);
}

.approval-step--done .approval-step-dot {
    background: var(--brand);
}

.approval-step--done .approval-step-label {
    color: var(--brand-strong);
}

.approval-step--current {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(17, 106, 99, .12);
}

.approval-step--current .approval-step-dot {
    background: var(--brand);
}

.approval-step--current .approval-step-label {
    color: var(--brand-strong);
}

.approval-step--rejected {
    border-color: #f4c7b2;
    background: var(--danger-soft);
}

.approval-step--rejected .approval-step-dot {
    background: var(--danger);
}

.approval-step--rejected .approval-step-label {
    color: var(--danger);
}

.approval-dialog {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(10, 20, 24, .72);
}

.approval-dialog.open {
    display: grid;
}

.approval-dialog-inner {
    width: min(440px, 96vw);
    padding: 18px;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.approval-dialog-inner h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.approval-dialog-inner p {
    margin: 0 0 12px;
    color: var(--muted);
}

.approval-dialog-inner input {
    width: 100%;
    margin-bottom: 12px;
}

.approval-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.table-card--sticky thead th:first-child,
.table-card--sticky thead th:nth-child(2) {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel-soft);
}

@media (max-width: 1200px) {
    .customer-overview-grid,
    .customer-grid,
    .item-grid {
        grid-template-columns: 1fr;
    }

    .recharge-split-layout {
        grid-template-columns: 1fr;
    }
}

@media print {
    .sidebar,
    .page-head-actions,
    .approval-actions-panel,
    .batch-action-bar,
    .filter-bar,
    .table-actions,
    .approval-dialog,
    .toast {
        display: none !important;
    }

    .shell {
        display: block;
    }

    .content {
        max-width: none;
        padding: 0;
    }

    .card {
        box-shadow: none;
        break-inside: avoid;
    }
}
