/* ============================================================
   Residência HAOC — estilos mobile-first
   ============================================================ */

:root {
    --primary: #0f4c75;
    --primary-dark: #0a3854;
    --primary-light: #3282b8;
    --accent: #bbe1fa;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1b2b3a;
    --text-muted: #6c7a89;
    --border: #e2e8f0;
    --danger: #c53030;
    --success: #2f855a;
    --warn: #c05621;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(15, 76, 117, 0.08);
    --shadow-hover: 0 4px 16px rgba(15, 76, 117, 0.15);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----- Topbar ----- */
.topbar {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar--admin { background: var(--primary-dark); }
.topbar__inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.topbar__brand {
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    text-decoration: none;
}
.topbar__nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.topbar__nav a {
    color: rgba(255,255,255,0.85);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.15s;
}
.topbar__nav a:hover,
.topbar__nav a.is-active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    text-decoration: none;
}
.topbar__logout { color: var(--accent) !important; }

/* ----- Main ----- */
.main {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px;
}
.main--admin { max-width: 1100px; }

/* ----- Cards ----- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card__title {
    margin: 0 0 4px 0;
    font-size: 20px;
    color: var(--primary-dark);
}
.card details summary { cursor: pointer; padding: 8px 0; }

/* ----- Login ----- */
.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px 24px;
    margin: 60px auto;
    max-width: 380px;
    box-shadow: var(--shadow);
}
.login-card__title {
    margin: 0 0 4px 0;
    text-align: center;
    color: var(--primary);
    font-size: 24px;
}
.login-card__subtitle {
    margin: 0 0 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* ----- Forms ----- */
.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.form--inline {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 180px;
}
.field span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.field--checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.field--checkbox input[type=checkbox] { width: 18px; height: 18px; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=month], select, textarea {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(50, 130, 184, 0.15);
}

/* ----- Buttons ----- */
.btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) { background: var(--primary-dark); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { background: #b0bec5; cursor: not-allowed; }
.btn--primary { background: var(--primary); }
.btn--block { width: 100%; }
.btn--large { padding: 16px; font-size: 17px; }
.btn--small { padding: 6px 10px; font-size: 13px; }
.btn--ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn--ghost:hover:not(:disabled) { background: var(--bg); color: var(--primary-dark); }
.btn--danger { background: var(--danger); }
.btn--danger:hover:not(:disabled) { background: #9b2c2c; }

/* ----- Flashes ----- */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.flash--success { background: #c6f6d5; color: #22543d; }
.flash--error   { background: #fed7d7; color: #742a2a; }
.flash--info    { background: var(--accent); color: var(--primary-dark); }

/* ----- Atividades dinâmicas ----- */
.atividades {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
}
.atividade-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.atividade-row__nome {
    flex: 1;
    font-weight: 500;
    font-size: 15px;
}
.atividade-row__controls {
    display: flex;
    align-items: center;
    gap: 6px;
}
.atividade-row__btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.atividade-row__btn:hover { background: var(--accent); }
.atividade-row__btn:disabled { opacity: 0.3; cursor: not-allowed; }
.atividade-row__qtd {
    width: 48px;
    text-align: center;
    font-weight: 600;
    font-size: 17px;
    border: none;
    background: transparent;
    padding: 0;
}
.atividade-row__qtd:focus { background: #fff; border-radius: 4px; }

/* ----- Tables ----- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.table input[type=text], .table input[type=number] {
    padding: 6px 8px;
    font-size: 14px;
    width: 100%;
}
.table-form { display: contents; }
.row-inactive { opacity: 0.5; }
.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.inline-form {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.inline-form input[type=text] {
    padding: 5px 8px;
    font-size: 13px;
    width: 110px;
}

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 99px;
    background: var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}
.badge--ok    { background: #c6f6d5; color: #22543d; }
.badge--warn  { background: #fefcbf; color: #744210; }
.badge--link  { background: var(--accent); color: var(--primary-dark); cursor: pointer; }

/* ----- Stats ----- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat--highlight { background: var(--primary); color: #fff; }
.stat--highlight .stat__l { color: rgba(255,255,255,0.8); }
.stat__n { font-size: 28px; font-weight: 700; }
.stat__l { font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }

/* ----- History ----- */
.history {
    list-style: none;
    padding: 0;
    margin: 0;
}
.history__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.history__item:last-child { border-bottom: none; }

/* ----- Utilities ----- */
.muted { color: var(--text-muted); font-size: 14px; }
.muted--center { text-align: center; padding: 16px 0; }
.footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 12px;
}
.info-box {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin: 12px 0;
    font-size: 14px;
}
.steps {
    padding-left: 20px;
    line-height: 1.8;
    font-size: 14px;
}
.steps code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    word-break: break-all;
}
.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}
textarea { resize: vertical; min-height: 60px; }

/* ----- Responsivo ----- */
@media (min-width: 768px) {
    .form--inline .field { flex: 0 1 auto; min-width: 160px; }
}
