:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #222222;
    --muted: #777777;
    --border: #e5e5e5;
    --primary: #222222;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ==========================================
   Guided onboarding wizard
   ========================================== */

.setup-page {
    min-height: 100vh;
    padding: 48px 24px 72px;
}

.setup-shell {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

.setup-brand {
    margin-bottom: 26px;
    text-align: center;
}

.setup-brand h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: 0.05em;
}

.setup-brand p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.setup-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
}

.setup-progress-bar {
    flex: 1;
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: #dedede;
}

.setup-progress-value {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.setup-progress-text {
    min-width: 74px;
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.setup-card {
    padding: 34px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.setup-card h2 {
    margin: 0 0 10px;
    font-size: 24px;
    line-height: 1.4;
}

.setup-lead {
    margin: 0 0 28px;
    color: #666666;
    font-size: 15px;
    line-height: 1.8;
}

.provider-grid {
    display: grid;
    gap: 14px;
}

.provider-option {
    position: relative;
    display: block;
}

.provider-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.provider-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px;
    border: 2px solid #dddddd;
    border-radius: 10px;
    background: #ffffff;
    transition: border-color 0.15s, background 0.15s;
}

.provider-option input:checked + .provider-content {
    border-color: #222222;
    background: #fafafa;
}

.provider-option:not(.disabled) .provider-content {
    cursor: pointer;
}

.provider-option:not(.disabled) .provider-content:hover {
    border-color: #777777;
}

.provider-option.disabled .provider-content {
    background: #f4f4f4;
    color: #999999;
}

.provider-name {
    display: block;
    margin-bottom: 5px;
    font-size: 18px;
    font-weight: bold;
}

.provider-description {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.provider-badge {
    flex: 0 0 auto;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eeeeee;
    font-size: 11px;
    font-weight: bold;
}

.setup-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.setup-actions .primary-button {
    flex: 1;
}

.setup-back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 108px;
    padding: 12px 16px;
    border: 1px solid #cccccc;
    border-radius: 6px;
    background: #ffffff;
    color: #333333;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
}

.guide-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.guide-list li {
    position: relative;
    margin-top: 12px;
    padding: 14px 16px 14px 42px;
    border-radius: 8px;
    background: #f7f7f7;
    color: #555555;
    font-size: 14px;
    line-height: 1.7;
}

.guide-list li::before {
    position: absolute;
    top: 15px;
    left: 16px;
    content: "✓";
    color: #222222;
    font-weight: bold;
}

.security-notice {
    margin: 22px 0 0;
    padding: 15px 16px;
    border-left: 4px solid #8a6723;
    border-radius: 4px 8px 8px 4px;
    background: #fff9ed;
    color: #624a1c;
    font-size: 13px;
    line-height: 1.75;
}

.wizard-field input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #bbbbbb;
    border-radius: 7px;
    background: #ffffff;
    font-size: 17px;
    outline: none;
}

.wizard-field input:focus {
    border-color: #333333;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.wizard-field label {
    display: block;
    margin-bottom: 9px;
    font-size: 14px;
    font-weight: bold;
}

.test-result {
    padding: 24px;
    border-radius: 10px;
    text-align: center;
}

.test-result.success {
    background: #eef8f1;
    color: #27653d;
}

.test-result.failed {
    background: #fff0f0;
    color: #8b2525;
}

.test-result-mark {
    display: block;
    margin-bottom: 10px;
    font-size: 32px;
    font-weight: bold;
}

.test-result h3 {
    margin: 0 0 8px;
    font-size: 19px;
}

.test-result p {
    margin: 0;
    font-size: 14px;
    line-height: 1.7;
}

@media (max-width: 600px) {
    .setup-page {
        padding: 28px 16px 48px;
    }

    .setup-card {
        padding: 26px 20px;
    }

    .setup-card h2 {
        font-size: 21px;
    }

    .provider-content,
    .setup-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .setup-back-link {
        width: 100%;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        Arial,
        "Hiragino Kaku Gothic ProN",
        "Yu Gothic",
        sans-serif;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

/* ==========================================
   Login
   ========================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 560px;
}

.login-brand {
    margin-bottom: 24px;
    text-align: center;
}

.login-brand h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: 0.04em;
}

.login-brand p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.login-card {
    padding: 32px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-card h2 {
    margin: 0 0 28px;
    font-size: 20px;
}

.google-login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 320px;
    min-height: 40px;
    margin: 0 0 20px;
    padding: 8px 12px;
    border: 1px solid #747775;
    border-radius: 4px;
    background: #ffffff;
    color: #1f1f1f;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.google-login-button:hover {
    background: #f7f8f8;
}

.login-legal {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin: 24px 0 0;
    font-size: 14px;
}

.login-legal a {
    color: #333;
}

.form-field {
    margin-bottom: 24px;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cccccc;
    border-radius: 6px;
    background: #ffffff;
    font-size: 16px;
    outline: none;
}

.form-field input:focus,
.form-field select:focus {
    border-color: #777777;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.form-field select:disabled {
    background: #f3f3f3;
    color: #999999;
    cursor: not-allowed;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 18px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
}

.primary-button:hover {
    opacity: 0.88;
}

.error-message {
    margin: 0 0 20px;
    padding: 12px 14px;
    border-radius: 6px;
    background: #fff0f0;
    color: #8b2525;
    font-size: 14px;
    line-height: 1.5;
}

.setup-introduction,
.form-note {
    margin: -12px 0 26px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.75;
}

.setup-account {
    margin: -12px 0 26px;
    padding: 12px 14px;
    border-radius: 6px;
    background: #f7f7f7;
    color: #555555;
    font-size: 13px;
    line-height: 1.6;
}

.setup-step {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 600px) {
    .login-page {
        align-items: flex-start;
        padding-top: 80px;
    }

    .login-card {
        padding: 24px;
    }

    .login-brand h1 {
        font-size: 24px;
    }
}

/* ==========================================
   Application Header
   ========================================== */

.app-header {
    margin-bottom: 32px;
}

.app-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.app-brand {
    margin: 0;
    font-size: 26px;
    letter-spacing: 0.04em;
}

.app-navigation {
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-navigation a,
.logout-button {
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #555;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.app-navigation a:hover,
.logout-button:hover {
    background: #eaeaea;
    color: #222;
}

.app-navigation a.active {
    background: #222;
    color: #fff;
}

.app-navigation a.app-nav-purchase {
    background: #1b8a4a;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

.app-navigation a.app-nav-purchase:hover,
.app-navigation a.app-nav-purchase.active {
    background: #146c3a;
    color: #fff;
}

.logout-form {
    margin: 0 0 0 8px;
    padding-left: 8px;
    border-left: 1px solid #ddd;
}

.page-heading {
    margin: 28px 0 0;
}

.page-heading h2 {
    margin: 0 0 6px;
    font-size: 22px;
}

.page-heading-meta {
    color: var(--muted);
    font-size: 14px;
}

.settings-page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
}

.settings-page-heading h2 {
    margin: 0;
}

.settings-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin: 28px 0 24px;
}

.settings-heading-row h2 {
    margin: 0 0 6px;
    font-size: 22px;
}

.settings-heading-row .description {
    margin: 0;
}

@media (max-width: 600px) {
    .settings-heading-row {
        flex-direction: column;
        gap: 16px;
    }
}

@media (max-width: 600px) {
    .settings-page-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }
}

@media (max-width: 700px) {
    .app-header-top {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-navigation {
        width: 100%;
        flex-wrap: wrap;
    }

    .logout-form {
        margin-left: auto;
    }
}

/* ==========================================
   Settings
   ========================================== */

.container,
.page-container {
    width: 100%;
    max-width: 760px;
    margin: 40px auto;
    padding: 0 20px;
}

.page-container > h1 {
    margin: 28px 0 8px;
    font-size: 24px;
}

.page-description {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.card {
    padding: 28px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.card-section + .card-section {
    margin-top: 30px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.card-section h2 {
    margin: 0 0 18px;
    font-size: 18px;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cccccc;
    border-radius: 6px;
    background: #ffffff;
    font-size: 16px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #777777;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.field-help {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.status-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafafa;
}

.status-label {
    margin-bottom: 5px;
    font-size: 15px;
    font-weight: bold;
}

.status-meta {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 8px;
    border-radius: 50%;
    background: #999999;
}

.status-dot.connected {
    background: #2f7d4a;
}

.status-dot.failed {
    background: #a33a3a;
}

.success-message {
    margin: 0 0 20px;
    padding: 12px 14px;
    border-radius: 6px;
    background: #eef8f1;
    color: #27653d;
    font-size: 14px;
    line-height: 1.5;
}

.action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
}

.action-row .save-button {
    min-width: 150px;
}

.save-button {
    padding: 11px 20px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    font-size: 15px;
    font-weight: bold;
}

.save-button:hover {
    opacity: 0.88;
}

.settings-card {
    margin-bottom: 20px;
}

.settings-card h2 {
    margin: 0 0 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 18px;
}

.settings-time-row,
.settings-option-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px 40px;
}

.settings-time-row .field,
.settings-option-row .field,
.settings-option-row .checkbox-field {
    margin-bottom: 20px;
}

.recipient-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.recipient-row input {
    width: 100%;
    max-width: 360px;
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid #cccccc;
    border-radius: 6px;
    background: #ffffff;
    color: #333333;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
}

.secondary-button:hover {
    background: #f5f5f5;
}

.settings-link {
    color: #333333;
    font-size: 14px;
}

.settings-save {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

@media (max-width: 600px) {
    .settings-time-row,
    .settings-option-row {
        display: block;
    }

    .recipient-row {
        align-items: stretch;
        flex-direction: column;
    }

    .recipient-row input {
        max-width: none;
    }

    .secondary-button {
        width: 100%;
    }

    .container,
    .page-container {
        margin: 24px auto;
        padding: 0 16px;
    }

    .card {
        padding: 22px 18px;
    }

    .status-panel,
    .action-row {
        align-items: stretch;
        flex-direction: column;
    }

    .action-row .save-button,
    .action-row .secondary-button {
        width: 100%;
    }
}

/* Error Page */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.error-container {
    width: 100%;
    max-width: 560px;
}

.error-brand {
    margin-bottom: 24px;
    text-align: center;
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 0.04em;
}

.error-card {
    padding: 40px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.error-code {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.08em;
}

.error-card h1 {
    margin: 0 0 16px;
    font-size: 22px;
}

.error-description {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
}

.error-back-button,
.error-home-button {
    min-width: 140px;
    padding: 11px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
}

.error-home-button {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.error-home-button:hover {
    opacity: 0.88;
}

@media (max-width: 600px) {
    .error-page {
        align-items: flex-start;
        padding-top: 80px;
    }

    .error-card {
        padding: 28px 20px;
    }

    .error-actions {
        flex-direction: column;
    }

    .error-back-button,
    .error-home-button {
        width: 100%;
    }
}
