:root {
    --bg: #0f1923;
    --bg2: #1a2740;
    --bg3: #243352;
    --card: #1e2f45;
    --border: #2d4060;
    --text: #e8eef5;
    --text2: #8da4bf;
    --accent: #4fc3f7;
    --accent2: #81c784;
    --warn: #ffb74d;
    --danger: #ef5350;
    --success: #66bb6a;
    --pee: #ffd54f;
    --poop: #a1887f;
    --feed: #ef9a9a;
    --treat: #ce93d8;
    --walk: #4fc3f7;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Nunito Sans', 'Nunito', sans-serif;
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ── Navbar ── */
.navbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: env(safe-area-inset-top);
}
.nav-brand { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 1.3rem; color: var(--accent); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 0.25rem; }
.nav-link { color: var(--text2); text-decoration: none; padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600; transition: all 0.15s; }
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--bg3); }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; color: #fff; margin-left: 0.25rem; }

/* ── Main ── */
.main-content { max-width: 700px; margin: 0 auto; padding: 1.25rem 1rem; }

/* ── Flash Messages ── */
.flash-container { margin-bottom: 1rem; }
.flash { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-weight: 600; margin-bottom: 0.5rem; }
.flash-success { background: #1b4332; border: 1px solid var(--success); color: var(--success); }
.flash-error { background: #3b0f0f; border: 1px solid var(--danger); color: var(--danger); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.65rem 1.25rem; border-radius: var(--radius-sm); border: none;
    font-family: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer;
    transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #0a1520; }
.btn-primary:hover { background: #81d4fa; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #3b0f0f; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }
.btn-full { width: 100%; }

/* ── Quick Actions / Dog Cards ── */
.quick-actions { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }

.dog-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow);
}
.dog-avatar {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--bg3); display: flex; align-items: center; justify-content: center;
    font-size: 1.75rem; overflow: hidden; flex-shrink: 0;
}
.dog-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dog-info { flex: 1; min-width: 120px; }
.dog-name { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1.1rem; }
.dog-last-out { color: var(--text2); font-size: 0.82rem; margin-top: 0.2rem; }
.dog-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; width: 100%; }

