/* =========================================================
   Sportway Tools — Complete Stylesheet
   ========================================================= */

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-dark: #0f172a;

    --text: #172033;
    --text-soft: #64748b;
    --text-faint: #94a3b8;

    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;

    --success: #15803d;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;

    --warning: #b45309;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;

    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;

    --border: #dfe6ef;
    --border-strong: #cbd5e1;

    --radius-sm: 7px;
    --radius: 11px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);

    --transition: 160ms ease;
}

/* Reset */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body,
h1,
h2,
h3,
p {
    margin: 0;
}

body {
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(
            circle at top left,
            rgba(37, 99, 235, 0.06),
            transparent 28rem
        ),
        var(--bg);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: var(--primary);
}

code {
    padding: 2px 5px;
    background: #e9eef5;
    border-radius: 4px;
    font-family: "Cascadia Code", "Cascadia Mono", Consolas, monospace;
    font-size: 0.9em;
}

::selection {
    color: #ffffff;
    background: var(--primary);
}

/* Navigation */

.top-nav {
    position: sticky;
    z-index: 100;
    top: 0;

    display: flex;
    align-items: center;
    gap: 24px;

    min-height: 68px;
    padding: 10px clamp(18px, 4vw, 56px);

    color: #ffffff;
    background: rgba(15, 23, 42, 0.96);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(14px);
}

.nav-brand {
    flex: 0 0 auto;
}

.nav-brand a {
    color: #ffffff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.025em;
    text-decoration: none;
}

.nav-brand a::before {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 10px;

    background: #60a5fa;
    border-radius: 50%;
    box-shadow: 0 0 0 5px rgba(96, 165, 250, 0.12);

    content: "";
}

