/* =========================================================
   MINHA ROTINA - design system COMPACTO (mobile-first)
   Fundo off-white, cards arredondados, tipografia elegante.
   Prioridade: informacao > espaco vazio.
   ========================================================= */

:root {
    --bg: #F6F6FA;
    --surface: #FFFFFF;
    --surface-soft: #F1F0F8;
    --text: #1F1D2B;
    --text-soft: #6B6880;
    --text-faint: #9E9BB0;
    --primary: #6C63FF;
    --primary-soft: #EEEBFF;
    --primary-dark: #5A52E0;
    --green: #34C77B;
    --green-soft: #E4F7EE;
    --amber: #F5A623;
    --amber-soft: #FDF2DF;
    --red: #EF5B72;
    --red-soft: #FDE9EC;
    --blue: #3FA9F5;
    --blue-soft: #E6F3FE;
    --radius-lg: 16px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow: 0 4px 14px rgba(31, 29, 43, .05);
    --shadow-soft: 0 2px 8px rgba(31, 29, 43, .035);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.42;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; opacity: .85; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

/* ---------- layout ---------- */
.app-shell {
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 16px 92px;
    min-height: 100vh;
}

.app-shell.wide { max-width: 1000px; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
    min-height: 40px;
}

.brand {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -.02em;
    color: var(--text);
}

.brand-dot { color: var(--primary); }

.greeting { font-size: 17px; font-weight: 600; margin: 0 0 1px; letter-spacing: -.01em; }
.greeting-sub { color: var(--text-soft); margin: 0 0 10px; font-size: 12.5px; }

.section-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-faint);
    margin: 14px 0 7px;
}

/* ---------- cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 13px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 9px;
}

.card-lg { border-radius: var(--radius-lg); padding: 13px 14px; }
.card-flat { box-shadow: none; border: 1px solid var(--surface-soft); }
.card-row { display: flex; align-items: center; gap: 10px; }
.card-row .grow { flex: 1; min-width: 0; }

.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.tiny { font-size: 10.5px; }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 9px; }
.mb-2 { margin-bottom: 9px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid { display: grid; gap: 9px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (min-width: 760px) {
    .grid-md-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- progress ---------- */
.progress-ring { display: flex; align-items: center; gap: 12px; }

.ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--primary) calc(var(--value, 0) * 1%), var(--surface-soft) 0);
    flex-shrink: 0;
}

.ring-inner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--surface);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
}

.bar {
    height: 6px;
    border-radius: var(--radius-pill);
    background: var(--surface-soft);
    overflow: hidden;
}

.bar > span {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--primary);
    transition: width .3s ease;
}

.bar.green > span { background: var(--green); }
.bar.blue > span { background: var(--blue); }
.bar.amber > span { background: var(--amber); }
.bar.red > span { background: var(--red); }

/* ---------- stat tiles ---------- */
.tile {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 11px 12px;
    box-shadow: var(--shadow-soft);
}

.tile .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.tile .label { color: var(--text-soft); font-size: 11.5px; margin-top: 1px; }

.tile-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    margin-bottom: 6px;
    background: var(--primary-soft);
    color: var(--primary);
}

.tile-icon svg { width: 17px; height: 17px; }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 2px; }

.timeline-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 7px 0;
    position: relative;
}

.timeline-item + .timeline-item { border-top: 1px solid var(--surface-soft); }

.timeline-time {
    width: 42px;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 12.5px;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
    padding-top: 1px;
}

.timeline-body { flex: 1; min-width: 0; }
.timeline-title { font-weight: 500; font-size: 13.5px; }
.timeline-item.done .timeline-title { color: var(--text-faint); text-decoration: line-through; }

/* ---------- lists ---------- */
.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 7px;
    box-shadow: var(--shadow-soft);
}

.list-item .grow { flex: 1; min-width: 0; }

.check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--surface-soft);
    background: transparent;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    color: transparent;
    font-size: 12px;
    transition: all .15s ease;
}

.check.checked {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 10.5px;
    font-weight: 600;
    background: var(--surface-soft);
    color: var(--text-soft);
    white-space: nowrap;
}

