:root {
    color-scheme: light;
    --ink: #13251d;
    --muted: #66736c;
    --paper: #f2efe6;
    --surface: #fffdf7;
    --green: #0b6b3a;
    --green-dark: #073f25;
    --green-light: #dcebdd;
    --red: #c82f36;
    --red-dark: #8f1e26;
    --red-light: #f6d9d8;
    --line: #c8cec8;
    --sidebar-width: 248px;
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
    background: var(--paper);
}

body {
    min-height: 100svh;
    margin: 0;
    color: var(--ink);
    background: var(--paper);
}

body.modal-open {
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    padding: 28px 22px 22px;
    color: var(--surface);
    background: var(--green-dark);
    border-right: 6px solid var(--red);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--surface);
    font-size: 0.93rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    color: var(--surface);
    background: var(--red);
    border: 2px solid var(--surface);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.1rem;
}

nav {
    display: grid;
    gap: 4px;
    margin-top: 72px;
}

.nav-link {
    display: grid;
    grid-template-columns: 30px 1fr;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 10px;
    color: #b9cebf;
    border-left: 3px solid transparent;
    font-size: 0.86rem;
    font-weight: 750;
    text-decoration: none;
    transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.nav-link span {
    color: #769883;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.67rem;
}

.nav-link:hover,
.nav-link.is-active {
    color: var(--surface);
    background: #115431;
    border-left-color: var(--red);
}

.health-check {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 62px;
    margin-top: auto;
    padding: 10px 12px;
    color: var(--surface);
    background: transparent;
    border: 1px solid #47765b;
    text-align: left;
}

.health-check:hover {
    background: #115431;
    border-color: var(--surface);
}

.health-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    background: #66d787;
    border-radius: 50%;
}

.health-check.is-error .health-dot {
    background: var(--red);
}

.health-check strong,
.health-check small {
    display: block;
}

.health-check strong {
    font-size: 0.75rem;
}

.health-check small {
    margin-top: 3px;
    color: #a9c0b1;
    font-size: 0.66rem;
}

main {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 40px;
    min-height: 82px;
    padding: 14px clamp(28px, 5vw, 80px) 12px;
    color: var(--surface);
    background: var(--green);
    border-bottom: 6px solid var(--red);
}

.eyebrow,
.section-number,
.panel-kicker {
    margin: 0;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--green-light);
    font-size: 0.58rem;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.55rem, 2.2vw, 2rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

.topbar-note {
    max-width: 310px;
    margin: 0 0 2px;
    color: var(--green-light);
    font-size: 0.72rem;
    line-height: 1.4;
}

.section {
    padding: 56px clamp(28px, 5vw, 80px);
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 0;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 26px;
}

.section-number,
.panel-kicker {
    margin-bottom: 10px;
    color: var(--red);
}

h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.55rem, 2.2vw, 2.15rem);
    line-height: 1;
    letter-spacing: -0.035em;
    color: var(--green-dark);
}

.section-heading > p {
    max-width: 290px;
    margin: 0;
    color: var(--muted);
    font-size: 0.83rem;
    line-height: 1.55;
}

.overview-section {
    background: var(--surface);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 3px solid var(--green-dark);
    border-bottom: 3px solid var(--green-dark);
}

.metric {
    min-width: 0;
    padding: 20px;
    border-right: 1px solid var(--line);
}

.metric:last-child {
    border-right: 0;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin: 14px 0 18px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.1rem, 3vw, 3rem);
    line-height: 0.85;
    color: var(--green-dark);
}

.metric a {
    color: var(--green);
    font-size: 0.72rem;
    font-weight: 800;
    text-underline-offset: 4px;
}

.metric-accent {
    color: var(--surface);
    background: var(--red);
}

.metric-accent span,
.metric-accent strong,
.metric-accent a {
    color: var(--surface);
}

.customer-layout,
.subscription-layout,
.payment-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.75fr);
    gap: 32px;
    align-items: start;
}

.subscription-layout,
.payment-layout {
    grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.6fr);
}

.data-panel {
    min-width: 0;
    background: var(--surface);
    border: 2px solid var(--green-dark);
    box-shadow: 7px 7px 0 var(--green-light);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 76px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
}

h3 {
    margin: 0;
    font-size: 1.08rem;
    color: var(--green-dark);
}

.panel-header p,
.create-panel > p,
.subscription-form > div + p,
.payment-form > div + p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.5;
}

.table-scroll {
    max-height: 420px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--red) var(--surface);
    scrollbar-width: thin;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 13px 18px;
    color: var(--surface);
    background: var(--green-dark);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

