:root {
    --white: #FFFFFF;
    --mint: #E2ECE2;
    --green: #5CB85C;
    --green-dark: #00892B;
    --ink: #202231;

    --radius: 12px;
    --shadow: 0 2px 8px rgba(32, 34, 49, 0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--white);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
                 Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.55;
    font-size: 16px;
}

a {
    color: var(--green-dark);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

code {
    background: var(--mint);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ----- Top bar ----- */
.topbar {
    background: var(--ink);
    color: var(--white);
}
.topbar .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    /* Slight opacity-hover so the click target feels alive. */
    transition: opacity 0.15s ease;
}
.brand:hover { opacity: 0.85; }
.brand-logo {
    height: 50px;
    width: auto;
    display: block;
}
.topbar-subtitle {
    color: var(--mint);
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

/* ----- Hero ----- */
.hero {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 32px;
    /* align-items: start so the progress card stays a fixed-size rectangle
       even if the hero-text grows (e.g. when the license is revealed). */
    align-items: start;
    margin: 40px 0 24px;
}
@media (max-width: 720px) {
    .hero { grid-template-columns: 1fr; }
}
.hero h1 {
    margin: 0 0 8px;
    font-size: 2rem;
    letter-spacing: -0.01em;
}
.hero-sub {
    margin: 0 0 20px;
    color: #4a4c5e;
}
.meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.meta-item {
    display: flex;
    flex-direction: column;
}
.meta-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b6e80;
}
.meta-value {
    font-weight: 600;
    font-size: 1.05rem;
}

.progress-card {
    background: var(--mint);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    box-shadow: var(--shadow);
    /* Fixed footprint so revealing the license never resizes this card. */
    min-height: 140px;
    box-sizing: border-box;
}
.progress-percent {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--green-dark);
    line-height: 1;
}
.progress-bar {
    background: var(--white);
    height: 10px;
    border-radius: 999px;
    margin: 12px 0 10px;
    overflow: hidden;
}
.progress-fill {
    background: linear-gradient(90deg, var(--green), var(--green-dark));
    height: 100%;
    /* Start at 0 so the bar reads correctly before JS runs.
       The page CSP blocks the th:style="width:..." attribute, so the
       initial width has to come from CSS or JS, not inline markup. */
    width: 0;
    border-radius: 999px;
    transition: width 0.3s ease;
}
.progress-count {
    color: var(--ink);
    font-size: 0.9rem;
}

/* ----- Resources bar (support + docs + sandbox) ----- */
.resources {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    margin: 8px 0 32px;
    padding: 14px 20px;
    background: var(--mint);
    border-radius: var(--radius);
    justify-content: center;
}
.resource-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.resource-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #4a4c5e;
    font-weight: 600;
}
.resource-value {
    font-weight: 500;
    color: var(--green-dark);
    font-size: 0.95rem;
    text-decoration: none;
}
.resource-value:hover { text-decoration: underline; }

/* ----- Cards / sections ----- */
.card {
    background: var(--white);
    border: 1px solid var(--mint);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin: 0 0 20px;
    box-shadow: var(--shadow);
}
.card-header { margin-bottom: 16px; }
.card h2 {
    margin: 0 0 6px;
    font-size: 1.25rem;
    color: var(--ink);
}
.card-summary {
    margin: 0;
    color: #4a4c5e;
}

/* ----- Tasks ----- */
.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.task {
    border-top: 1px solid var(--mint);
    padding: 14px 0;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.task:first-child { border-top: none; }

.task .task-main {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.task-doc-link {
    flex-shrink: 0;
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.task-doc-link:hover { text-decoration: underline; }

.task-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--green);
    border-radius: 6px;
    margin-top: 2px;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
    background: var(--white);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.task-checkbox:hover { border-color: var(--green-dark); }
.task-checkbox:checked {
    background: var(--green-dark);
    border-color: var(--green-dark);
}
.task-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 12px;
    border: solid var(--white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.task-checkbox:disabled { opacity: 0.5; cursor: wait; }

.task-body {
    display: flex;
    flex-direction: column;
}
.task-title {
    font-weight: 600;
    color: var(--ink);
}
.task-checkbox:checked ~ .task-body .task-title {
    color: var(--green-dark);
    text-decoration: line-through;
    text-decoration-color: rgba(0, 137, 43, 0.4);
}
.task-desc {
    color: #4a4c5e;
    font-size: 0.93rem;
    margin-top: 2px;
}
.task-examples {
    margin: 6px 0 0;
    padding-left: 18px;
    color: #4a4c5e;
    font-size: 0.88rem;
    list-style: disc;
}
.task-examples li {
    line-height: 1.5;
    padding-left: 2px;
}
.task-checkbox:checked ~ .task-body .task-examples {
    color: #6b6e80;
}

/* Saving / saved indicator */
.task.saving { opacity: 0.7; }
.task.error .task-title { color: #b00020; }

/* ----- License key (hero meta) ----- */
.license-meta {
    /* Let the license item grow / wrap onto its own line when narrow. */
    flex-grow: 1;
    min-width: 0;
}
.meta-license-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    flex-wrap: wrap;
}
.license-meta .license-key {
    /* Hidden by default — the key box appears only after "Show" is clicked. */
    display: none;
    background: var(--mint);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.95rem;
    user-select: all;
    word-break: break-all;
    line-height: 1.4;
    color: var(--ink);
}
.license-meta.revealed .license-key {
    display: inline-block;
    animation: license-fade-in 0.2s ease;
}
@keyframes license-fade-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.meta-license-row .btn-secondary {
    padding: 4px 12px;
    font-size: 0.8rem;
    min-width: 56px;
}

/* ----- License generate (empty-state) ----- */
.license-meta-empty {
    flex-grow: 1;
    min-width: 0;
}
.license-warning {
    background: #FFF8E1;
    border-left: 4px solid #F0A020;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--ink);
    max-width: 460px;
}
.license-warning strong { color: var(--ink); }
.license-warning-date { font-weight: 600; }
.license-generate-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ----- Admin: topbar actions ----- */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}
.btn-link {
    background: none;
    border: none;
    color: var(--mint);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 8px;
    text-decoration: underline;
}
.btn-link:hover { color: var(--white); }
.inline { display: inline; margin: 0; }

/* ----- Admin: login ----- */
.login-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 48px;
}
.login-card {
    max-width: 420px;
    width: 100%;
}

/* ----- Forms ----- */
.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
}
.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #4a4c5e;
    font-weight: 600;
}
.field input {
    border: 1px solid var(--mint);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
    outline: none;
    border-color: var(--green-dark);
    box-shadow: 0 0 0 3px rgba(0, 137, 43, 0.15);
}

