:root {
    --hh-primary: #4338ca;
    --hh-primary-dark: #3730a3;
    --hh-accent: #f59e0b;
    --hh-sidebar: #17153b;
    --hh-sidebar-text: #c7c9e8;
    --hh-sidebar-muted: #7375a5;
    --hh-bg: #f5f6fb;
    --hh-border: #e5e7eb;
    --bs-primary: #4338ca;
    --bs-primary-rgb: 67, 56, 202;
    --bs-link-color: #4338ca;
    --bs-link-color-rgb: 67, 56, 202;
    --bs-link-hover-color: #3730a3;
}

body { background: var(--hh-bg); font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .92rem; color: #1f2937; }
.btn-primary { --bs-btn-bg: var(--hh-primary); --bs-btn-border-color: var(--hh-primary); --bs-btn-hover-bg: var(--hh-primary-dark); --bs-btn-hover-border-color: var(--hh-primary-dark); --bs-btn-active-bg: var(--hh-primary-dark); --bs-btn-disabled-bg: var(--hh-primary); --bs-btn-disabled-border-color: var(--hh-primary); }
.btn-outline-primary { --bs-btn-color: var(--hh-primary); --bs-btn-border-color: var(--hh-primary); --bs-btn-hover-bg: var(--hh-primary); --bs-btn-hover-border-color: var(--hh-primary); --bs-btn-active-bg: var(--hh-primary); }
.text-bg-primary { background-color: var(--hh-primary) !important; }
.text-primary { color: var(--hh-primary) !important; }
.bg-primary { background-color: var(--hh-primary) !important; }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(67, 56, 202, .15); }
.form-check-input:checked { background-color: var(--hh-primary); border-color: var(--hh-primary); }
.min-w-0 { min-width: 0; }