td {
    padding: 16px 18px;
    border-bottom: 1px solid #dde1dc;
    font-size: 0.8rem;
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover td {
    background: var(--green-light);
}

.customer-name {
    font-weight: 800;
    color: var(--green-dark);
}

.muted-cell {
    color: var(--muted);
}

.action-cell {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

.danger-action-button {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 28px;
    padding: 0;
    color: transparent;
    background: var(--red);
    border: 2px solid var(--red);
    border-radius: 50%;
    font-size: 0;
}

.danger-action-button::before,
.danger-action-button::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 2px;
    background: var(--surface);
    border-radius: 999px;
    transform-origin: center;
}

.danger-action-button::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.danger-action-button::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.danger-action-button:not(:disabled):hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}

.danger-action-button:disabled {
    cursor: wait;
    opacity: 0.58;
}

.danger-action-button.inactive-action-button:disabled {
    background: #9da8a0;
    border-color: #9da8a0;
    cursor: default;
    opacity: 0.8;
}

.inline-action-button {
    min-height: 34px;
    padding: 0 12px;
    color: var(--surface);
    background: var(--green);
    border: 2px solid var(--green);
    font-size: 0.68rem;
    font-weight: 900;
}

.inline-action-button:not(:disabled):hover {
    color: var(--green-dark);
    background: var(--surface);
}

.inline-action-button:disabled {
    cursor: default;
    opacity: 0.54;
}

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

.create-panel,
.subscription-form,
.payment-form {
    display: grid;
    gap: 10px;
    padding: 24px;
    color: var(--surface);
    background: var(--green-dark);
    border: 3px solid var(--green-dark);
    box-shadow: 7px 7px 0 var(--red);
}

.create-panel h3,
.subscription-form h3,
.payment-form h3 {
    color: var(--surface);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.5rem;
}

.create-panel > p:not(.panel-kicker),
.subscription-form p:not(.panel-kicker),
.payment-form p:not(.panel-kicker) {
    color: #abc2b3;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 12px;
}