.btn {
    /* Use inline-flex + box-sizing so <a> and <button> render at the
       same height regardless of whether they have a border. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}
.btn-primary {
    background: var(--green-dark);
    color: var(--white);
    border-color: var(--green-dark);
}
.btn-primary:hover { background: #006b21; border-color: #006b21; }
.btn-secondary {
    background: var(--white);
    color: var(--green-dark);
    border-color: var(--green-dark);
    padding: 6px 12px;
    font-size: 0.85rem;
}
.btn-secondary:hover { background: var(--mint); text-decoration: none; }
.btn-danger {
    background: var(--white);
    color: #b00020;
    border-color: #e0c4c9;
    padding: 6px 12px;
    font-size: 0.85rem;
}
.btn-danger:hover { background: #fbeaee; border-color: #b00020; }

.btn-login {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    padding: 12px 18px;
}
.btn-login:hover { text-decoration: none; color: var(--white); }

/* ----- Alerts ----- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 0 0 16px;
}
.alert-ok {
    background: var(--mint);
    color: var(--ink);
    border-left: 4px solid var(--green-dark);
}
.alert-error {
    background: #fbeaee;
    color: #7a0014;
    border-left: 4px solid #b00020;
}
.alert code {
    background: var(--white);
    word-break: break-all;
    cursor: pointer;
}

/* ----- Admin: customer table ----- */
.hero-admin { grid-template-columns: 1fr; }
/* ----- Admin customer list (grid-based card per customer) ----- */
.customer-list { width: 100%; }

.customer-list-header,
.customer-card-top {
    display: grid;
    /* Customer | POC end | Created/Modified | Progress */
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.8fr) minmax(0, 1.2fr);
    gap: 16px;
    align-items: start;
}
.customer-list-header {
    padding: 12px 0;
    border-bottom: 2px solid var(--mint);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b6e80;
    font-weight: 600;
}

.customer-card {
    padding: 14px 0;
    border-bottom: 1px solid var(--mint);
}
.customer-card:last-child { border-bottom: none; }

.customer-card-bottom {
    margin-top: 14px;
    display: grid;
    /* License box on the left grows to fill, action buttons size to content. */
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
}
.cell-license-box {
    background: var(--mint);
    border-radius: 8px;
    padding: 10px 12px;
    min-width: 0;
}
.cell-license-label {
    margin: 0 0 4px;
}
.cell-license-key {
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--ink);
    word-break: break-all;
    overflow-wrap: anywhere;
}
.cell-license-empty { font-style: italic; }
.cell-progress { min-width: 0; }

.cell-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.cell-actions .inline { display: inline-flex; }
.cell-actions .btn { margin: 0; }

@media (max-width: 720px) {
    .customer-list-header { display: none; }
    .customer-card-top,
    .customer-card-bottom {
        grid-template-columns: 1fr;
    }
    .cell-actions { justify-content: flex-start; }
}
.cell-strong { font-weight: 600; }
.cell-sub {
    color: #6b6e80;
    font-size: 0.85rem;
    margin-top: 2px;
}
.cell-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    word-break: break-all;
}
.cell-license { margin-top: 6px; }
.cell-license .cell-sub { margin-top: 0; margin-bottom: 2px; }
.cell-license-key {
    display: block;
    background: var(--mint);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--ink);
    word-break: break-all;
    overflow-wrap: anywhere;
    max-width: 100%;
    box-sizing: border-box;
}
.link-sub {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.85rem;
}
.actions-cell {
    white-space: nowrap;
}
.actions-cell .btn,
.actions-cell .btn-secondary,
.actions-cell .btn-danger {
    margin-right: 4px;
    margin-bottom: 4px;
    display: inline-block;
    text-decoration: none;
}
.actions-cell .inline { display: inline-block; }
.form-actions-edit {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}
.form-actions-edit .btn-secondary { text-decoration: none; }
.table-progress {
    min-width: 110px;
}
.table-progress-bar {
    background: var(--mint);
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 4px;
}
.table-progress-fill {
    background: linear-gradient(90deg, var(--green), var(--green-dark));
    height: 100%;
    /* JS sets the width from data-percent; default to 0 so empty progress
       reads as empty even before JS runs (CSP blocks inline styles). */
    width: 0;
    transition: width 0.3s ease;
}

/* ----- Footer ----- */
.page-footer {
    color: #6b6e80;
    font-size: 0.85rem;
    text-align: center;
    margin: 32px 0 48px;
}
