/* Modernized Agency Baseline Styles */
:root { 
    --primary-blue: #004a99; 
    --accent-gold: #ffbf47;
    --focus-ring: #0b63ce;
    --focus-ring-offset: #ffffff;
    --text-dark: #1a1a1a; 
    --bg-light: #ffffff; 
    --border-gray: #d1d9e0;
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    line-height: 1.6; 
    max-width: 900px; 
    margin: 40px auto; 
    padding: 20px; 
    color: var(--text-dark); 
    background-color: var(--bg-light); 
}

header { border-bottom: 3px solid var(--primary-blue); margin-bottom: 30px; padding-bottom: 10px; }
h1 { color: var(--primary-blue); margin-bottom: 0; }

main { background: #f4f7fa; padding: 30px; border-radius: 8px; border: 1px solid var(--border-gray); }

/* Input & Form Styling */
.control-group { margin-bottom: 20px; }
label { font-weight: bold; display: block; margin-bottom: 8px; }

input[type="url"], input[type="email"], input[type="password"], input[type="number"], input[type="text"], select {
    width: 100%; 
    max-width: 500px; 
    padding: 12px; 
    border: 2px solid #555; 
    border-radius: 4px; 
    font-size: 1rem; 
    background: white;
}

/* Keyboard focus visibility (WCAG 2.2 focus appearance support) */
input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px; 
    box-shadow: 0 0 0 2px var(--focus-ring-offset);
}

input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

button { 
    padding: 14px 28px; 
    background-color: var(--primary-blue); 
    color: white; 
    border: none; 
    border-radius: 4px; 
    font-weight: bold; 
    font-size: 1rem;
    cursor: pointer; 
    transition: background 0.2s;
}