label {
    margin-top: 10px;
    color: var(--green-light);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

input,
select {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 0 14px;
    color: var(--ink);
    background: var(--surface);
    border: 2px solid #74907d;
    border-radius: 0;
    outline: 0;
}

select {
    appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23073f25' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

input:focus,
select:focus {
    border-color: var(--red);
    box-shadow: 4px 4px 0 var(--red);
}

.primary-button,
.secondary-button {
    min-height: 44px;
    border-radius: 0;
    font-weight: 800;
    transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.primary-button {
    margin-top: 16px;
    padding: 0 18px;
    color: var(--surface);
    background: var(--red);
    border: 2px solid var(--red);
}

.primary-button:hover {
    color: var(--green-dark);
    background: var(--surface);
    border-color: var(--surface);
    transform: translateY(-2px);
}

.secondary-button {
    padding: 0 16px;
    color: var(--green-dark);
    background: transparent;
    border: 2px solid var(--green-dark);
}

.secondary-button:hover {
    color: var(--surface);
    background: var(--green-dark);
}

.primary-button:disabled,
.secondary-button:disabled {
    cursor: wait;
    opacity: 0.58;
    transform: none;
}

.form-status {
    min-height: 18px;
    margin: 4px 0 0;
    color: var(--green-light);
    font-size: 0.72rem;
    line-height: 1.45;
}

.form-status.is-error {
    color: #ffb5b8;
}

.form-status.is-success {
    color: #8be5a4;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgb(7 24 16 / 64%);
}

.modal-panel {
    width: min(100%, 430px);
    padding: 26px;
    color: var(--ink);
    background: var(--surface);
    border: 3px solid var(--green-dark);
    box-shadow: 9px 9px 0 var(--red);
}

.modal-panel h2 {
    font-size: clamp(1.45rem, 4vw, 2rem);
}

.modal-panel p:not(.panel-kicker) {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.55;
}

.modal-panel strong {
    color: var(--green-dark);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.modal-actions .primary-button,
.modal-actions .secondary-button {
    margin-top: 0;
}

.modal-status {
    min-height: 18px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.45;
}

.modal-status.is-error {
    color: var(--red-dark);
}

.modal-status.is-success {
    color: var(--green);
}

.danger-button:hover {
    color: var(--surface);
    background: var(--red-dark);
    border-color: var(--red-dark);
}

.catalogue-section {
    background: var(--green-light);
}

.plan-list {
    display: grid;
    border-top: 3px solid var(--green-dark);
}

.plan {
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1.2fr) minmax(300px, 1.5fr);
    align-items: center;
    gap: 24px;
    min-height: 120px;
    padding: 20px 0;
    border-bottom: 1px solid #aabcae;
}

.plan:last-child {
    border-bottom: 3px solid var(--green-dark);
}

.plan-index {
    display: block;
    margin-bottom: 8px;
    color: var(--red);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.66rem;
    font-weight: 800;
}

.plan h3 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.4rem, 2.4vw, 2rem);
    letter-spacing: -0.035em;
}

.plan-description {
    margin: 0;
    color: #4e6457;
    font-size: 0.83rem;
    line-height: 1.6;
}

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

.price-option {
    min-width: 0;
    padding: 13px;
    background: var(--surface);
    border-left: 5px solid var(--green);
}

.price-option.yearly {
    border-left-color: var(--red);
}

.price-option span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.price-option strong {
    color: var(--green-dark);
    font-size: 1rem;
}

.status-badge {
    display: inline-block;
    padding: 5px 8px;
    color: var(--green-dark);
    background: var(--green-light);
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.status-badge.cancelled,
.status-badge.past-due {
    color: var(--red-dark);
    background: var(--red-light);
}

.status-badge.incomplete {
    color: #6b4f00;
    background: #f4e4a9;
}

.status-badge.requires-confirmation {
    color: #6b4f00;
    background: #f4e4a9;
}

.status-badge.processing {
    color: #0d4f68;
    background: #d7edf6;
}

.status-badge.succeeded {
    color: var(--green-dark);
    background: var(--green-light);
}

.status-badge.failed {
    color: var(--red-dark);
    background: var(--red-light);
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 26px clamp(28px, 5vw, 80px);
    color: var(--green-light);
    background: var(--green-dark);
    font-size: 0.7rem;
    font-weight: 700;
}

[hidden] {
    display: none !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 4px solid var(--red-light);
    outline-offset: 3px;
}

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 210px;
    }

    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric:nth-child(2) {
        border-right: 0;
    }

    .metric:nth-child(-n + 2) {
        border-bottom: 1px solid var(--line);
    }

    .customer-layout,
    .subscription-layout,
    .payment-layout {
        grid-template-columns: 1fr;
    }

    .subscription-form,
    .payment-form {
        grid-row: 1;
    }

    .plan {
        grid-template-columns: minmax(180px, 0.8fr) minmax(240px, 1.4fr);
    }

    .plan-description {
        grid-column: 1;
    }

    .price-options {
        grid-column: 2;
        grid-row: 1 / span 2;
    }
}

@media (max-width: 760px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        position: sticky;
        top: 0;
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        width: 100%;
        padding: 10px 14px;
        border-right: 0;
        border-bottom: 4px solid var(--red);
    }

    .brand {
        font-size: 0;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }

    nav {
        display: flex;
        justify-content: flex-end;
        gap: 2px;
        margin: 0;
    }

    .nav-link {
        display: block;
        min-height: auto;
        padding: 10px 8px;
        border-left: 0;
        border-bottom: 2px solid transparent;
        font-size: 0.68rem;
    }

    .nav-link span {
        display: none;
    }

    .nav-link:hover,
    .nav-link.is-active {
        border-bottom-color: var(--red);
    }

    .health-check {
        display: none;
    }

    main {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        min-height: 76px;
        padding-top: 12px;
    }

    .topbar-note {
        display: none;
    }

    .section {
        padding-block: 44px;
    }

    .section-heading {
        align-items: start;
    }

    .section-heading > p {
        display: none;
    }

    .plan {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .plan-description,
    .price-options {
        grid-column: 1;
        grid-row: auto;
    }
}

@media (max-width: 520px) {
    nav .nav-link:first-child {
        display: none;
    }

    .topbar,
    .section,
    footer {
        padding-inline: 18px;
    }

    h1 {
        font-size: 1.65rem;
    }

    .section-heading {
        display: grid;
    }

    .secondary-button {
        width: 100%;
    }

    .modal-actions {
        display: grid;
    }

    .modal-actions .primary-button,
    .modal-actions .secondary-button {
        width: 100%;
    }

    .metrics {
        grid-template-columns: 1fr 1fr;
    }

    .metric {
        padding: 17px 14px;
    }

    .metric strong {
        font-size: 2.1rem;
    }

    .metric a {
        display: none;
    }

    .create-panel,
    .subscription-form,
    .payment-form {
        padding: 20px;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .price-options {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding-inline: 13px;
    }

    footer {
        display: grid;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
