:root {
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-alt: #f8fafe;
    --text: #111a2f;
    --muted: #60708f;
    --border: #d6dfef;
    --primary: #2166f3;
    --primary-strong: #154ed0;
    --success: #1a9a59;
    --danger: #cc2f2f;
    --warning: #d17b13;
    --shadow: 0 18px 40px rgba(30, 66, 140, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

.light-body {
    min-height: 100vh;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.auth-card-wide {
    max-width: 640px;
}

.signup-card {
    max-height: calc(100vh - 42px);
    overflow: auto;
}

.logo-section {
    text-align: center;
    margin-bottom: 18px;
}

.logo-section.compact {
    margin-bottom: 14px;
}

.logo-image {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.logo-section h1 {
    font-size: 27px;
    margin-top: 4px;
}

.tagline {
    color: var(--muted);
    margin-top: 4px;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.form-group {
    display: grid;
    gap: 6px;
}

.form-group label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.required-star {
    color: var(--danger);
    font-weight: 700;
}

.input-wrapper {
    position: relative;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    background: #fff;
    color: var(--text);
}

.input-wrapper input,
.input-wrapper select {
    padding-left: 38px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(33, 102, 243, 0.2);
    border-color: var(--primary);
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--muted);
    width: 30px;
    height: 30px;
    cursor: pointer;
}

.form-hint,
.muted-note {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.inline-error {
    color: var(--danger);
}

.inline-ok {
    color: var(--success);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.checkbox-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    color: var(--muted);
    font-size: 13px;
}

.checkbox-wrapper input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

.link {
    color: var(--primary);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.captcha-box {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 12px;
    background: var(--surface-alt);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

/* Lets the CAPTCHA row shrink on narrow screens so the image is not clipped (flex default min-width: auto). */
.captcha-main {
    flex: 1 1 200px;
    min-width: 0;
}

.captcha-image-wrap {
    width: 100%;
    max-width: min(100%, 300px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.captcha-image {
    display: block;
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #fff;
}

/* Avoid the broken-image icon flash when src is cleared after an error. */
.captcha-image:not([src]) {
    display: none;
}

.captcha-box .btn-sm {
    flex: 0 0 auto;
    align-self: center;
}

.captcha-answer-input {
    font-size: 16px;
}

.captcha-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

/* Stack label + image + Refresh so the button does not sit beside the image on narrow layouts. */
@media (max-width: 720px) {
    .captcha-box {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
    }

    .captcha-main {
        flex: 1 1 auto;
        width: 100%;
    }

    .captcha-box .btn-sm {
        align-self: stretch;
        width: 100%;
        justify-content: center;
    }

    .captcha-image-wrap {
        max-width: 100%;
    }
}

.hidden-honeypot {
    position: absolute;
    left: -99999px;
    opacity: 0;
    pointer-events: none;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-strong);
}

.btn-secondary {
    border-color: var(--border);
    background: #fff;
    color: var(--text);
}

.btn-ready {
    background: #0f9d58;
    border-color: #0f9d58;
    color: #fff;
}

.btn-ready:hover:not(:disabled) {
    background: #0b7f46;
    border-color: #0b7f46;
}

.btn-sm {
    font-size: 12px;
    padding: 8px 11px;
}

.btn-block {
    width: 100%;
}

.auth-footer {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

.message-box {
    display: none;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 12px;
}

.message-box.success {
    border: 1px solid #95dbb4;
    background: #effcf4;
    color: #166e3c;
}

.message-box.error {
    border: 1px solid #f3b7b2;
    background: #fff3f2;
    color: #9f2721;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 20px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 44px;
    height: 44px;
}

.brand-text h1 {
    font-size: 20px;
}

.brand-text p {
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-email {
    color: var(--muted);
    font-size: 13px;
    padding: 0 4px;
}

.account-chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-alt);
    padding: 7px 10px;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.account-chip.stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    border-radius: 12px;
}

.account-chip small {
    color: var(--text);
    font-size: 11px;
}

.dashboard-shell {
    max-width: 1280px;
    margin: 0 auto;
    padding: 22px;
    display: grid;
    gap: 18px;
}

.filters-panel {
    display: grid;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filters-panel.modern {
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding: 12px;
}

.input-group {
    display: grid;
    gap: 6px;
}

.input-group label {
    color: var(--muted);
    font-size: 12px;
}

.search-group {
    position: relative;
}

.search-group i {
    position: absolute;
    left: 12px;
    top: 38px;
    color: var(--muted);
}

.search-group input {
    padding-left: 34px;
}

.content-section {
    background: transparent;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    gap: 10px;
}

.section-subtitle {
    color: var(--muted);
    font-size: 12px;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
}

.app-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
    display: grid;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.app-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(36, 70, 140, 0.12);
}

.app-card-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 4px;
}

.app-card-title-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.app-card-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: flex-start;
}

.app-card-title {
    font-size: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 8px;
    color: var(--muted);
    font-size: 11px;
    margin-right: 6px;
}

.status-pill {
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border: 1px solid var(--border);
}

.status-pill.active {
    color: var(--success);
    border-color: #8ed8b0;
    background: #edf9f1;
}

.status-pill.inactive {
    color: var(--warning);
    border-color: #f3d6aa;
    background: #fff7ec;
}

.app-description {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.app-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-view {
    display: grid;
    gap: 12px;
}

.detail-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
    padding: 18px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-media {
    display: grid;
    gap: 8px;
    align-content: flex-start;
    justify-items: center;
    min-width: 88px;
}

.detail-logo {
    width: 76px;
    height: 76px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 6px;
}

.detail-main h2 {
    margin-bottom: 7px;
}

.meta-row {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-actions {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.offer-grid {
    margin-top: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.offer-card {
    border: 2px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 14px;
    display: grid;
    gap: 10px;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}

.offer-card .price-stack {
    justify-items: start;
}

.offer-card:hover {
    border-color: #9ab4f7;
    transform: translateY(-1px);
}

.offer-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(33, 102, 243, 0.18);
}

.offer-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.offer-mode-pill {
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    color: #334155;
    background: #f8fafc;
}

.offer-mode-pill.online {
    color: #1e40af;
    border-color: #c7d2fe;
    background: #eef2ff;
}

.offer-mode-pill.offline {
    color: #14532d;
    border-color: #bbf7d0;
    background: #ecfdf5;
}

.offer-plan-name {
    font-size: 12px;
    color: var(--muted);
}

.offer-term {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.offer-price .price-stack {
    justify-items: start;
}

.pack-cta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.active-tab {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background: #f3f7ff !important;
}

.settings-separator {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

.settings-subscriptions-list {
    display: grid;
    gap: 8px;
}

.settings-sub-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #fff;
    display: grid;
    gap: 4px;
}

.plan-grid {
    display: grid;
    gap: 10px;
}

.plan-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    display: grid;
    gap: 8px;
}

.plan-card-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.price-list {
    display: grid;
    gap: 6px;
}

.price-pill {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
    padding: 8px;
}

.empty-state {
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--muted);
    text-align: center;
    padding: 18px;
}

.empty-state i {
    font-size: 22px;
    margin-bottom: 6px;
}

.modal-shell {
    position: fixed;
    inset: 0;
    background: rgba(9, 15, 29, 0.45);
    display: grid;
    place-items: center;
    padding: 18px;
    z-index: 100;
}

.modal-shell[hidden] {
    display: none !important;
}

.modal-card {
    width: 100%;
    max-width: 620px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 34px 64px rgba(22, 40, 82, 0.24);
    overflow: hidden;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.modal-card.compact {
    max-width: 460px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 20px;
}

.modal-body {
    padding: 14px 16px;
    display: grid;
    gap: 12px;
    overflow: auto;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.promo-row {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr auto;
    align-items: center;
}

.radio-list {
    display: grid;
    gap: 8px;
}

.radio-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    background: #fff;
    text-align: left;
}

.radio-item.active {
    border-color: var(--primary);
    background: #f3f7ff;
    box-shadow: inset 0 0 0 1px rgba(33, 102, 243, 0.2);
}

.price-stack {
    display: inline-grid;
    justify-items: end;
    line-height: 1.1;
    gap: 3px;
}

.price-main {
    font-size: 14px;
}

.price-original-row {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    font-size: 11px;
}

.price-original {
    color: #6b7280;
    text-decoration: line-through;
}

.price-discount-pill {
    color: #047857;
    font-weight: 600;
}

.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 120;
    display: grid;
    gap: 8px;
}

.toast {
    min-width: 260px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 10px 12px;
    box-shadow: var(--shadow);
    font-size: 13px;
}

.toast.success {
    border-color: #95dbb4;
}

.toast.error {
    border-color: #efb5ae;
}

.policy-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.policy-card {
    width: 100%;
    max-width: 900px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 24px;
    display: grid;
    gap: 16px;
}

.policy-header h1 {
    margin-bottom: 6px;
}

.policy-header p {
    color: var(--muted);
    font-size: 13px;
}

.policy-section h2 {
    margin-bottom: 6px;
    font-size: 17px;
}

.policy-section p {
    color: #2c3a53;
    line-height: 1.6;
    font-size: 14px;
}

@media (max-width: 980px) {
    .filters-panel.modern {
        grid-template-columns: 1fr;
    }

    .topbar {
        position: static;
    }

    .dashboard-shell {
        padding: 14px;
    }

    .auth-shell {
        padding: 14px;
    }
}

