:root {
    --bg: #f5f7fb;
    --ink: #111827;
    --muted: #64748b;
    --line: #dde4ee;
    --panel: rgba(255, 255, 255, 0.9);
    --blue: #1257ff;
    --cyan: #14b8d4;
    --green: #0f9f6e;
    --navy: #10192f;
    --gold: #e8b23f;
    --shadow: 0 20px 60px rgba(17, 24, 39, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(20, 184, 212, 0.16), transparent 32rem),
        linear-gradient(135deg, #f7fafc 0%, #eef4ff 45%, #f8fbfd 100%);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 28px;
    background: #0d1324;
    color: white;
    transition: width 0.2s ease, padding 0.2s ease;
}

.sidebar-toggle {
    align-items: center;
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    display: inline-grid;
    gap: 3px;
    height: 36px;
    justify-content: center;
    min-height: 36px;
    padding: 0;
    width: 36px;
}

.sidebar-toggle-arrow {
    color: white;
    display: block;
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    margin-top: -2px;
    transition: transform 0.2s ease;
}

.sidebar-collapsed .sidebar-toggle-arrow {
    transform: rotate(180deg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo-wrap {
    align-items: center;
    background: white;
    border-radius: 8px;
    display: flex;
    flex: 0 0 auto;
    height: 44px;
    justify-content: center;
    padding: 6px;
    width: 58px;
}

.brand-logo {
    display: block;
    height: auto;
    max-height: 32px;
    max-width: 100%;
    object-fit: contain;
}

.brand-mark {
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--gold), #fff1a6);
    color: #14213d;
    font-weight: 900;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.sidebar-foot span {
    color: #94a3b8;
    font-size: 12px;
}

nav {
    display: grid;
    gap: 8px;
}

nav a {
    align-items: center;
    border-radius: 8px;
    color: #cbd5e1;
    display: flex;
    gap: 10px;
    font-weight: 700;
    padding: 13px 14px;
}

nav a span {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    display: inline-flex;
    flex: 0 0 26px;
    height: 26px;
    justify-content: center;
    width: 26px;
}

nav a strong {
    font: inherit;
}

nav a.active,
nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-foot {
    margin-top: auto;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 16px;
}

.sidebar-foot strong,
.sidebar-foot span {
    display: block;
}

.shell {
    margin-left: 280px;
    min-height: 100vh;
    padding: 34px;
    transition: margin-left 0.2s ease;
}

.sidebar-collapsed .sidebar {
    gap: 24px;
    padding: 20px 14px;
    width: 88px;
}

.sidebar-collapsed .brand {
    justify-content: center;
}

.sidebar-collapsed .brand-logo-wrap {
    width: 56px;
}

.sidebar-collapsed .brand > span:last-child,
.sidebar-collapsed nav a strong,
.sidebar-collapsed .sidebar-foot {
    display: none;
}

.sidebar-collapsed nav a {
    justify-content: center;
    padding: 12px;
}

.sidebar-collapsed nav a span {
    flex-basis: 32px;
    height: 32px;
    width: 32px;
}

.sidebar-collapsed .shell {
    margin-left: 88px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
}

.eyebrow {
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(32px, 5vw, 58px);
    letter-spacing: 0;
    line-height: 0.98;
    margin-bottom: 14px;
    max-width: 820px;
}

h2 {
    font-size: 18px;
    letter-spacing: 0;
    margin-bottom: 0;
}

.subtle,
small,
.empty {
    color: var(--muted);
}

.month-picker,
.action-row,
.action-row form {
    align-items: flex-end;
    display: flex;
    gap: 10px;
}

label {
    color: #334155;
    display: grid;
    font-size: 13px;
    font-weight: 800;
    gap: 8px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

textarea {
    resize: vertical;
}

button,
.button-link {
    align-items: center;
    background: var(--ink);
    border: 0;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 800;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
}

.button-link.secondary {
    background: #f8fafc;
    border: 1px solid var(--line);
    color: var(--ink);
}

.button-link.disabled {
    cursor: not-allowed;
    opacity: 0.45;
    pointer-events: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.metrics-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 18px;
}

.metric,
.panel,
.invoice-sheet {
    background: var(--panel);
    border: 1px solid rgba(221, 228, 238, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    min-height: 150px;
    padding: 22px;
    min-width: 0;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric strong {
    display: block;
    font-size: 34px;
    letter-spacing: 0;
    margin: 18px 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric.accent {
    background: linear-gradient(135deg, #111827, #123f6d);
    color: white;
}

.metric.accent.profit {
    background: linear-gradient(135deg, #0f172a, #08744f);
}

.metric.accent.loss {
    background: linear-gradient(135deg, #111827, #991b1b);
}

.metric.accent span,
.metric.accent small {
    color: #cbd5e1;
}

.two-col,
.split-form {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.8fr);
}

.split-form {
    grid-template-columns: 360px minmax(0, 1fr);
}

.stacked-layout {
    display: grid;
    gap: 18px;
}

.collapsible-panel[hidden] {
    display: none;
}

.panel {
    overflow: hidden;
    padding: 20px;
}

.panel-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-head a {
    color: var(--blue);
    font-weight: 800;
}

.form-panel {
    display: grid;
    gap: 16px;
    align-self: start;
}

.mini-form {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(86px, 0.7fr) minmax(130px, 1fr) auto;
}

.mini-form input,
.mini-form button {
    min-height: 38px;
}

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

.dashboard-table-wrap {
    max-height: 760px;
    overflow: auto;
}

.dashboard-table-wrap thead th {
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 3;
}

.dashboard-customer-table {
    table-layout: fixed;
}

.dashboard-customer-table th,
.dashboard-customer-table td {
    font-size: 15px;
}

.dashboard-customer-table th {
    font-size: 12px;
    overflow-wrap: anywhere;
}

.dashboard-customer-table.wrap-table-text th,
.dashboard-customer-table.wrap-table-text td {
    white-space: normal;
    word-break: break-word;
}

.dashboard-customer-table:not(.wrap-table-text) th,
.dashboard-customer-table:not(.wrap-table-text) td {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-customer-table:not(.wrap-table-text) td a,
.dashboard-customer-table:not(.wrap-table-text) td strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-customer-table th:first-child,
.dashboard-customer-table td:first-child {
    min-width: 0;
    width: 24%;
}

.dashboard-customer-table th:nth-child(2),
.dashboard-customer-table td:nth-child(2) {
    width: 9%;
}

.dashboard-customer-table th:nth-child(n+3),
.dashboard-customer-table td:nth-child(n+3) {
    width: 13.4%;
}

.pagination {
    align-items: center;
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    font-size: 13px;
    font-weight: 800;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
}

.pagination > div {
    display: flex;
    gap: 10px;
}

.sticky-table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 68vh;
    overflow: auto;
}

.sticky-table-wrap table {
    min-width: 1180px;
    table-layout: fixed;
}

.sticky-table-wrap thead th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 5;
}

.sticky-table-wrap th:first-child,
.sticky-table-wrap td:first-child {
    background: #ffffff;
    left: 0;
    position: sticky;
    z-index: 4;
}

.sticky-table-wrap th:nth-child(2),
.sticky-table-wrap td:nth-child(2) {
    background: #ffffff;
    left: 58px;
    position: sticky;
    z-index: 4;
}

.sticky-table-wrap thead th:first-child,
.sticky-table-wrap thead th:nth-child(2) {
    background: #f8fafc;
    z-index: 8;
}

.sticky-table-wrap td:first-child,
.sticky-table-wrap th:first-child {
    min-width: 58px;
    width: 58px;
}

.sticky-table-wrap td:nth-child(2),
.sticky-table-wrap th:nth-child(2) {
    min-width: 170px;
}

.sticky-table-wrap td,
.sticky-table-wrap th {
    white-space: normal;
    word-break: break-word;
}

.sticky-table-wrap td:nth-child(1),
.sticky-table-wrap th:nth-child(1),
.sticky-table-wrap td:nth-child(2),
.sticky-table-wrap th:nth-child(2),
.sticky-table-wrap td:nth-child(6),
.sticky-table-wrap th:nth-child(6),
.sticky-table-wrap td:nth-child(7),
.sticky-table-wrap th:nth-child(7) {
    white-space: nowrap;
}

.sticky-table-wrap input,
.sticky-table-wrap select,
.sticky-table-wrap textarea {
    height: auto;
    min-height: 42px;
    white-space: normal;
}

.bulk-textarea {
    line-height: 1.35;
    min-width: 100%;
    overflow: hidden;
    overflow-wrap: anywhere;
    resize: vertical;
    white-space: pre-wrap;
}

.account-edit-field {
    line-height: 1.35;
    min-width: 100%;
    overflow: hidden;
    overflow-wrap: anywhere;
    resize: vertical;
    white-space: pre-wrap;
}

.auto-height-fields .bulk-textarea {
    resize: none;
}

.auto-height-fields .account-edit-field {
    resize: none;
}

.sticky-table-wrap input[type="text"],
.sticky-table-wrap input:not([type]),
.sticky-table-wrap textarea {
    overflow-wrap: anywhere;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0;
    text-align: left;
    text-transform: uppercase;
}

.sort-button {
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: inherit;
    justify-content: flex-start;
    min-height: 0;
    padding: 0;
    text-align: left;
    text-transform: inherit;
}

.sort-button::after {
    content: "↕";
    font-size: 11px;
    margin-left: 6px;
}

.sort-button[aria-sort="ascending"]::after {
    content: "↑";
}

.sort-button[aria-sort="descending"]::after {
    content: "↓";
}

td,
th {
    border-bottom: 1px solid var(--line);
    padding: 14px 12px;
    vertical-align: top;
    white-space: nowrap;
}

td:first-child,
th:first-child {
    padding-left: 0;
}

td:last-child,
th:last-child {
    padding-right: 0;
}

td a {
    color: var(--blue);
    font-weight: 800;
}

.invoice-list,
.cards-list {
    display: grid;
    gap: 10px;
}

.invoice-row,
.customer-card {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
}

.invoice-row strong,
.invoice-row small,
.customer-card strong,
.customer-card small {
    display: block;
}

.invoice-row em,
.customer-card em {
    color: var(--green);
    font-style: normal;
    font-weight: 900;
    white-space: nowrap;
}

.status {
    background: #eaf7f1;
    border-radius: 999px;
    color: #08744f;
    display: inline-block;
    font-size: 12px;
    font-weight: 900;
    padding: 6px 10px;
}

.status.danger {
    background: #fee2e2;
    color: #991b1b;
}

.match-pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    justify-content: center;
    min-width: 68px;
    padding: 7px 10px;
}

.match-pill.strong {
    background: #dcfce7;
    color: #166534;
}

.match-pill.medium {
    background: #fef3c7;
    color: #92400e;
}

.match-pill.weak {
    background: #fee2e2;
    color: #991b1b;
}

.inline-upload {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(260px, 1fr) auto;
}

.bulk-panel {
    margin-top: 18px;
}

.bulk-tools {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
}

.bulk-tool-row {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 96px auto auto auto 1fr;
}

.bulk-tool-row-main {
    grid-template-columns: 96px minmax(260px, 1fr) auto;
}

.bulk-tool-row-view {
    grid-template-columns: 96px auto auto minmax(260px, 360px);
}

.bulk-tool-row-view .bulk-search {
    justify-self: end;
}

.tool-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.bulk-tools button {
    min-height: 38px;
}

.bulk-tools input {
    min-height: 38px;
}

.bulk-search {
    border-color: #bfdbfe;
    max-width: 360px;
}

.table-search {
    max-width: 280px;
    min-height: 38px;
}

.check-label {
    align-items: center;
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.check-label input,
.row-select {
    height: 18px;
    min-height: 0;
    width: 18px;
}

.selected-row {
    background: #eef6ff;
}

.sticky-table-wrap tbody tr.group-tone-1 td,
table tbody tr.group-tone-1 td {
    background: #f0f9ff;
}

.sticky-table-wrap tbody tr.group-tone-2 td,
table tbody tr.group-tone-2 td {
    background: #f7fee7;
}

.sticky-table-wrap tbody tr.group-tone-3 td,
table tbody tr.group-tone-3 td {
    background: #fff7ed;
}

.sticky-table-wrap tbody tr.group-tone-4 td,
table tbody tr.group-tone-4 td {
    background: #f5f3ff;
}

.sticky-table-wrap tbody tr.group-tone-5 td,
table tbody tr.group-tone-5 td {
    background: #ecfdf5;
}

.sticky-table-wrap tbody tr.group-tone-6 td,
table tbody tr.group-tone-6 td {
    background: #fdf2f8;
}

.sticky-table-wrap tbody tr.group-tone-7 td,
table tbody tr.group-tone-7 td {
    background: #fefce8;
}

.sticky-table-wrap tbody tr.group-tone-8 td,
table tbody tr.group-tone-8 td {
    background: #f8fafc;
}

.sticky-table-wrap tbody tr.selected-row td {
    box-shadow: inset 0 0 0 9999px rgba(18, 87, 255, 0.08);
}

.flash-wrap {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.flash {
    background: #eaf7ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    color: #075985;
    font-weight: 700;
    padding: 12px 14px;
}

.invoice-sheet {
    background: white;
    margin: 0 auto;
    max-width: 1040px;
    padding: 36px;
}

.invoice-sheet header {
    align-items: flex-start;
    border-bottom: 2px solid var(--ink);
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 24px;
}

.invoice-sheet h2 {
    font-size: 28px;
    margin: 14px 0 4px;
}

.invoice-logo-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.invoice-logo {
    display: block;
    height: auto;
    object-fit: contain;
}

.atc-logo {
    max-width: 210px;
    width: 210px;
}

.aws-logo {
    max-height: 54px;
    max-width: 92px;
    width: 92px;
}

.logo-divider {
    background: var(--line);
    display: block;
    height: 44px;
    width: 1px;
}

dl {
    display: grid;
    gap: 8px 24px;
    grid-template-columns: auto auto;
    margin: 0;
}

dt {
    color: var(--muted);
    font-weight: 700;
}

dd {
    font-weight: 900;
    margin: 0;
    text-align: right;
}

.bill-to {
    background: #f8fafc;
    border-radius: 8px;
    margin: 24px 0;
    padding: 18px;
}

.bill-to span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.bill-to strong {
    display: block;
    font-size: 22px;
    margin: 6px 0 8px;
}

.bill-to p {
    color: #334155;
    margin-bottom: 4px;
}

.invoice-total {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

.invoice-total dl {
    min-width: 320px;
}

.invoice-total dt:last-of-type,
.invoice-total dd:last-of-type {
    border-top: 1px solid var(--line);
    font-size: 22px;
    padding-top: 12px;
}

@media (max-width: 980px) {
    .sidebar {
        position: static;
        width: auto;
    }

    .sidebar-collapsed .sidebar {
        width: auto;
    }

    .shell {
        margin-left: 0;
        padding: 20px;
    }

    .sidebar-collapsed .shell {
        margin-left: 0;
    }

    .sidebar-collapsed .brand > span:last-child,
    .sidebar-collapsed nav a strong,
    .sidebar-collapsed .sidebar-foot {
        display: block;
    }

    .sidebar-collapsed nav a {
        justify-content: flex-start;
    }

    .metrics-grid,
    .two-col,
    .split-form {
        grid-template-columns: 1fr;
    }

    .page-head,
    .invoice-sheet header {
        display: grid;
    }
}

@media (max-width: 1320px) {
    .metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .month-picker,
    .action-row,
    .action-row form,
    .pagination {
        align-items: stretch;
        display: grid;
        width: 100%;
    }

    .sidebar {
        padding: 18px;
    }

    .shell {
        padding: 16px;
    }

    h1 {
        font-size: 34px;
    }

    .invoice-sheet {
        padding: 18px;
    }

    .bulk-tool-row,
    .bulk-tool-row-main,
    .bulk-tool-row-view {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .bulk-search {
        max-width: none;
    }
}

@media print {
    body {
        background: white;
    }

    .sidebar,
    .page-head,
    .flash-wrap {
        display: none;
    }

    .shell {
        margin: 0;
        padding: 0;
    }

    .invoice-sheet {
        border: 0;
        box-shadow: none;
        max-width: none;
    }
}
