:root {
    --brand-cyan: #2ec4f0;
    --brand-navy: #1b3d6b;
    --brand-navy-light: #2563a8;
    --text: #334155;
    --muted: #64748b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --bg: #eef2f7;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
    --success-bg: #f0fdf4;
    --success-text: #15803d;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--brand-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-navy-light) 100%);
    color: #fff;
    flex-wrap: wrap;
}

.site-nav-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: #fff;
    font-weight: 600;
    font-size: 1.0625rem;
    text-decoration: none;
}

.site-nav-brand:hover { text-decoration: none; opacity: 0.92; }

.site-logo {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.site-nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.site-nav-links a,
.site-nav-links button {
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.875rem;
    font-family: inherit;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem 0.625rem;
    border-radius: 0.375rem;
}

.site-nav-links a:hover,
.site-nav-links button:hover {
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
}

.site-footer {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.125rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.15s;
}

.btn:hover { opacity: 0.92; }

.btn-primary {
    background: var(--brand-cyan);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: var(--brand-navy);
    border: 1px solid var(--border);
}

.card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(27, 61, 107, 0.08);
    overflow: hidden;
}

.form-page {
    min-height: calc(100vh - 4rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.form-card { width: 100%; max-width: 440px; }

.form-card .card-header {
    background: linear-gradient(135deg, var(--brand-cyan) 0%, var(--brand-navy) 100%);
    color: #fff;
    padding: 1.25rem 1.5rem;
}

.form-card .card-header h1 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.form-card .card-header p { margin: 0.35rem 0 0; font-size: 0.875rem; opacity: 0.9; }

.form-card form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-card label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.form-card input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
}

.form-card input:focus {
    outline: none;
    border-color: var(--brand-cyan);
    box-shadow: 0 0 0 3px rgba(46, 196, 240, 0.15);
}

.msg {
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.msg-error { background: var(--error-bg); color: var(--error-text); border: 1px solid #fecaca; }
.msg-success { background: var(--success-bg); color: var(--success-text); border: 1px solid #bbf7d0; }
.msg-hint { background: #f8fafc; color: var(--muted); border: 1px solid var(--border); }

.hidden { display: none; }

.code-row { display: flex; gap: 0.5rem; }
.code-row input { flex: 1; }

.mode-pills { display: flex; gap: 0.35rem; }

.mode-pill {
    flex: 1;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 0.8125rem;
    cursor: pointer;
    font-family: inherit;
}

.mode-pill-active {
    background: #fff;
    border-color: var(--brand-cyan);
    color: var(--brand-cyan);
}

.form-card-footer {
    padding: 0 1.5rem 1.5rem;
    font-size: 0.8125rem;
    color: var(--muted);
    text-align: center;
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-send-code {
    padding: 0.625rem 0.875rem;
    background: #f1f5f9;
    color: var(--text);
    white-space: nowrap;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.form-card .btn-primary {
    padding: 0.75rem 1rem;
    background: var(--brand-cyan);
    color: #fff;
    font-size: 0.9375rem;
    border: none;
    border-radius: 8px;
    width: 100%;
}

.form-card .btn-primary:hover:not(:disabled) { opacity: 0.92; }

/* Register page (DFRobot-style tabs) */
.reg-card .card-header { text-align: center; }

.reg-tabs {
    display: flex;
    margin: 0 1.5rem;
    border-bottom: 1px solid var(--border);
}

.reg-tab {
    flex: 1;
    padding: 0.875rem 0.5rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: -1px;
}

.reg-tab-active {
    color: var(--brand-cyan);
    border-bottom-color: var(--brand-cyan);
}

.reg-card form { padding-top: 1.25rem; }

.agreement-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.agreement-row input { width: auto; margin-top: 0.15rem; flex-shrink: 0; }

.link-btn {
    padding: 0;
    border: none;
    background: none;
    color: var(--brand-cyan);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.success-panel {
    padding: 2.5rem 1.5rem 2rem;
    text-align: center;
}

.success-icon {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto 1rem;
    border-radius: 999px;
    background: var(--success-bg);
    color: var(--success-text);
    font-size: 1.75rem;
    line-height: 3.5rem;
    font-weight: 700;
}

.success-panel h2 {
    margin: 0 0 0.5rem;
    color: var(--brand-navy);
    font-size: 1.375rem;
}

.success-panel p { margin: 0 0 1rem; color: var(--muted); font-size: 0.9375rem; }

.success-panel .btn-primary { max-width: 16rem; margin: 0 auto; }

.field-hint {
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.45;
    margin: 0.75rem 0 0;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-dialog {
    width: 100%;
    max-width: 520px;
    max-height: min(80vh, 640px);
    background: #fff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { margin: 0; font-size: 1.0625rem; color: var(--brand-navy); }

.modal-close {
    border: none;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 0.25rem;
}

.modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    font-size: 0.8125rem;
    color: var(--text);
    line-height: 1.6;
}

.modal-body h3 {
    margin: 1rem 0 0.35rem;
    font-size: 0.875rem;
    color: var(--brand-navy);
}

.modal-body h3:first-child { margin-top: 0; }

.modal-body p { margin: 0 0 0.75rem; }

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
}

.modal-footer .btn-primary { flex: 1; }

.modal-footer .btn-secondary {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9375rem;
}