button:hover { background-color: #003366; }
button:active { transform: translateY(1px); }

/* Results Area Placeholder */
#results-area { margin-top: 40px; display: none; }
.status-msg { font-style: italic; color: #555; margin-top: 15px; }

footer { margin-top: 50px; font-size: 0.9rem; border-top: 1px solid #ccc; padding-top: 20px; }

/* Download Button Styling */
.btn-download {
    background-color: #28a745; /* Success Green */
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    display: inline-block;
    transition: background 0.2s;
}

.btn-download:hover {
    background-color: #218838;
}

.results-card {
    background: white;
    padding: 20px;
    border-radius: 5px;
    border-left: 5px solid var(--primary-blue);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.metric-card {
    background: #f6f9fc;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    padding: 10px;
}

.metric-label {
    margin: 0;
    font-size: 0.85rem;
    color: #4d5b6a;
}

.metric-value {
    margin: 2px 0 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.score-note {
    font-size: 0.92rem;
    color: #3e4d5d;
    margin: 10px 0 16px;
}

.suggestions-list {
    margin: 8px 0 18px;
}

.violation-list {
    list-style: none;
    padding-left: 0;
    margin: 8px 0 0;
    display: grid;
    gap: 12px;
}

.violation-item {
    background: #fbfdff;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    padding: 12px;
}

.violation-item p {
    margin: 6px 0;
}

.violation-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.impact-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.impact-critical { background: #7f1d1d; color: #fff; }
.impact-serious { background: #991b1b; color: #fff; }
.impact-moderate { background: #92400e; color: #fff; }
.impact-minor { background: #1e3a8a; color: #fff; }
.impact-unknown { background: #475569; color: #fff; }

.no-violations {
    margin-top: 8px;
    background: #edf7ed;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    padding: 10px;
}

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

.billing-plan-group {
    max-width: 280px;
    margin-top: 12px;
}

.billing-plan-group select {
    max-width: 280px;
}

.crawl-settings-group {
    max-width: 280px;
}

.crawl-settings-group input {
    max-width: 280px;
}

.crawl-page-list {
    list-style: none;
    padding-left: 0;
    margin: 10px 0 0;
    display: grid;
    gap: 10px;
}

.crawl-page-item {
    background: #fbfdff;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    padding: 10px;
}

.crawl-page-item p {
    margin: 4px 0;
}

.crawl-page-error {
    border-color: #f5c2c7;
    background: #fff5f5;
}

.btn-secondary {
    background-color: #2f5d8a;
}

.btn-secondary:hover {
    background-color: #24486b;
}

#history-area,
#crawl-history-area {
    margin-top: 28px;
}

.history-list {
    list-style: none;
    margin: 10px 0 0;
    padding-left: 0;
    display: grid;
    gap: 10px;
}

.history-item-btn {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    background: #fff;
    color: var(--text-dark);
    padding: 10px 12px;
    font-weight: 600;
    cursor: pointer;
}

.history-item-btn:hover {
    background: #eef4fb;
}

.history-item-meta {
    display: block;
    margin-top: 5px;
    font-size: 0.88rem;
    color: #4d5b6a;
    font-weight: 500;
}

.history-empty {
    margin-top: 8px;
    background: #f9fafb;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    padding: 10px;
}

.account-card {
    background: #eef4fb;
    border: 1px solid #c9d8ea;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.account-card h2 {
    margin-top: 0;
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.plan-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
    background: #334155;
    margin-left: 8px;
}

.plan-pill.plan-free,
.plan-pill.plan-guest-trial {
    background: #92400e;
}

.plan-pill.plan-pro {
    background: #14532d;
}

.plan-pill.plan-pro-monthly,
.plan-pill.plan-pro-yearly {
    background: #14532d;
}

.plan-pill.plan-crawler,
.plan-pill.plan-crawler-monthly {
    background: #1d4ed8;
}

/* Professional UI polish overrides */
* {
    box-sizing: border-box;
}

:root {
    --surface-white: #ffffff;
    --surface-subtle: #f8fafd;
    --surface-page: #f2f6fb;
    --text-muted: #4a5b70;
    --border-strong: #b8c8db;
    --shadow-soft: 0 10px 24px rgba(16, 42, 76, 0.08);
    --shadow-card: 0 5px 14px rgba(16, 42, 76, 0.06);
    --header-divider: #dde7f3;
    --metric-border: #c3d3e6;
    --focus-ring: #0b63ce;
    --focus-ring-offset: #ffffff;
}

body {
    max-width: none;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    background: linear-gradient(180deg, #f8fbff 0%, var(--surface-page) 100%);
}

header {
    max-width: 1120px;
    margin: 22px auto 10px;
    padding: 0 24px 16px;
    border-bottom-width: 2px;
}

header h1 {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    color: #0f3d73;
}

header p {
    margin: 8px 0 0;
    color: var(--text-muted);
}

.app-version {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px 26px;
    background: transparent;
    border: none;
    border-radius: 0;
    display: grid;
    gap: 14px;
}

main > section {
    background: var(--surface-white);
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: var(--shadow-soft);
}

h2,
h3,
h4 {
    margin-top: 0;
    color: #17385f;
}

main > section > h2,
main > section > h3 {
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--header-divider);
    letter-spacing: 0.01em;
    font-size: 1.08rem;
    font-weight: 700;
}

.methodology-section {
    border-top: 3px solid #e1ebf7;
}

.methodology-section ul {
    margin: 8px 0 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.control-group {
    margin-bottom: 12px;
}

label {
    font-weight: 600;
    margin-bottom: 6px;
    color: #213450;
}

input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="text"],
select {
    max-width: 560px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text-dark);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
    color: #7b8798;
}

button {
    min-height: 42px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.96rem;
    font-weight: 600;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

button:hover {
    background-color: #003f79;
    box-shadow: 0 4px 12px rgba(0, 74, 153, 0.28);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    background-color: #2e5b88;
}

.btn-secondary:hover {
    background-color: #234565;
}

.btn-download {
    background-color: #1f7a45;
    border-radius: 8px;
}

.btn-download:hover {
    background-color: #176338;
}

.action-row {
    gap: 8px;
}

.export-actions {
    margin-top: 14px;
}

.export-actions button {
    min-width: 250px;
}

.status-msg {
    margin-top: 10px;
    padding: 9px 12px;
    border: 1px solid var(--border-gray);
    border-left: 4px solid var(--primary-blue);
    border-radius: 8px;
    font-style: normal;
    color: var(--text-muted);
    background: var(--surface-subtle);
}

.score-note {
    color: var(--text-muted);
}

.account-card {
    background: #f1f6fd;
    border-color: #cbd9ea;
}

.account-card h2 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.auth-grid {
    gap: 10px;
}

.auth-form-panel {
    margin: 12px 0 14px;
    padding: 14px;
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    background: var(--surface-subtle);
}

.profile-panel {
    margin: 12px 0 14px;
    padding: 14px;
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    background: #ffffff;
}

.profile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.profile-heading {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

#profile-toggle-btn {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 0.84rem;
}

.profile-sections {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-sections[hidden] {
    display: none !important;
}

.profile-section {
    margin: 0;
    padding: 10px;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    background: #ffffff;
}

.profile-section-heading {
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f3654;
}

.profile-grid {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px 10px;
    align-items: start;
}

.profile-section-identity {
    order: 0;
}

.profile-section-plan {
    order: 1;
}

.profile-section-identity .profile-grid {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
}

.profile-section-plan .profile-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.profile-item-name-input {
    display: grid;
    gap: 4px;
}

.profile-item-name-input label {
    margin-bottom: 0;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.profile-item-name-input input[type="text"] {
    max-width: none;
    min-height: 38px;
}

.profile-name-actions-inline {
    margin-top: 8px;
}

.profile-item {
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    background: var(--surface-subtle);
    align-self: start;
}

.profile-item dt {
    margin: 0;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.profile-item dd {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-name-actions {
    margin-top: 8px;
}

.profile-name-actions button,
.profile-name-editor-actions button {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 0.84rem;
}

.profile-name-editor {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-gray);
    display: grid;
    gap: 8px;
}

.profile-name-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px 10px;
}

.profile-name-grid .control-group {
    margin-bottom: 0;
}

.profile-name-editor label {
    margin-bottom: 0;
    font-size: 0.84rem;
}

.profile-name-editor input[type="text"] {
    max-width: none;
    min-height: 40px;
}

.profile-name-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.auth-form-heading {
    margin: 0 0 10px;
    padding: 0;
    border: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.auth-form-panel .auth-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 12px;
}

.auth-name-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 12px;
    margin-bottom: 10px;
}

@media (max-width: 980px) {
    .profile-section-identity .profile-grid,
    .profile-section-plan .profile-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 640px) {
    .profile-section-identity .profile-grid,
    .profile-section-plan .profile-grid {
        grid-template-columns: 1fr;
    }
}

.auth-name-grid .control-group {
    margin-bottom: 0;
}

.field-note {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.auth-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.auth-form-actions button {
    min-width: 150px;
}

.billing-plan-group,
.crawl-settings-group {
    max-width: 320px;
}

.billing-plan-group select,
.crawl-settings-group input {
    max-width: 320px;
}

#results-area {
    margin-top: 0;
}

#history-area,
#crawl-history-area {
    margin-top: 0;
}

#results-area hr {
    border: 0;
    border-top: 1px solid var(--border-gray);
    margin: 0 0 18px;
}

.results-card {
    border-left: none;
    border: 1px solid #cad8e9;
    border-top: 4px solid #1b4e86;
    border-radius: 10px;
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
}

.metrics-grid {
    gap: 12px;
    margin: 12px 0 14px;
}

.metric-card {
    background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%);
    border: 1px solid var(--metric-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
    padding: 12px;
}

.metric-label {
    color: #556a84;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
}

.metric-value {
    color: #0f3d73;
    font-size: 1.45rem;
    line-height: 1.1;
}

.violation-item,
.crawl-page-item,
.history-empty {
    background: var(--surface-subtle);
}

.history-item-btn {
    border-radius: 8px;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.history-item-btn:hover {
    background: #f1f6fd;
    border-color: #c7d5e6;
}

.history-item-btn:focus {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--focus-ring-offset);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    button:active {
        transform: none;
    }
}

footer {
    max-width: 1120px;
    margin: 18px auto 26px;
    padding: 18px 24px 0;
    border-top: 1px solid var(--border-gray);
    color: var(--text-muted);
}

@media (max-width: 768px) {
    header {
        margin-top: 16px;
        padding: 0 16px 12px;
    }

    main {
        padding: 0 16px 20px;
        gap: 12px;
    }

    main > section {
        padding: 16px;
    }

    button {
        width: 100%;
    }

    .action-row {
        align-items: stretch;
    }

    .export-actions button {
        min-width: 0;
    }

    .billing-plan-group,
    .crawl-settings-group,
    .billing-plan-group select,
    .crawl-settings-group input {
        max-width: none;
    }
}
