:root {
    --bg: #fdf2f6;
    --bg-alt: #ffffff;
    --text: #3a2a35;
    --text-muted: #7a6a75;
    --primary: #d6336c;
    --primary-hover: #b0255a;
    --accent: #9c6ade;
    --border: #f0d9e4;
    --card-shadow: 0 4px 18px rgba(214, 51, 108, 0.08);
    --success-bg: #e6f7ef;
    --success-text: #1b7a4d;
    --danger: #c1293e;
    --danger-bg: #fdecee;
    --fertile-bg: #ffe3ec;
    --fertile-border: #ff9ebe;
    --ovulation-bg: #f3e0ff;
    --period-bg: #ffe0e0;
    --status-nao-fertil: #22a866;
    --status-fertil: #f5980f;
    --status-ovulacao: #e1293f;
    --status-menstruacao: #c22a80;
}

[data-theme="dark"] {
    --bg: #1c1620;
    --bg-alt: #26202c;
    --text: #f2e9ef;
    --text-muted: #b8a9b6;
    --primary: #ec6ea0;
    --primary-hover: #f286b1;
    --accent: #b58af0;
    --border: #3a2f3d;
    --card-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    --success-bg: #143826;
    --success-text: #6fd9a3;
    --danger: #ff8a97;
    --danger-bg: #3a1c22;
    --fertile-bg: #402032;
    --fertile-border: #a24d75;
    --ovulation-bg: #33234a;
    --period-bg: #402525;
    --status-nao-fertil: #2fd98a;
    --status-fertil: #ffab2e;
    --status-ovulacao: #ff4f68;
    --status-menstruacao: #ea59b0;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.2s ease, color 0.2s ease;
}

a {
    color: var(--primary);
}

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- Topbar ---------- */
.topbar {
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    max-width: 960px;
    margin: 0 auto;
    gap: 12px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.nav a.active,
.nav a:hover {
    background: var(--fertile-bg);
    color: var(--primary);
}

.user-chip {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.theme-toggle {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text);
}

.theme-toggle:hover {
    border-color: var(--primary);
}

/* ---------- Cards / Layout ---------- */
.page {
    padding: 24px 0 48px;
}

.card {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .grid.cols-2 {
        grid-template-columns: 1fr 1fr;
    }
    .grid.cols-3 {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* ---------- Forms ---------- */
label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field {
    margin-bottom: 16px;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 44px;
}

.toggle-password {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 6px 8px;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
}

.btn:hover {
    background: var(--primary-hover);
}

.btn.secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn.secondary:hover {
    background: var(--fertile-bg);
}

.btn.danger {
    background: var(--danger);
}

.btn-inline {
    width: auto;
    padding: 8px 14px;
    font-size: 0.9rem;
}

@media (min-width: 480px) {
    .btn {
        width: auto;
    }
}

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

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 32px 28px;
    position: relative;
}

.login-card .theme-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
}

.login-card .btn {
    width: 100%;
}

.login-logo {
    text-align: center;
    margin-bottom: 8px;
    font-size: 2rem;
}

.login-title {
    text-align: center;
    margin: 0 0 4px;
    color: var(--primary);
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin: 0 0 24px;
    font-size: 0.9rem;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---------- Resultado do calculo ---------- */
.result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 8px;
}

@media (min-width: 640px) {
    .result-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.result-item {
    border-radius: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
}

.result-item .label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.result-item .value {
    font-size: 1.1rem;
    font-weight: 700;
}

.result-item.fertil {
    background: var(--fertile-bg);
    border-color: var(--fertile-border);
}

.result-item.ovulacao {
    background: var(--ovulation-bg);
}

.result-item.menstruacao {
    background: var(--period-bg);
}

/* ---------- Tabela / historico ---------- */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 560px;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: none;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 24px 0;
}

.row-actions form {
    display: inline;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: var(--fertile-bg);
    color: var(--primary);
}

/* ---------- Usuarios ---------- */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    flex-wrap: wrap;
}

.user-row .info strong {
    display: block;
}

.user-row .info span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

footer.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 24px 16px;
}

/* ---------- Status de hoje (anel + faixa de dias) ---------- */
.status-hoje-card .subtitulo {
    margin: -8px 0 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.status-hoje {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

@media (min-width: 640px) {
    .status-hoje {
        flex-direction: row;
        align-items: center;
        gap: 32px;
    }
}

.anel-ciclo {
    width: 180px;
    height: 180px;
    min-width: 180px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.anel-centro {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    color: #fff;
    background-image: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 55%);
    box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.18), inset 0 -8px 16px rgba(0, 0, 0, 0.18);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.anel-label {
    font-size: 1.25rem;
    font-weight: 800;
}

.anel-dia {
    font-size: 0.8rem;
    opacity: 0.9;
}

.status-nao_fertil { background-color: var(--status-nao-fertil); }
.status-fertil { background-color: var(--status-fertil); }
.status-ovulacao { background-color: var(--status-ovulacao); }
.status-menstruacao { background-color: var(--status-menstruacao); }

.faixa-dias {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 8px;
    width: 100%;
}

.dia-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.dia-numero {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    background-image: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%);
    box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.18), 0 2px 4px rgba(0, 0, 0, 0.12);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.dia-semana {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.dia-hoje .dia-numero {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.legenda-status {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 18px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legenda-status .ponto {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}
