/* MyTradeForge Account Portal */
:root {
    --ink: #111827;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --bg: #f9fafb;
    --card: #fff;
    --border: #e5e7eb;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header / nav --------------------------------------------------- */
.portal-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    font-weight: 700;
    color: var(--ink);
    font-size: 1.1rem;
}
.portal-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.92rem;
}
.portal-nav .navlink {
    color: var(--ink);
    text-decoration: none;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}
.portal-nav .navlink:hover { color: var(--accent); }
.portal-nav .navlink.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.portal-nav .who {
    color: var(--muted);
    border-left: 1px solid var(--border);
    padding-left: 20px;
}

/* Main + footer -------------------------------------------------- */
.portal-main {
    flex: 1;
    padding: 40px 24px;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}
.portal-footer {
    padding: 20px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}
.portal-footer strong { color: var(--accent); }

/* Auth card ------------------------------------------------------- */
.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 36px 28px;
    max-width: 420px;
    margin: 40px auto 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.auth-card h1 {
    font-size: 1.4rem;
    margin: 0 0 20px;
}
.auth-card label {
    display: block;
    margin-bottom: 14px;
}
.auth-card label > span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--ink);
}
.auth-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}
.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.auth-foot {
    margin: 18px 0 0;
    font-size: 0.88rem;
    color: var(--muted);
    text-align: center;
}

/* Buttons --------------------------------------------------------- */
.btn-primary {
    display: block;
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 6px;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* Alerts ---------------------------------------------------------- */
.alert {
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #fecaca;
}
.alert-success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

/* Profile / billing card ----------------------------------------- */
.profile-card,
.billing-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}
.profile-card h1, .billing-card h1 { margin: 0 0 6px; font-size: 1.4rem; }
.profile-card .muted, .billing-card .muted { margin: 0 0 22px; }

.profile-card fieldset, .billing-card fieldset {
    border: 0; padding: 0; margin: 0 0 24px;
}
.profile-card legend, .billing-card legend {
    font-weight: 600;
    padding: 0;
    margin: 0 0 12px;
}
.profile-card label, .billing-card label {
    display: block;
    margin-bottom: 14px;
}
.profile-card label > span, .billing-card label > span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
}
.profile-card input, .billing-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}
.profile-card input:focus, .billing-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* Wider card for the signup form */
.auth-card--wide { max-width: 560px; }

/* Two-up form rows on wider cards */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.form-row label { margin-bottom: 14px; }

/* "Optional" inline marker */
.opt {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.78rem;
}

/* Legal microcopy under the create-account button */
.legal-fine {
    margin: 14px 0 0;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
    text-align: center;
}
.legal-fine strong { color: var(--accent); }

/* Plan selection -------------------------------------------------- */
.portal-main:has(.plans-grid) { max-width: 1100px; }

.plans-intro {
    text-align: center;
    margin-bottom: 28px;
}
.plans-intro h1 { margin: 0 0 8px; font-size: 1.7rem; }
.plans-intro p  { margin: 0; color: var(--muted); }

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}
.plan-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px 24px;
    position: relative;
    display: flex;
    flex-direction: column;
}
.plan-card--featured {
    border-color: var(--accent);
    box-shadow: 0 4px 14px rgba(37,99,235,.10);
}
.plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 10px;
    border-radius: 12px;
}
.plan-card h2 { margin: 0 0 4px; font-size: 1.3rem; }
.plan-tagline { color: var(--muted); margin: 0 0 16px; font-size: 0.92rem; }
.plan-price { margin: 0 0 18px; }
.plan-price-amount { font-size: 2rem; font-weight: 700; color: var(--ink); }
.plan-price-period { color: var(--muted); font-size: 0.95rem; }
.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    flex: 1;
}
.plan-features li {
    font-size: 0.9rem;
    color: var(--ink);
    padding: 5px 0 5px 22px;
    position: relative;
}
.plan-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}
.plan-cta {
    width: 100%;
    text-decoration: none;
    text-align: center;
}

/* Checkout -------------------------------------------------------- */
.portal-main:has(.checkout-grid) { max-width: 980px; }

.checkout-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 28px;
    align-items: start;
}
@media (max-width: 800px) {
    .checkout-grid { grid-template-columns: 1fr; }
}
.checkout-main {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}
.checkout-main h1 { margin: 0 0 18px; font-size: 1.4rem; }
.checkout-main fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 24px;
}
.checkout-main legend {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0;
    margin: 0 0 12px;
}
.checkout-main label > span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0 0 6px;
}
.checkout-main input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}
.checkout-main input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.checkout-main label { display: block; margin-bottom: 14px; }