.nav-links {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.nav-links a,
.nav-logout {
    padding: 8px 11px;

    color: #b8c4d6;
    border-radius: var(--radius-sm);

    font-size: 13px;
    font-weight: 500;
    text-decoration: none;

    transition:
        color var(--transition),
        background var(--transition);
}

.nav-links a:hover,
.nav-links a.active,
.nav-logout:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.nav-links a.active {
    box-shadow: inset 0 -2px #60a5fa;
}

.nav-user {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.nav-email {
    max-width: 220px;
    overflow: hidden;

    color: #94a3b8;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main content */

.container {
    width: min(1440px, calc(100% - 40px));
    min-height: calc(100vh - 108px);
    margin: 32px auto;
    padding: clamp(24px, 4vw, 42px);

    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(203, 213, 225, 0.75);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

h1,
h2,
h3 {
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -0.03em;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(25px, 3vw, 34px);
}

h2 {
    margin: 32px 0 14px;
    font-size: 21px;
}

h3 {
    margin: 26px 0 12px;
    font-size: 17px;
}

p + p {
    margin-top: 10px;
}

.notice + p,
.error + p,
.success + p,
.warning + p {
    margin-top: 18px;
}

.muted,
.note,
.small {
    color: var(--text-soft);
}

.muted,
.note {
    font-size: 14px;
}

.note {
    max-width: 760px;
    margin-bottom: 20px;
}

.small {
    margin-top: 5px;
    font-size: 12px;
}

/* Forms */

body:not(.login-page) .container > form {
    margin-top: 24px;
    padding: clamp(20px, 3vw, 28px);

    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

label {
    display: block;
    margin: 18px 0 7px;

    color: #334155;
    font-size: 13px;
    font-weight: 650;
}

label:first-child {
    margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;

    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    box-shadow: var(--shadow-sm);

    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        background var(--transition);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select {
    min-height: 44px;
    padding: 9px 12px;
}

select {
    min-width: 220px;
    cursor: pointer;
}

textarea {
    min-height: 190px;
    padding: 13px;
    resize: vertical;

    font-family: "Cascadia Code", "Cascadia Mono", Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-faint);
}

input:focus,
select:focus,
textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11);
}

input[readonly],
textarea[readonly] {
    color: #475569;
    background: #f1f5f9;
    cursor: text;
}

input[type="file"] {
    width: 100%;
    margin: 0;
    padding: 7px;

    color: var(--text-soft);
    background: #ffffff;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);

    cursor: pointer;
}

input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 8px 12px;

    color: #334155;
    background: #eef2f7;
    border: 0;
    border-radius: 6px;

    font-weight: 600;
    cursor: pointer;
}

.input-row {
    max-width: 680px;
    margin: 20px 0 24px;
}

/* Buttons */

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;
    margin-top: 20px;
    padding: 9px 17px;

    color: #ffffff;
    background: var(--primary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);

    font-size: 14px;
    font-weight: 650;
    cursor: pointer;

    transition:
        background var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

button + button {
    margin-left: 8px;
}

button:hover {
    background: var(--primary-dark);
    box-shadow: 0 7px 18px rgba(37, 99, 235, 0.24);
    transform: translateY(-1px);
}

button:active {
    box-shadow: none;
    transform: translateY(0);
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.55);
    outline-offset: 3px;
}

button:disabled {
    color: #64748b;
    background: #cbd5e1;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.button-danger {
    background: var(--danger);
}

.button-danger:hover {
    background: #991b1b;
}

/* Notices */

.notice,
.error,
.success,
.warning,
.info {
    margin-top: 20px;
    padding: 13px 15px;

    border: 1px solid;
    border-radius: var(--radius-sm);

    font-size: 14px;
}

.error {
    color: #991b1b;
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

.success {
    color: #166534;
    background: var(--success-bg);
    border-color: var(--success-border);
}

.warning {
    color: #92400e;
    background: var(--warning-bg);
    border-color: var(--warning-border);
}

.info {
    color: #1e40af;
    background: var(--primary-soft);
    border-color: #bfdbfe;
}

.error ul,
.warning ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

/* Tables */

.table-wrap {
    width: 100%;
    margin-top: 20px;
    overflow-x: auto;

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table {
    display: block;
    width: 100%;
    margin-top: 20px;
    overflow-x: auto;

    border-spacing: 0;
    border-collapse: separate;
    border: 1px solid var(--border);
    border-radius: var(--radius);

    font-size: 12px;
    white-space: nowrap;

    scrollbar-color: #cbd5e1 transparent;
    scrollbar-width: thin;
}

thead {
    background: #eef2f7;
}

th,
td {
    padding: 11px 13px;

    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);

    text-align: left;
    vertical-align: top;
}

th {
    color: #475569;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

td {
    color: #334155;
    background: #ffffff;
}

th:last-child,
td:last-child {
    border-right: 0;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover td {
    background: #f8fafc;
}

tr.ready td {
    background: rgba(240, 253, 244, 0.7);
}

tr.issue td {
    background: rgba(254, 242, 242, 0.72);
}

td input[type="text"] {
    min-width: 260px;
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
}

/* Code and debug output */

pre,
.payload-preview {
    max-width: 100%;
    max-height: 460px;
    margin-top: 14px;
    padding: 16px;
    overflow: auto;

    color: #dbeafe;
    background: var(--surface-dark);
    border: 1px solid #26344c;
    border-radius: var(--radius);

    font-family: "Cascadia Code", "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

details summary {
    color: var(--primary);
    font-weight: 650;
    cursor: pointer;
}

details[open] summary {
    margin-bottom: 8px;
}

/* Dashboard */

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.menu-card {
    position: relative;
    display: block;

    min-height: 132px;
    padding: 22px 48px 22px 22px;
    overflow: hidden;

    color: inherit;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);

    text-decoration: none;

    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.menu-card::after {
    position: absolute;
    top: 22px;
    right: 21px;

    color: #94a3b8;
    font-size: 21px;

    content: "\2192";

    transition:
        color var(--transition),
        transform var(--transition);
}

.menu-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.09);
    transform: translateY(-2px);
}

.menu-card:hover::after {
    color: var(--primary);
    transform: translateX(3px);
}

.menu-card h2 {
    margin: 0 0 8px;
    font-size: 17px;
}

.menu-card p {
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.55;
}

/* Badges and utilities */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;

    color: #475569;
    background: #e9eef5;
    border-radius: 999px;

    font-size: 11px;
    font-weight: 650;
}

.badge-success {
    color: var(--success);
    background: #dcfce7;
}

.badge-warning {
    color: var(--warning);
    background: #fef3c7;
}

.issue-list {
    margin: 0;
    padding-left: 18px;
}

.issue-list li {
    margin-bottom: 4px;
}

.create-form,
.tool-form {
    margin-top: 24px;
}

/* FreeScout */

.site-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.site-link {
    position: relative;
    display: block;

    padding: 15px 40px 15px 16px;

    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);

    font-size: 13px;
    font-weight: 600;
    text-decoration: none;

    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.site-link::after {
    position: absolute;
    top: 50%;
    right: 15px;

    color: var(--text-faint);
    content: "\2197";

    transform: translateY(-50%);
}

.site-link:hover {
    border-color: #93c5fd;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.site-link.disabled {
    opacity: 0.45;
    box-shadow: none;
    pointer-events: none;
}

.context {
    display: block;
    margin-top: 3px;

    color: var(--text-soft);

    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 10px;
    font-weight: 500;
}

/* Login */

body.login-page {
    display: grid;
    min-height: 100vh;
    padding: 24px;
    place-items: center;

    background:
        radial-gradient(
            circle at 20% 15%,
            rgba(96, 165, 250, 0.22),
            transparent 28rem
        ),
        radial-gradient(
            circle at 85% 85%,
            rgba(37, 99, 235, 0.18),
            transparent 26rem
        ),
        #0f172a;
}

.login-container {
    width: min(100%, 410px);
    padding: 38px;

    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-container h1 {
    margin-bottom: 28px;
    font-size: 25px;
    text-align: center;
}

.login-container h1::before {
    display: block;
    width: 40px;
    height: 5px;
    margin: 0 auto 18px;

    background: var(--primary);
    border-radius: 999px;

    content: "";
}

.form-group {
    margin-bottom: 17px;
}

.form-group label {
    margin: 0 0 7px;
}

.login-container button {
    width: 100%;
    margin-top: 8px;
}

.login-container .notice {
    margin: -8px 0 22px;
}

/* Responsive */

@media (max-width: 960px) {
    .top-nav {
        flex-wrap: wrap;
        gap: 10px 18px;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .nav-user {
        margin-left: auto;
    }

    .container {
        width: min(100% - 28px, 1440px);
        margin: 20px auto;
    }
}

@media (max-width: 680px) {
    .top-nav {
        position: relative;
        padding: 12px 16px;
    }

    .nav-email {
        display: none;
    }

    .nav-links a {
        white-space: nowrap;
    }

    .container {
        width: calc(100% - 20px);
        margin: 10px auto;
        padding: 22px 17px;
        border-radius: 12px;
    }

    .menu-grid {
        grid-template-columns: 1fr;
    }

    body:not(.login-page) .container > form {
        padding: 18px;
    }

    button {
        width: 100%;
    }

    button + button {
        margin-top: 9px;
        margin-left: 0;
    }

    .login-container {
        padding: 30px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}