.pill-primary { background: var(--primary-soft); color: var(--primary); }
.pill-green { background: var(--green-soft); color: #1E8A55; }
.pill-amber { background: var(--amber-soft); color: #A9700F; }
.pill-red { background: var(--red-soft); color: #C0392B; }
.pill-blue { background: var(--blue-soft); color: #1F7FB8; }

/* ---------- water ---------- */
.water-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 4px 0 2px;
}

.water-value { font-size: 32px; font-weight: 700; letter-spacing: -.03em; }

.round-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform .1s ease;
}

.round-btn:active { transform: scale(.94); }
.round-btn.primary { background: var(--primary); color: #fff; }

.cups { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.cup {
    width: 20px;
    height: 26px;
    border-radius: 5px 5px 8px 8px;
    background: var(--surface-soft);
    border: 2px solid transparent;
}

.cup.filled { background: var(--blue-soft); border-color: var(--blue); }

/* ---------- forms ---------- */
.field { margin-bottom: 11px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--surface-soft);
    background: var(--surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, .12);
}

.field textarea { min-height: 72px; resize: vertical; }
.field .hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.field .error { font-size: 11.5px; color: var(--red); margin-top: 4px; }

.field-row { display: grid; gap: 9px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 9px;
}

.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform .1s ease, background .15s ease;
    text-align: center;
}

.btn:hover { background: var(--primary-dark); opacity: 1; }
.btn:active { transform: scale(.985); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--surface-soft); color: var(--text); }
.btn-ghost:hover { background: #E7E6F2; }
.btn-outline { background: transparent; border: 1.5px solid var(--surface-soft); color: var(--text); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #D84A60; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 10px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    width: min(536px, calc(100% - 16px));
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(31, 29, 43, .10);
    display: flex;
    padding: 5px;
    z-index: 60;
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 5px 2px;
    border-radius: 12px;
    color: var(--text-faint);
    font-size: 9.5px;
    font-weight: 600;
    transition: color .15s ease, background .15s ease;
}

.bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
.bottom-nav svg { width: 19px; height: 19px; }

.fab-add {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 12px rgba(108, 99, 255, .32);
    margin-top: 0;
}

.fab-add svg { width: 18px; height: 18px; }

/* ---------- sheets / modals ---------- */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(31, 29, 43, .35);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 100%);
    width: min(560px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px 16px 20px;
    z-index: 91;
    transition: transform .26s cubic-bezier(.22, 1, .36, 1);
}

.sheet.open { transform: translate(-50%, 0); }

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sheet-title { font-size: 16px; font-weight: 600; margin: 0; }

/* ---------- alerts ---------- */
.alert {
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    margin-bottom: 9px;
    font-size: 12.5px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.alert-success { background: var(--green-soft); color: #1E8A55; }
.alert-error { background: var(--red-soft); color: #C0392B; }
.alert-info { background: var(--blue-soft); color: #1F7FB8; }
.alert-warn { background: var(--amber-soft); color: #A9700F; }

/* ---------- empty state ---------- */
.empty {
    text-align: center;
    padding: 26px 14px;
    color: var(--text-faint);
}

.empty svg { margin: 0 auto 10px; color: var(--text-faint); width: 30px; height: 30px; }
.empty-title { font-weight: 600; color: var(--text-soft); margin-bottom: 3px; font-size: 13.5px; }

/* ---------- segment control ---------- */
.segment {
    display: flex;
    gap: 4px;
    background: var(--surface-soft);
    padding: 3px;
    border-radius: var(--radius-pill);
    overflow-x: auto;
    margin-bottom: 11px;
    scrollbar-width: none;
}

.segment::-webkit-scrollbar { display: none; }

.segment a {
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    white-space: nowrap;
}

.segment a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }

/* ---------- toast ---------- */
.toast-wrap {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: min(420px, calc(100% - 24px));
}

.toast {
    background: var(--text);
    color: #fff;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: toast-in .22s ease;
}

.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--surface-soft); margin: 12px 0; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.badge-count {
    background: var(--red); color: #fff; border-radius: var(--radius-pill);
    font-size: 9.5px; padding: 1px 5px; font-weight: 700;
}
.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- HOME compacta (rotina, nao dashboard) ---------- */
.home-head { margin: 0 2px 7px; }

.home-greet { font-size: 13.5px; font-weight: 600; min-width: 0; }
.home-greet .faint { font-weight: 400; }

.home-progress-line { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: var(--text-faint); font-size: 10px; line-height: 1; }
.home-progress-line i { display: block; width: 58px; height: 3px; border-radius: 99px; background: var(--surface-soft); overflow: hidden; }
.home-progress-line i b { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.home-progress-line strong { color: var(--text-soft); font-size: 10px; font-weight: 600; }

.chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 1px 0 2px;
    margin-bottom: 9px;
}

.chips::-webkit-scrollbar { display: none; }
.chips-tight { margin: 7px 0 0; }

.chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 35px;
    padding: 7px 11px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    border: 0;
    cursor: pointer;
    font-family: inherit;
}

.chip-on { background: var(--primary-soft); color: var(--primary); }
.ui-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.chip-icon { width: 14px; height: 14px; flex: 0 0 auto; }
.inline { display: inline; }

.alarm-card { padding: 8px 11px; }
.alarm-head { display: flex; align-items: center; justify-content: space-between; }
.alarm-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.alarm-title .ui-icon { width: 16px; height: 16px; }
.alarm-actions { display: flex; gap: 5px; margin-top: 6px; }
.alarm-actions .btn-sm { padding: 6px 9px; font-size: 11px; }

.water-card { padding: 9px 11px; }
.water-head { display: flex; align-items: center; justify-content: space-between; }
.water-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; }
.water-title .ui-icon { width: 17px; height: 17px; color: var(--blue); }
.water-meta { font-size: 12px; color: var(--text-soft); }
.water-meta b { color: var(--text); font-size: 14px; }
.water-ctrl { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.water-ctrl .cups { flex: 1; justify-content: center; margin: 0; flex-wrap: nowrap; }
.water-ctrl .round-btn { width: 30px; height: 30px; font-size: 17px; }
.water-ctrl .cup { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--surface-soft); }
.water-ctrl .cup.filled { background: var(--blue); }

.sec-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 2px 5px;
}

.sec-title { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; }
.sec-title .ui-icon { width: 17px; height: 17px; }
.sec-count { font-size: 11.5px; font-weight: 700; color: var(--text-soft); }
.section-action { margin-left: auto; width: 24px; height: 24px; display: grid; place-items: center; color: var(--primary); border-radius: 7px; }
.section-action:hover { background: var(--primary-soft); opacity: 1; }
.section-action .ui-icon { width: 15px; height: 15px; }

.row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 0;
    border-bottom: 1px solid var(--surface-soft);
}

.row:last-child { border-bottom: 0; padding-bottom: 2px; }
.row .grow { flex: 1; min-width: 0; }
.rtitle { font-size: 13px; font-weight: 500; }
.rsub { display: flex; align-items: center; gap: 3px; font-size: 10.5px; color: var(--text-faint); }
.row-icon { width: 12px; height: 12px; flex: 0 0 auto; }

.routine-empty { padding: 2px 0; color: var(--text-faint); font-size: 12px; }

.icon-btn {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    border-radius: 8px;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.icon-btn:hover { background: var(--surface-soft); color: var(--red); }
.library-card-actions { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:9px; padding-top:8px; border-top:1px solid var(--surface-soft); }

/* ---------- desktop: um pouco mais de respiro, sem virar dashboard ---------- */
@media (min-width: 760px) {
    html, body { font-size: 14.5px; }
    .app-shell { padding: 18px 16px 40px; }
    .card { padding: 14px 16px; }
    .tile { padding: 13px 14px; }
    .tile .value { font-size: 26px; }
    .greeting { font-size: 19px; }
    .bottom-nav { position: sticky; bottom: 12px; transform: none; left: auto; margin: 18px auto 0; }
}