.subdomain-row {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.subdomain-row input { border: 0; flex: 1; }
.subdomain-row input:focus { box-shadow: none; }
.subdomain-suffix {
    background: var(--bg);
    padding: 10px 14px;
    color: var(--muted);
    font-size: 0.9rem;
    border-left: 1px solid var(--border);
    white-space: nowrap;
}

.btn-large { padding: 14px 16px; font-size: 1rem; }

.checkout-summary {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.checkout-summary h2 { margin: 0 0 16px; font-size: 1.05rem; }
.summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.95rem;
}
.summary-features {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}
.summary-features li {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 3px 0;
}
.summary-totals {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin: 0 0 12px;
    font-size: 1rem;
}
.summary-renew {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

/* Welcome --------------------------------------------------------- */
.welcome-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    text-align: center;
}
.welcome-card h1 { margin: 0 0 12px; font-size: 1.5rem; }
.welcome-card p  { color: var(--muted); margin: 0 0 16px; }

.creds {
    text-align: left;
    background: var(--bg);
    border-radius: 8px;
    padding: 18px 22px;
    margin: 20px 0;
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 8px 16px;
}
.creds dt { font-weight: 600; font-size: 0.88rem; }
.creds dd { margin: 0; font-size: 0.92rem; word-break: break-all; }
.creds code {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.88rem;
}

.welcome-next { margin: 24px 0 16px; }
.welcome-next .btn-primary { display: inline-block; max-width: 280px; text-decoration: none; }

progress {
    width: 100%;
    height: 6px;
    margin-top: 24px;
}

/* Dashboard ------------------------------------------------------- */
.portal-main:has(.dash-greeting) { max-width: 980px; }

.dash-greeting { margin-bottom: 28px; }
.dash-greeting h1 { margin: 0 0 4px; font-size: 1.7rem; }
.dash-greeting .muted { color: var(--muted); margin: 0; font-size: 0.95rem; }

.dash-section { margin-bottom: 32px; }
.dash-section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
}
.dash-section-head h2 { margin: 0; font-size: 1.05rem; }

.btn-link {
    color: var(--accent);
    font-size: 0.88rem;
    text-decoration: none;
    font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

/* Empty state */
.dash-empty {
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 32px;
    text-align: center;
}
.dash-empty h2 { margin: 0 0 8px; font-size: 1.25rem; }
.dash-empty p  { color: var(--muted); margin: 0 0 24px; }
.dash-empty-cta {
    display: inline-block;
    text-decoration: none;
    max-width: 280px;
}

/* Service cards */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}
.service-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}
.service-card header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}
.service-card header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.service-url {
    margin: 6px 0 14px;
    font-size: 0.88rem;
    word-break: break-all;
}
.service-meta {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 6px 14px;
    margin: 12px 0;
    font-size: 0.88rem;
}
.service-meta dt {
    color: var(--muted);
}
.service-meta dd { margin: 0; }
.service-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.service-actions .btn-sm {
    width: auto;
    padding: 6px 12px;
    font-size: 0.85rem;
    display: inline-block;
    text-decoration: none;
}