/* ---------- App shell ---------- */
.hh-sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; background: var(--hh-sidebar); color: var(--hh-sidebar-text); display: flex; flex-direction: column; z-index: 1040; transition: transform .2s; }
.hh-brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.06); }
.hh-brand:hover { color: #fff; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #f59e0b); display: grid; place-items: center; font-size: 1.05rem; color: #fff; flex-shrink: 0; }
.hh-nav { padding: .75rem .65rem; overflow-y: auto; flex: 1; }
.hh-nav .section { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--hh-sidebar-muted); padding: .9rem .75rem .35rem; }
.hh-nav a { display: flex; align-items: center; gap: .7rem; color: var(--hh-sidebar-text); text-decoration: none; padding: .52rem .75rem; border-radius: 8px; margin-bottom: 2px; }
.hh-nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.hh-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.hh-nav a.active { background: rgba(129,140,248,.2); color: #fff; }
.hh-nav a .count { margin-left: auto; font-size: .7rem; background: rgba(255,255,255,.12); padding: .1rem .45rem; border-radius: 99px; }
.hh-nav a .count.warn { background: #f59e0b; color: #1f2937; font-weight: 600; }
.hh-sidebar-foot { padding: .9rem 1.25rem; border-top: 1px solid rgba(255,255,255,.06); font-size: .78rem; color: var(--hh-sidebar-muted); }
.hh-sidebar-foot a { color: #fcd34d; text-decoration: none; }

.hh-main { margin-left: 248px; min-height: 100vh; display: flex; flex-direction: column; }
.hh-topbar { position: sticky; top: 0; z-index: 1030; background: #fff; border-bottom: 1px solid var(--hh-border); height: 60px; display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; }
.hh-content { padding: 1.5rem; flex: 1; }
.hh-footer { padding: 1rem 1.5rem; color: #9ca3af; font-size: .78rem; }
.sidebar-backdrop { display: none; }

/* Mobile bottom navigation (household app) */
.hh-bottom-nav { display: none; }

@media (max-width: 991.98px) {
    .hh-sidebar { transform: translateX(-100%); }
    body.sidebar-open .hh-sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1035; }
    .hh-main { margin-left: 0; }
    .hh-content { padding: 1rem; }
    .hh-topbar { padding: 0 1rem; }
    .hh-bottom-nav { display: flex; position: fixed; inset: auto 0 0 0; z-index: 1030; background: #fff; border-top: 1px solid var(--hh-border); padding: .3rem 0 calc(.3rem + env(safe-area-inset-bottom)); }
    .hh-bottom-nav a { flex: 1; text-align: center; color: #6b7280; text-decoration: none; font-size: .68rem; line-height: 1.2; }
    .hh-bottom-nav a i { display: block; font-size: 1.25rem; }
    .hh-bottom-nav a.active { color: var(--hh-primary); font-weight: 600; }
    body.has-bottom-nav .hh-footer { padding-bottom: 5rem; }
}

/* ---------- Components ---------- */
.card { border: 1px solid var(--hh-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--hh-border); font-weight: 600; padding: .85rem 1.1rem; border-radius: 12px 12px 0 0 !important; }
.card-footer { border-radius: 0 0 12px 12px !important; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-sub { color: #6b7280; font-size: .85rem; }

.stat-card { padding: 1.1rem 1.2rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.stat-card .icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-card .value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-card .label { color: #6b7280; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.soft-icon { width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.soft-icon.sm { width: 30px; height: 30px; font-size: .9rem; border-radius: 8px; }
.soft-icon.lg { width: 48px; height: 48px; font-size: 1.4rem; border-radius: 12px; }
.bg-soft-primary { background: #eef2ff; color: #4338ca; }
.bg-soft-danger { background: #fef2f2; color: #dc2626; }
.bg-soft-warning { background: #fffbeb; color: #d97706; }
.bg-soft-success { background: #ecfdf5; color: #059669; }
.bg-soft-info { background: #ecfeff; color: #0891b2; }
.bg-soft-secondary { background: #f3f4f6; color: #4b5563; }

.table-hh { margin: 0; }
.table-hh th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; background: #f9fafb; white-space: nowrap; }
.table-hh td { vertical-align: middle; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: .78rem; background: #e0e7ff; color: #3730a3; flex-shrink: 0; }
.avatar.staff { background: #fef3c7; color: #92400e; }
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }

.pill-tabs .nav-link { color: #4b5563; border-radius: 8px; padding: .4rem .8rem; font-size: .85rem; }
.pill-tabs .nav-link.active { background: var(--hh-primary); color: #fff; }
.pill-tabs .nav-link .badge { font-weight: 500; }

.month-nav { display: inline-flex; align-items: center; gap: .25rem; background: #fff; border: 1px solid var(--hh-border); border-radius: 10px; padding: .15rem; }
.month-nav a { color: #4b5563; padding: .3rem .55rem; border-radius: 8px; text-decoration: none; }
.month-nav a:hover { background: #f3f4f6; }
.month-nav span { font-weight: 600; padding: 0 .4rem; min-width: 8.5rem; text-align: center; }

.progress { height: .55rem; border-radius: 99px; background: #eef0f4; }
.progress-bar { border-radius: 99px; }

/* ---------- Attendance calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; }
.cal .dow { font-size: .7rem; text-transform: uppercase; color: #9ca3af; text-align: center; font-weight: 600; letter-spacing: .05em; }
.cal-day { position: relative; border: 1px solid var(--hh-border); border-radius: 10px; background: #fff; min-height: 74px; padding: .35rem .45rem; text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; transition: transform .1s, box-shadow .1s; }
button.cal-day { cursor: pointer; }
button.cal-day:hover { box-shadow: 0 4px 12px rgba(16,24,40,.08); transform: translateY(-1px); }
.cal-day .d { font-size: .78rem; font-weight: 600; color: #6b7280; }
.cal-day .s { margin-top: auto; font-size: .78rem; font-weight: 600; display: flex; align-items: center; gap: .25rem; }
.cal-day .q { font-size: .7rem; color: #6b7280; }
.cal-day.today { outline: 2px solid var(--hh-primary); outline-offset: 1px; }
.cal-day.delivered { background: #f0fdf4; border-color: #bbf7d0; }
.cal-day.delivered .s { color: #15803d; }
.cal-day.absent { background: #fef2f2; border-color: #fecaca; }
.cal-day.absent .s { color: #dc2626; }
.cal-day.unmarked { background: #fffbeb; border-color: #fde68a; }
.cal-day.unmarked .s { color: #b45309; }
.cal-day.upcoming { background: #fafafa; border-style: dashed; }
.cal-day.upcoming .s { color: #9ca3af; font-weight: 500; }
.cal-day.off { background: #f9fafb; color: #9ca3af; }
.cal-day .dot { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--hh-accent); }
.cal-blank { min-height: 74px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .75rem; color: #6b7280; }
.cal-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; border: 1px solid; }
@media (max-width: 575.98px) {
    .cal { gap: .25rem; }
    .cal-day, .cal-blank { min-height: 54px; padding: .25rem; }
    .cal-day .q { display: none; }
}

/* Today's delivery tiles on the dashboard */
.today-tile { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid #f1f2f6; }
.today-tile:last-child { border-bottom: 0; }
.today-tile .btn-group .btn { min-width: 2.6rem; }

/* Lists */
.list-row { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; border-bottom: 1px solid #f1f2f6; }
.list-row:last-child { border-bottom: 0; }
.list-row .title { font-weight: 600; color: #111827; text-decoration: none; }
.list-row .title:hover { color: var(--hh-primary); }
.check-btn { border: 2px solid #c7cbd6; width: 22px; height: 22px; border-radius: 50%; background: #fff; display: inline-grid; place-items: center; padding: 0; color: transparent; flex-shrink: 0; }
.check-btn:hover { border-color: var(--hh-primary); color: var(--hh-primary); }
.check-btn.done { background: #22c55e; border-color: #22c55e; color: #fff; }
.done-text { text-decoration: line-through; color: #9ca3af !important; }
.prio-high { border-left: 3px solid #ef4444; }
.prio-low { opacity: .9; }

.shop-item { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px dashed #eceef3; }
.shop-item:last-child { border-bottom: 0; }

.bill-card { display: flex; gap: .9rem; align-items: center; padding: .85rem 1rem; border-bottom: 1px solid #f1f2f6; }
.bill-card:last-child { border-bottom: 0; }
.bill-card .name { font-weight: 600; color: #111827; text-decoration: none; }
.bill-card .name:hover { color: var(--hh-primary); }
.group-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: #6b7280; padding: .6rem 1rem; background: #f9fafb; border-bottom: 1px solid #f1f2f6; }

.detail-list dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; }
.detail-list dd { margin-bottom: .75rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: #6b7280; }
.empty-state i { font-size: 2.5rem; color: #c7d2fe; }

.onboard-step { display: flex; gap: .75rem; align-items: center; padding: .65rem .2rem; text-decoration: none; color: #374151; border-bottom: 1px dashed #e5e7eb; }
.onboard-step:last-child { border-bottom: 0; }
.onboard-step .num { width: 26px; height: 26px; border-radius: 50%; background: #eef2ff; color: #4338ca; display: grid; place-items: center; font-weight: 700; font-size: .78rem; flex-shrink: 0; }
.onboard-step.done .num { background: #22c55e; color: #fff; }
.onboard-step.done span.t { text-decoration: line-through; color: #9ca3af; }

.hero-card { background: linear-gradient(135deg, #312e81, #4338ca 55%, #b45309); color: #fff; border: 0; }
.hero-card .text-muted, .hero-card .small { color: rgba(255,255,255,.75) !important; }

.plan-card { border: 2px solid var(--hh-border); }
.plan-card.current { border-color: #22c55e; }
.plan-card.featured { border-color: var(--hh-primary); box-shadow: 0 12px 30px -12px rgba(67,56,202,.35); }
.plan-card .price { font-size: 2rem; font-weight: 800; }
.plan-card ul { list-style: none; padding: 0; }
.plan-card li { padding: .3rem 0; }
.plan-card li i { color: #22c55e; margin-right: .4rem; }

/* Notifications dropdown */
.bell-menu { width: 360px; max-height: 460px; overflow-y: auto; padding: 0; }
.bell-menu .item { display: block; padding: .7rem 1rem; border-bottom: 1px solid #f3f4f6; text-decoration: none; color: #374151; font-size: .82rem; }
.bell-menu .item.unread { background: #eef2ff; }
.bell-menu .item:hover { background: #f9fafb; }
.bell-menu .item .t { font-weight: 600; color: #111827; }
.bell-badge { position: absolute; top: 2px; right: 0; font-size: .6rem; }
@media (max-width: 575.98px) { .bell-menu { width: 300px; } }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: linear-gradient(140deg, #1e1b4b, #4338ca 60%, #b45309); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side a { color: #fff; text-decoration: none; }
.auth-side h1 { font-weight: 800; font-size: 2.1rem; line-height: 1.2; }
.auth-side .feature { display: flex; gap: .8rem; margin-bottom: 1rem; opacity: .95; }
.auth-side .feature i { font-size: 1.3rem; color: #fcd34d; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 420px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

.form-label { font-weight: 500; font-size: .85rem; }
.required::after { content: " *"; color: #dc2626; }
.weekday-picker .btn { min-width: 3rem; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

@media print {
    .hh-sidebar, .hh-topbar, .hh-bottom-nav, .hh-footer, .no-print { display: none !important; }
    .hh-main { margin: 0; }
    body { background: #fff; }
}