.btn-action {
    flex: 1; min-width: 70px; padding: 0.7rem 0.5rem;
    border: none; border-radius: var(--radius-sm);
    font-family: inherit; font-weight: 700; font-size: 0.85rem;
    cursor: pointer; transition: all 0.15s; text-align: center;
}
.btn-walk { background: rgba(79,195,247,0.15); color: var(--walk); border: 1px solid rgba(79,195,247,0.3); }
.btn-walk:hover { background: rgba(79,195,247,0.3); }
.btn-pee { background: rgba(255,213,79,0.15); color: var(--pee); border: 1px solid rgba(255,213,79,0.3); }
.btn-pee:hover { background: rgba(255,213,79,0.3); }
.btn-poop { background: rgba(161,136,127,0.15); color: #bcaaa4; border: 1px solid rgba(161,136,127,0.3); }
.btn-poop:hover { background: rgba(161,136,127,0.3); }
.btn-both { background: rgba(129,199,132,0.15); color: var(--accent2); border: 1px solid rgba(129,199,132,0.3); }
.btn-both:hover { background: rgba(129,199,132,0.3); }

.btn-feed { background: rgba(239,154,154,0.15); color: var(--feed); border: 1px solid rgba(239,154,154,0.3); }
.btn-feed:hover { background: rgba(239,154,154,0.3); }
.btn-treat { background: rgba(206,147,216,0.15); color: var(--treat); border: 1px solid rgba(206,147,216,0.3); }
.btn-treat:hover { background: rgba(206,147,216,0.3); }

/* ── Active Walk Banner ── */
.active-walk-banner {
    background: linear-gradient(135deg, #0d2137, #1a3a5c);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 20px rgba(79,195,247,0.2);
}
.walk-timer-label { flex: 1; font-weight: 700; }
.walk-timer { font-family: 'Nunito', sans-serif; font-size: 1.4rem; font-weight: 900; color: var(--accent); }
.btn-end-walk { background: var(--accent); color: #0a1520; }

/* ── Activity Feed ── */
.section { margin-bottom: 2rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 1.2rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; }

.activity-feed { display: flex; flex-direction: column; gap: 0.6rem; }
.activity-item {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.85rem 1rem;
    display: flex; gap: 0.75rem; align-items: flex-start;
    border-left: 3px solid transparent;
}
.activity-walk { border-left-color: var(--walk); }
.activity-potty { border-left-color: var(--poop); }
.activity-feeding { border-left-color: var(--feed); }
.activity-treat { border-left-color: var(--treat); }

.activity-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.9rem; color: #fff; flex-shrink: 0;
}
.activity-body { flex: 1; min-width: 0; }
.activity-header { font-size: 0.9rem; line-height: 1.4; }
.activity-who { font-weight: 700; }
.activity-notes { color: var(--text2); font-size: 0.82rem; margin-top: 0.2rem; font-style: italic; }
.activity-time { color: var(--text2); font-size: 0.78rem; margin-top: 0.3rem; }
.activity-photo { width: 60px; height: 60px; border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.activity-photo img { width: 100%; height: 100%; object-fit: cover; }

/* ── Modals ── */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 200; padding-bottom: env(safe-area-inset-bottom);
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.5rem; width: 100%; max-width: 500px;
    max-height: 90vh; overflow-y: auto;
}
.modal-content h3 { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1.2rem; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
.modal-actions .btn { flex: 1; }

/* ── Forms ── */
.form-group { margin-bottom: 0.9rem; }
.form-row { display: flex; gap: 0.75rem; }
.form-row .form-group { flex: 1; }
.form-label { display: block; font-weight: 700; font-size: 0.85rem; color: var(--text2); margin-bottom: 0.35rem; }
.form-input {
    width: 100%; background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    padding: 0.65rem 0.85rem; font-family: inherit; font-size: 0.95rem;
    transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-select { appearance: none; }
textarea.form-input { resize: vertical; }

/* ── Stats ── */
.stats-controls { margin-bottom: 1.25rem; }
.stats-form { display: flex; gap: 0.75rem; }
.stats-form .form-input { flex: 1; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.stat-card-highlight { flex-direction: row; align-items: center; gap: 0.75rem; grid-column: 1/-1; }
.stat-ok { border-left: 3px solid var(--success); }
.stat-caution { border-left: 3px solid var(--warn); }
.stat-warn { border-left: 3px solid var(--danger); }
.stat-icon { font-size: 1.5rem; }
.stat-label { color: var(--text2); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 1.5rem; color: var(--text); }

.chart-container { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.chart-title { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 0.95rem; color: var(--text2); margin-bottom: 1rem; }

.walkers-list { display: flex; flex-direction: column; gap: 0.6rem; }
.walker-row { display: flex; align-items: center; gap: 0.75rem; }
.walker-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.82rem; color: #fff; flex-shrink: 0; }
.walker-name { width: 100px; font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.walker-bar-wrap { flex: 1; background: var(--bg3); border-radius: 4px; height: 10px; overflow: hidden; }
.walker-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s ease; }
.walker-count { color: var(--text2); font-size: 0.82rem; white-space: nowrap; }

/* ── Dogs Grid ── */
.dogs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.dog-profile-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dog-profile-actions { margin-top: 0.75rem; }
.dog-profile-photo { height: 160px; background: var(--bg3); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.dog-profile-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.dog-profile-placeholder { font-size: 4rem; }
.dog-profile-info { padding: 1rem; }
.dog-profile-name { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 1.15rem; margin-bottom: 0.25rem; }
.dog-profile-breed { color: var(--text2); font-size: 0.85rem; margin-bottom: 0.5rem; }
.dog-meta { color: var(--text2); font-size: 0.82rem; margin-top: 0.25rem; }

/* ── Users Table ── */
.users-table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.users-table th { color: var(--text2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }
.users-table td { padding: 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tr.row-inactive td { opacity: 0.5; }
.user-row-name { display: flex; align-items: center; gap: 0.6rem; }
.user-badge { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem; color: #fff; flex-shrink: 0; }
.role-badge { padding: 0.2rem 0.55rem; border-radius: 20px; font-size: 0.78rem; font-weight: 700; }
.role-admin { background: rgba(79,195,247,0.2); color: var(--accent); }
.role-member { background: var(--bg3); color: var(--text2); }
.status-badge { padding: 0.2rem 0.55rem; border-radius: 20px; font-size: 0.78rem; font-weight: 700; }
.status-active { background: rgba(102,187,106,0.2); color: var(--success); }
.status-inactive { background: rgba(239,83,80,0.2); color: var(--danger); }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-container { width: 100%; max-width: 360px; padding: 2rem 1.5rem; }
.login-logo { font-size: 3.5rem; text-align: center; margin-bottom: 0.5rem; }
.login-title { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 2rem; text-align: center; color: var(--accent); }
.login-sub { color: var(--text2); text-align: center; margin-bottom: 2rem; }
.login-form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }

/* ── Misc ── */
.hidden { display: none !important; }
.empty-state { text-align: center; color: var(--text2); padding: 2rem; }
.empty-icon { font-size: 3rem; margin-bottom: 0.5rem; }
a { color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .nav-link { font-size: 0.8rem; padding: 0.35rem 0.45rem; }
    .users-table { font-size: 0.8rem; }
}

.btn-delete-activity {
    background: none; border: none; cursor: pointer;
    font-size: 1rem; opacity: 0; transition: opacity 0.15s;
    padding: 0.25rem; flex-shrink: 0; align-self: center;
    color: var(--danger, #e55);
}
.activity-item:hover .btn-delete-activity { opacity: 0.5; }
.btn-delete-activity:hover { opacity: 1 !important; }