/* Status pills */
.status-pill {
    display: inline-block;
    padding: 2px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    text-transform: capitalize;
    border: 1px solid;
}
.status-pill--active  { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.status-pill--paid    { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.status-pill--pending,
.status-pill--unpaid  { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.status-pill--suspended { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.status-pill--cancelled,
.status-pill--terminated { color: #4b5563; background: #f3f4f6; border-color: #d1d5db; }

.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    margin-left: 4px;
}
.badge-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Billing-specific bits */
.billing-h2 { font-size: 1.05rem; margin: 28px 0 12px; }
.paymethod-list { list-style: none; padding: 0; margin: 0; font-size: 0.92rem; }
.paymethod-list li {
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.paymethod-list code {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.88rem;
}
.card-type { font-weight: 600; }

.card-replace {
    margin: 12px 0 28px;
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 16px;
}
.card-replace summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 500;
}
.card-replace summary:hover { text-decoration: underline; }
.card-replace form { margin-top: 18px; }

/* Service-manage page -------------------------------------------- */
.service-manage h1 { margin: 4px 0 4px; font-size: 1.5rem; }
.back-link {
    display: inline-block;
    font-size: 0.88rem;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 6px;
}
.back-link:hover { color: var(--accent); }

.manage-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-top: 22px;
}
.manage-section h2 { margin: 0 0 8px; font-size: 1.05rem; }
.manage-section p  { margin: 0 0 14px; }

.plan-switch {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.plan-switch-option {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.plan-switch-option:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}
.plan-switch-option strong { display: block; font-size: 0.95rem; }

.danger-zone { border-color: #fecaca; }
.danger-zone h2 { color: #b91c1c; }
.btn-danger-link {
    color: #b91c1c;
    font-weight: 500;
    cursor: pointer;
}
.btn-danger-link:hover { text-decoration: underline; }
.cancel-form { margin-top: 18px; }
.cancel-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 14px;
}
.btn-danger {
    background: #b91c1c;
    color: #fff;
    border: 1px solid #b91c1c;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
}
.btn-danger:hover { background: #991b1b; }

/* Manage page enhancements --------------------------------------- */
.quick-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    margin: 0 0 16px;
}
.quick-actions .btn-sm {
    width: auto;
    padding: 8px 14px;
    font-size: 0.88rem;
    text-decoration: none;
    display: inline-block;
}

.meta-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 6px 16px;
    margin: 14px 0 0;
    font-size: 0.9rem;
}
.meta-grid dt { color: var(--muted); }
.meta-grid dd { margin: 0; word-break: break-all; }
.manage-recents { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 14px 0 0;
}
.stat-cell {
    background: var(--bg);
    border-radius: 10px;
    padding: 16px 18px;
}
.stat-num {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.1;
}
.stat-num-sub {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--muted);
}
.stat-label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Support / tickets ---------------------------------------------- */
.portal-main:has(.support-list) { max-width: 980px; }
.portal-main:has(.ticket-view)  { max-width: 800px; }
.portal-main:has(.ticket-new)   { max-width: 720px; }

.support-new-cta {
    display: inline-block;
    width: auto;
    padding: 8px 14px;
    text-decoration: none;
    font-size: 0.88rem;
}

.ticket-table {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}
.ticket-table th, .ticket-table td {
    padding: 10px 16px;
    text-align: left;
}
.ticket-table thead th {
    background: var(--bg);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.ticket-table tbody tr + tr td { border-top: 1px solid var(--border); }

/* Single ticket view */
.ticket-view, .ticket-new {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}
.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    margin: 4px 0 4px;
}
.ticket-header h1 { margin: 0; font-size: 1.3rem; }
.ticket-meta { margin: 0 0 18px; font-size: 0.86rem; }

.thread {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}
.thread-msg {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    background: #fff;
}
.thread-msg--staff {
    background: #f7fafe;
    border-color: #cfe0fb;
}
.thread-msg header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    font-size: 0.85rem;
}
.msg-from { font-weight: 600; }
.msg-when { font-size: 0.82rem; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; font-size: 0.93rem; }

.ticket-reply textarea, .ticket-new textarea, .ticket-new input, .ticket-new select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
}
.ticket-reply textarea:focus,
.ticket-new textarea:focus, .ticket-new input:focus, .ticket-new select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.ticket-reply label, .ticket-new label { display:block; margin-bottom:14px; }
.ticket-reply label > span, .ticket-new label > span {
    display:block; margin-bottom:6px; font-size:0.85rem; font-weight:500;
}

.form-row-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 6px;
}
.form-row-actions .btn-primary { width: auto; padding: 10px 18px; }
.ticket-closed-note {
    background: var(--bg);
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 0.9rem;
}

/* Custom-domain card row */
.service-url-alt {
    font-size: 0.82rem;
    margin: -8px 0 12px;
}

/* Field hint copy under a tier-aware input */
.hint {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 6px 0 0;
    line-height: 1.55;
}
.hint code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.82rem;
}
.hint strong { color: var(--ink); }

.cd-form {
    margin-top: 14px;
    display: flex;
    gap: 12px;
    align-items: end;
}
.cd-form label { flex: 1; margin: 0; }
.cd-form .btn-primary { width: auto; padding: 10px 16px; white-space: nowrap; }

/* Promo status feedback inline under the code input */
.promo-status {
    margin: 8px 0 0;
    font-size: 0.85rem;
}
.promo-status--ok  { color: #047857; }
.promo-status--bad { color: #b91c1c; }

/* Invoice table */
.invoice-table {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}
.invoice-table th, .invoice-table td {
    padding: 10px 16px;
    text-align: left;
}
.invoice-table thead th {
    background: var(--bg);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.invoice-table tbody tr + tr td {
    border-top: 1px solid var(--border);
}

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