/* ─── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; }
body { height: 100%; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; overflow: hidden; }

/* ─── Theme variables ───────────────────────────────────────── */
:root {
  --accent:    #38bdf8;
  --accent-2:  #818cf8;
  --danger:    #f87171;
  --success:   #4ade80;
  --warning:   #fbbf24;
}

[data-theme="dark"] {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #334155;
  --border:    #334155;
  --text:      #e2e8f0;
  --text-2:    #94a3b8;
  --text-inv:  #0f172a;
  --shadow:    0 4px 24px #0006;
}
[data-theme="light"] {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface2:  #e2e8f0;
  --border:    #cbd5e1;
  --text:      #0f172a;
  --text-2:    #475569;
  --text-inv:  #ffffff;
  --shadow:    0 4px 24px #0001;
}

body { background: var(--bg); color: var(--text); }

/* ─── Layout ────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.app-logo { font-size: 1.6rem; }
.app-name { font-size: 1.1rem; font-weight: 700; flex: 1; }
.sidebar-close { display: none; }

.nav-list { list-style: none; flex: 1; overflow-y: auto; padding: .5rem 0; }
.nav-list li { }
.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  text-decoration: none;
  color: var(--text-2);
  border-radius: .5rem;
  margin: .1rem .5rem;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--accent); color: var(--text-inv); }
.nav-link.active .badge { background: var(--text-inv); color: var(--accent); }
.nav-icon { width: 1.4rem; text-align: center; font-size: 1.1rem; }

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .6rem;
}
.user-avatar {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inv);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .9rem;
}
.role-badge {
  font-size: .7rem;
  padding: .1rem .4rem;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--text-2);
  text-transform: capitalize;
}
.sidebar-actions { display: flex; gap: .5rem; }

/* ─── Topbar (mobile) ───────────────────────────────────────── */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 .75rem;
  gap: .75rem;
  z-index: 300;
}
.topbar-title { flex: 1; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

/* ─── Main area ─────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.view {
  flex: 1;
  padding: 1.5rem;
}

/* ─── Shared components ─────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  font-size: 1.1rem;
  padding: .35rem;
  border-radius: .4rem;
  line-height: 1;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: .5rem;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary   { background: var(--accent);  color: var(--text-inv); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-success   { background: var(--success); color: #0f172a; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.badge {
  display: inline-block;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.25rem;
  padding: 0 .3rem;
}
.topbar-notif { position: absolute; top: 10px; right: 44px; }

/* ─── Page headers ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title { font-size: 1.4rem; font-weight: 700; }

/* ─── Forms & inputs ─────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  color: var(--text-2);
  margin-bottom: .3rem;
}
input, select, textarea {
  width: 100%;
  padding: .55rem .75rem;
  border-radius: .5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
textarea { resize: vertical; min-height: 80px; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: #0008;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: 1rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px #0009;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 1.25rem;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: .75rem; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem 1rem; text-align: left; white-space: nowrap; }
th { background: var(--surface2); font-size: .8rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
tr + tr td { border-top: 1px solid var(--border); }
tr:hover td { background: var(--surface2); }

/* ─── Dashboard ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.stat-label { font-size: .8rem; color: var(--text-2); }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-icon  { font-size: 1.5rem; }

/* ─── Calendar ───────────────────────────────────────────────── */
.cal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.cal-month { font-size: 1.1rem; font-weight: 700; flex: 1; text-align: center; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day-name {
  text-align: center;
  padding: .4rem;
  font-size: .75rem;
  color: var(--text-2);
  font-weight: 600;
}
.cal-day {
  min-height: 70px;
  border-radius: .4rem;
  padding: .3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: .85rem;
  transition: background .1s;
  overflow: hidden;
}
.cal-day:hover { background: var(--surface2); }
.cal-day.today { border-color: var(--accent); }
.cal-day.other-month { opacity: .4; }
.cal-date { font-weight: 700; margin-bottom: .15rem; }
.cal-event-dot {
  font-size: .7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: .1rem .3rem;
  border-radius: .2rem;
  background: var(--accent);
  color: var(--text-inv);
  margin-top: 1px;
}

/* ─── Tasks / Kanban ─────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1rem;
  min-height: 200px;
}
.kanban-col-header {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .75rem;
  margin-bottom: .5rem;
  cursor: pointer;
  transition: box-shadow .15s;
}
.task-card:hover { box-shadow: var(--shadow); }
.task-title { font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.task-meta  { font-size: .75rem; color: var(--text-2); display: flex; gap: .5rem; flex-wrap: wrap; }
.priority-high   { border-left: 3px solid var(--danger); }
.priority-medium { border-left: 3px solid var(--warning); }
.priority-low    { border-left: 3px solid var(--success); }

/* ─── GPS Map ────────────────────────────────────────────────── */
#gps-map {
  height: calc(100vh - 200px);
  border-radius: .75rem;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ─── Messages ───────────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  height: calc(100vh - 180px);
}
.contact-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  overflow-y: auto;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.contact-item:hover, .contact-item.active { background: var(--surface2); }
.contact-avatar {
  width: 2.2rem; height: 2.2rem;
  border-radius: 50%;
  background: var(--accent-2);
  color: var(--text-inv);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.contact-name { font-size: .9rem; font-weight: 600; }
.contact-role { font-size: .72rem; color: var(--text-2); }

.chat-window {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  overflow: hidden;
}
.chat-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.msg-bubble {
  max-width: 70%;
  padding: .6rem .9rem;
  border-radius: 1rem;
  font-size: .9rem;
  line-height: 1.4;
}
.msg-me {
  align-self: flex-end;
  background: var(--accent);
  color: var(--text-inv);
  border-bottom-right-radius: .2rem;
}
.msg-other {
  align-self: flex-start;
  background: var(--surface2);
  border-bottom-left-radius: .2rem;
}
.msg-time { font-size: .7rem; opacity: .6; margin-top: .2rem; }
.chat-input-row {
  display: flex;
  gap: .5rem;
  padding: .75rem;
  border-top: 1px solid var(--border);
}
.chat-input-row input { flex: 1; }

/* ─── Voice call ─────────────────────────────────────────────── */
.voice-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding-top: 2rem;
}
.voice-avatar {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inv);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}
.voice-status { font-size: 1rem; color: var(--text-2); }
.voice-controls { display: flex; gap: 1rem; }
.call-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  font-size: 1.5rem;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.call-btn-green  { background: var(--success); color: #0f172a; }
.call-btn-red    { background: var(--danger); color: #fff; }
.call-btn-mute   { background: var(--surface2); color: var(--text); }
.call-btn:hover  { opacity: .85; }
.user-select-row { display: flex; gap: .75rem; align-items: center; }
.user-select-row select { max-width: 200px; }

/* ─── Alarms ─────────────────────────────────────────────────── */
.alarm-list { display: flex; flex-direction: column; gap: .75rem; }
.alarm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.alarm-time  { font-size: 1.5rem; font-weight: 700; min-width: 5rem; }
.alarm-info  { flex: 1; }
.alarm-title { font-weight: 600; }
.alarm-meta  { font-size: .8rem; color: var(--text-2); margin-top: .15rem; }
.alarm-toggle {
  width: 42px; height: 24px;
  background: var(--surface2);
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  border: none;
  transition: background .2s;
  flex-shrink: 0;
}
.alarm-toggle.on  { background: var(--success); }
.alarm-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: left .2s;
}
.alarm-toggle.on::after { left: 20px; }

/* ─── Users page ─────────────────────────────────────────────── */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  text-align: center;
}
.user-card-avatar {
  width: 3.5rem; height: 3.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inv);
  font-size: 1.4rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-card-name { font-weight: 700; }
.user-card-role {
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--text-2);
  text-transform: capitalize;
}
.user-card-actions { display: flex; gap: .5rem; margin-top: .25rem; }

/* ─── Notifications drawer ───────────────────────────────────── */
.notif-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 320px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
  box-shadow: var(--shadow);
}
.notif-drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.notif-list { flex: 1; overflow-y: auto; }
.notif-item {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.notif-item-title  { font-weight: 600; font-size: .9rem; }
.notif-item-body   { font-size: .8rem; color: var(--text-2); margin-top: .2rem; }
.notif-item-time   { font-size: .72rem; color: var(--text-2); margin-top: .25rem; }

/* ─── Overlay ────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: #0006;
  z-index: 150;
}
.overlay.hidden { display: none; }

/* ─── Login screen ───────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-screen.hidden { display: none; }
.login-card {
  background: var(--surface);
  border-radius: 1.25rem;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 60px #0009;
}
.login-logo { font-size: 2.5rem; text-align: center; margin-bottom: .5rem; }
.login-title { text-align: center; font-size: 1.3rem; font-weight: 700; margin-bottom: 1.5rem; }
.login-error {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  padding: .6rem .8rem;
  border-radius: .5rem;
  font-size: .85rem;
  margin-bottom: 1rem;
}
.login-footer { text-align: center; font-size: .85rem; color: var(--text-2); margin-top: 1rem; }
.login-footer a { color: var(--accent); text-decoration: none; }

/* ─── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.text-muted { color: var(--text-2); font-size: .85rem; }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-2);
  font-size: 1rem;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.spinner {
  display: inline-block;
  width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vw #0006;
  }
  .sidebar-close { display: inline-flex; }
  .topbar { display: flex; }
  .main { padding-top: 56px; }
  .view { padding: 1rem; }
  .kanban { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .contact-list { max-height: 200px; }
  #gps-map { height: 60vh; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .users-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── SOS ─────────────────────────────────────────────────────── */
.sos-child-view { display:flex; flex-direction:column; align-items:center; padding:2rem 1rem; gap:1.5rem; }
.sos-description { text-align:center; color:var(--text-2); max-width:320px; }
.sos-button {
  width:160px; height:160px; border-radius:50%;
  background:linear-gradient(135deg,#ef4444,#b91c1c);
  border:4px solid #fca5a5;
  color:#fff; font-size:1.1rem; font-weight:700;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.5rem;
  cursor:pointer; box-shadow:0 0 0 0 #ef444455;
  animation:sos-pulse 2s infinite;
  transition:transform .1s;
}
.sos-button:active { transform:scale(.95); }
.sos-button:disabled { opacity:.5; animation:none; }
.sos-icon { font-size:2.5rem; }
@keyframes sos-pulse { 0%,100%{box-shadow:0 0 0 0 #ef444455} 70%{box-shadow:0 0 0 20px #ef444400} }
.sos-hint { font-size:.78rem; color:var(--text-2); text-align:center; }
.sos-status { padding:.75rem 1.25rem; border-radius:.5rem; text-align:center; }
.sos-sent  { background:#14532d; color:#86efac; }
.sos-error { background:#7f1d1d; color:#fca5a5; }
.sos-event-row { display:flex; align-items:center; gap:.75rem; padding:.5rem 0; border-bottom:1px solid var(--border); }
.sos-time { font-size:.8rem; color:var(--text-2); min-width:70px; }
.sos-map-link { font-size:.85rem; }
.sos-msg { font-size:.85rem; color:var(--text-2); }
.sos-list { display:flex; flex-direction:column; gap:.75rem; }
.sos-event-card { background:var(--surface); border:1px solid var(--border); border-radius:.75rem; padding:1rem; }
.sos-event-header { display:flex; align-items:center; gap:.5rem; margin-bottom:.75rem; }
.sos-child-badge { font-weight:700; color:var(--danger); flex:1; }
.sos-event-time { font-size:.8rem; color:var(--text-2); }
.sos-del { color:var(--text-2); font-size:.75rem; }

/* ─── Chores ─────────────────────────────────────────────────── */
.chores-list { display:flex; flex-direction:column; gap:.75rem; }
.chore-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:.75rem; padding:1rem; transition:opacity .2s;
}
.chore-done { opacity:.6; }
.chore-top { display:flex; align-items:flex-start; gap:.75rem; }
.chore-check { font-size:1.4rem; line-height:1; }
.chore-info { flex:1; }
.chore-title { font-weight:600; font-size:1rem; }
.chore-meta { font-size:.8rem; color:var(--text-2); margin-top:.2rem; }
.chore-pts { color:var(--warning); font-weight:600; }
.chore-actions { display:flex; gap:.5rem; flex-wrap:wrap; margin-top:.75rem; }

/* ─── Photos ─────────────────────────────────────────────────── */
.photo-grid {
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(150px,1fr));
  gap:.75rem; padding:.5rem 0;
}
.photo-tile {
  position:relative; aspect-ratio:1; overflow:hidden;
  border-radius:.5rem; cursor:pointer; background:var(--surface);
}
.photo-tile img { width:100%; height:100%; object-fit:cover; transition:transform .2s; }
.photo-tile:hover img { transform:scale(1.05); }
.photo-tile-overlay {
  position:absolute; bottom:0; left:0; right:0;
  background:linear-gradient(transparent,#000a);
  padding:.5rem; display:flex; flex-direction:column;
  font-size:.7rem; color:#fff;
}
.lightbox { position:fixed; inset:0; z-index:1000; display:flex; align-items:center; justify-content:center; }
.lightbox-backdrop { position:absolute; inset:0; background:#000c; }
.lightbox-content { position:relative; max-width:90vw; max-height:90vh; display:flex; flex-direction:column; align-items:center; gap:.75rem; }
.lightbox-content img { max-width:100%; max-height:70vh; border-radius:.5rem; object-fit:contain; }
.lightbox-close { position:absolute; top:-2rem; right:0; color:#fff; font-size:1.2rem; }
.lightbox-meta { background:#000a; color:#fff; border-radius:.5rem; padding:.75rem 1rem; min-width:200px; text-align:center; }
.lb-uploader { font-weight:700; }
.lb-time { font-size:.8rem; opacity:.7; }
.lb-caption { margin-top:.5rem; font-style:italic; }
.lb-del { margin-top:.75rem; }

/* ─── Homework ───────────────────────────────────────────────── */
.hw-list { display:flex; flex-direction:column; gap:.75rem; }
.hw-card { background:var(--surface); border:1px solid var(--border); border-radius:.75rem; padding:1rem; }
.hw-submitted    { border-left:3px solid var(--info); }
.hw-reviewed     { border-left:3px solid var(--success); }
.hw-needs_revision { border-left:3px solid var(--warning); }
.hw-card-header { display:flex; align-items:flex-start; gap:.75rem; }
.hw-status-icon { font-size:1.5rem; line-height:1; }
.hw-info { flex:1; }
.hw-subject { font-weight:700; font-size:1rem; }
.hw-meta { font-size:.8rem; color:var(--text-2); margin-top:.2rem; display:flex; gap:.5rem; flex-wrap:wrap; }
.hw-status-badge { background:var(--surface2); padding:.1rem .4rem; border-radius:.25rem; }
.hw-desc { font-size:.9rem; margin:.5rem 0; color:var(--text-2); }
.hw-photo-thumb { width:80px; height:80px; object-fit:cover; border-radius:.4rem; cursor:pointer; }
.hw-reviewer { font-size:.8rem; color:var(--success); margin:.25rem 0; }
.hw-actions { display:flex; gap:.5rem; flex-wrap:wrap; margin-top:.75rem; }
.btn-success { background:var(--success); color:#0f172a; }
.btn-warning { background:var(--warning); color:#0f172a; }

/* ─── Screen Time ─────────────────────────────────────────────── */
.st-child-view { display:flex; flex-direction:column; align-items:center; padding:2rem 1rem; gap:1.5rem; }
.st-ring-wrap { position:relative; width:160px; height:160px; }
.st-ring { width:100%; height:100%; }
.st-ring-bg   { fill:none; stroke:var(--surface2); stroke-width:10; }
.st-ring-fill { fill:none; stroke-width:10; stroke-linecap:round; transition:stroke-dasharray .5s; }
.st-ring-ok      { stroke:var(--success); }
.st-ring-warning { stroke:var(--warning); }
.st-ring-danger  { stroke:var(--danger); }
.st-ring-text { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.st-remaining { font-size:2rem; font-weight:700; }
.st-remaining-label { font-size:.7rem; color:var(--text-2); text-align:center; }
.st-details { width:100%; max-width:280px; }
.st-row { display:flex; justify-content:space-between; padding:.4rem 0; border-bottom:1px solid var(--border); font-size:.9rem; }
.st-no-limit { color:var(--text-2); font-size:1.1rem; text-align:center; padding:2rem; }
.st-list { display:flex; flex-direction:column; gap:1rem; }
.st-child-row { background:var(--surface); border:1px solid var(--border); border-radius:.75rem; padding:1rem; display:flex; align-items:center; gap:1rem; flex-wrap:wrap; }
.st-child-info { flex:1; min-width:180px; }
.st-child-name { font-weight:700; margin-bottom:.25rem; }
.st-child-meta { font-size:.85rem; color:var(--text-2); margin-bottom:.4rem; }
.st-bar-wrap { height:6px; background:var(--surface2); border-radius:3px; overflow:hidden; }
.st-bar { height:100%; border-radius:3px; transition:width .4s; }
.st-bar-ok      { background:var(--success); }
.st-bar-warning { background:var(--warning); }
.st-bar-danger  { background:var(--danger); }
.st-child-actions { display:flex; gap:.5rem; flex-wrap:wrap; }

/* ─── Password Vault ─────────────────────────────────────────── */
.vault-toolbar { display:flex; flex-direction:column; gap:.5rem; margin-bottom:1rem; }
.vault-type-filter { display:flex; gap:.4rem; flex-wrap:wrap; }
.type-filter-btn {
  padding:.25rem .6rem; border-radius:1rem; border:1px solid var(--border);
  background:var(--surface); color:var(--text-2); font-size:.8rem; cursor:pointer;
  transition:background .15s,color .15s;
}
.type-filter-btn.active { background:var(--accent); color:#0f172a; border-color:var(--accent); }
.vault-list { display:flex; flex-direction:column; gap:.75rem; }
.vault-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:.75rem; padding:1rem;
}
.vault-card-header { display:flex; align-items:center; gap:.5rem; margin-bottom:.4rem; flex-wrap:wrap; }
.vault-type-icon { font-size:1.25rem; }
.vault-title { font-weight:700; font-size:1rem; flex:1; }
.vault-type-badge {
  font-size:.68rem; padding:.1rem .4rem; border-radius:.3rem; font-weight:600;
  background:var(--surface2); color:var(--text-2);
}
.type-login    { background:#dbeafe; color:#1e3a5f; }
.type-card     { background:#fef9c3; color:#5c4b00; }
.type-wifi     { background:#d1fae5; color:#064e3b; }
.type-identity { background:#ede9fe; color:#3b0764; }
.type-note     { background:#fee2e2; color:#7f1d1d; }
.vault-share-pill {
  font-size:.72rem; padding:.1rem .45rem; border-radius:1rem;
  border:1px solid var(--border); white-space:nowrap;
}
.vault-share-pill.family  { background:#d1fae5; color:#065f46; border-color:#6ee7b7; }
.vault-share-pill.shared  { background:#dbeafe; color:#1e3a5f; border-color:#93c5fd; }
.vault-share-pill.private { color:var(--text-2); }
.vault-from-badge { font-size:.75rem; color:var(--text-2); font-style:italic; margin-bottom:.25rem; display:block; }
.vault-url { font-size:.78rem; color:var(--accent); word-break:break-all; display:block; margin:.15rem 0 .4rem; }
.vault-row { display:flex; align-items:center; gap:.4rem; margin:.2rem 0; font-size:.88rem; }
.vault-lbl { color:var(--text-2); min-width:72px; font-size:.78rem; }
.vault-username { font-family:monospace; }
.vault-secret { font-family:monospace; letter-spacing:.08em; }
.vault-note-preview { letter-spacing:0; font-style:italic; color:var(--text-2); }
.vault-notes { font-size:.8rem; color:var(--text-2); margin:.4rem 0 0; }
.vault-share-names { font-size:.75rem; color:var(--text-2); margin:.3rem 0 0; }
.vault-card-footer { display:flex; align-items:center; gap:.4rem; flex-wrap:wrap; margin-top:.75rem; border-top:1px solid var(--border); padding-top:.6rem; }
.vault-meta { font-size:.75rem; color:var(--text-2); flex:1; }
.btn-icon { background:none; border:none; cursor:pointer; font-size:.95rem; padding:.1rem .25rem; line-height:1; opacity:.8; }
.btn-icon:hover { opacity:1; }
.pass-input-wrap { display:flex; align-items:center; gap:.3rem; }
.pass-input-wrap input { flex:1; }
.modal-box-lg { max-width:520px; }
/* Vault groups — filter bar */
.vault-group-filter { display:flex; gap:.4rem; flex-wrap:wrap; }
.group-filter-btn {
  display:flex; align-items:center; gap:.3rem;
  padding:.3rem .65rem; border-radius:1rem; border:1px solid var(--border);
  background:var(--surface); color:var(--text-2); font-size:.8rem; cursor:pointer;
  white-space:nowrap;
}
.group-filter-btn.active { background:var(--accent); color:#0f172a; border-color:var(--accent); }
.group-dot-sm {
  display:inline-block; width:.5rem; height:.5rem; border-radius:50%;
  flex-shrink:0;
}
.group-count { font-size:.7rem; opacity:.7; margin-left:.1rem; }
/* Vault groups — card tags */
.vault-group-tags { display:flex; gap:.3rem; flex-wrap:wrap; margin:.25rem 0 .35rem; }
.vault-group-tag {
  display:inline-flex; align-items:center; gap:.25rem;
  font-size:.72rem; padding:.1rem .45rem; border-radius:1rem;
  border:1px solid; font-weight:500;
}
/* Vault groups — entry modal */
.vault-groups-assign { border:1px solid var(--border); border-radius:.5rem; padding:.6rem .75rem; margin:.5rem 0; }
.vault-groups-assign legend { font-size:.8rem; color:var(--text-2); padding:0 .3rem; }
.vault-group-checks { display:flex; flex-wrap:wrap; gap:.5rem; margin-top:.4rem; }
.vault-group-check-label {
  display:flex; align-items:center; gap:.35rem;
  font-size:.85rem; cursor:pointer; padding:.25rem .5rem;
  border:1px solid var(--border); border-radius:.5rem; background:var(--surface);
}
.vault-group-check-label input[type=checkbox] { accent-color:var(--accent); }
/* Vault groups — management modal */
.group-mgmt-list { display:flex; flex-direction:column; gap:.4rem; margin-bottom:.75rem; max-height:260px; overflow-y:auto; }
.group-mgmt-row {
  display:flex; align-items:center; gap:.5rem;
  padding:.4rem .6rem; border-radius:.5rem;
  border:1px solid var(--border); background:var(--surface);
}
.group-dot {
  width:.75rem; height:.75rem; border-radius:50%; flex-shrink:0;
}
.group-mgmt-name { flex:1; font-weight:500; font-size:.9rem; }
.group-mgmt-count { font-size:.72rem; }
.group-create-form { display:flex; gap:.5rem; flex-wrap:wrap; align-items:flex-start; margin-bottom:.5rem; }
.group-color-picker { display:flex; gap:.3rem; flex-wrap:wrap; padding:.25rem 0; }
.group-color-swatch {
  width:1.3rem; height:1.3rem; border-radius:50%; cursor:pointer;
  border:2px solid transparent; transition:transform .1s, border-color .1s; flex-shrink:0;
}
.group-color-swatch.active,
.group-color-swatch:hover { transform:scale(1.2); border-color:#fff; }
/* Type picker in modal */
.type-picker { display:flex; gap:.4rem; flex-wrap:wrap; margin-top:.3rem; }
.type-pick-btn {
  padding:.3rem .65rem; border-radius:1rem; border:1px solid var(--border);
  background:var(--surface); color:var(--text-2); font-size:.8rem; cursor:pointer;
}
.type-pick-btn.active { background:var(--accent); color:#0f172a; border-color:var(--accent); }
/* Share modal */
.share-global-label { display:flex; align-items:center; gap:.75rem; margin-bottom:.75rem; }
.share-global-label select { flex:1; }
.share-user-list { display:flex; flex-direction:column; gap:.4rem; max-height:280px; overflow-y:auto; margin-bottom:.75rem; }
.share-user-row {
  display:flex; align-items:center; gap:.6rem;
  padding:.5rem .6rem; border-radius:.5rem;
  border:1px solid var(--border); background:var(--surface);
  cursor:pointer;
}
.share-user-row.shared { border-color:var(--accent); background:color-mix(in srgb,var(--accent) 8%,transparent); }
.share-user-avatar {
  width:2rem; height:2rem; border-radius:50%;
  background:var(--accent); color:#0f172a;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:.85rem; flex-shrink:0;
}
.share-user-name { flex:1; font-weight:500; }
.share-user-row input[type=checkbox] { width:1.1rem; height:1.1rem; accent-color:var(--accent); }
/* Toast */
.toast {
  position:fixed; bottom:1.5rem; left:50%; transform:translateX(-50%);
  background:var(--surface); border:1px solid var(--border);
  color:var(--text); padding:.6rem 1.2rem; border-radius:2rem;
  font-size:.9rem; z-index:9999; pointer-events:none;
  animation:fadeInOut 2s forwards;
}
@keyframes fadeInOut { 0%{opacity:0} 10%{opacity:1} 80%{opacity:1} 100%{opacity:0} }

/* ─── Shopping List ──────────────────────────────────────────── */
.shopping-list { display:flex; flex-direction:column; gap:.3rem; margin-bottom:1rem; }
.shop-divider { font-size:.75rem; text-transform:uppercase; letter-spacing:.08em; color:var(--text-2); padding:.5rem 0 .25rem; }
.shop-item {
  display:flex; align-items:center; justify-content:space-between;
  background:var(--surface); border:1px solid var(--border);
  border-radius:.6rem; padding:.6rem .85rem; gap:.5rem;
  transition:opacity .2s;
}
.shop-item.bought { opacity:.55; }
.shop-check-label { display:flex; align-items:center; gap:.6rem; flex:1; cursor:pointer; }
.shop-check { width:1.1rem; height:1.1rem; accent-color:var(--accent); cursor:pointer; }
.shop-item.bought .shop-name { text-decoration:line-through; }
.shop-name { font-weight:500; }
.shop-qty { font-size:.8rem; color:var(--text-2); }
.shop-meta { display:flex; align-items:center; gap:.5rem; font-size:.78rem; color:var(--text-2); }
.shop-buyer { color:var(--success); }
.shopping-footer { padding:.5rem 0; }

/* ─── Emergency Contacts ─────────────────────────────────────── */
.contact-list { display:flex; flex-direction:column; gap:.75rem; }
.contact-card {
  display:flex; align-items:flex-start; gap:1rem;
  background:var(--surface); border:1px solid var(--border);
  border-radius:.75rem; padding:1rem;
}
.contact-avatar {
  width:2.75rem; height:2.75rem; border-radius:50%;
  background:var(--accent); color:#0f172a;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:1.1rem; flex-shrink:0; text-transform:uppercase;
}
.contact-info { flex:1; min-width:0; }
.contact-name { font-weight:700; font-size:1rem; }
.contact-rel { display:inline-block; font-size:.72rem; margin:.2rem 0; }
.contact-phone { display:block; color:var(--accent); font-size:.9rem; margin:.2rem 0; text-decoration:none; }
.contact-address { font-size:.8rem; color:var(--text-2); margin:.15rem 0; }
.contact-notes { font-size:.8rem; color:var(--text-2); margin:.15rem 0; }
.contact-meta { font-size:.72rem; color:var(--text-2); margin-top:.3rem; }
.contact-actions { display:flex; flex-direction:column; gap:.4rem; flex-shrink:0; }

/* ─── Shared Notes ───────────────────────────────────────────── */
.note-grid {
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:1rem; align-items:start;
}
.note-card {
  border-radius:.75rem; padding:1rem;
  box-shadow:0 2px 8px #0003;
  display:flex; flex-direction:column; gap:.5rem;
  border-top:3px solid transparent;
}
.note-card.pinned { border-top-color: #f59e0b; }
.note-yellow { background:#fef08a; color:#1c1917; }
.note-blue   { background:#bae6fd; color:#0c1a2e; }
.note-green  { background:#bbf7d0; color:#052e16; }
.note-pink   { background:#fbcfe8; color:#500724; }
.note-purple { background:#e9d5ff; color:#2e1065; }
.note-header { display:flex; align-items:center; gap:.4rem; }
.note-title { font-weight:700; font-size:.95rem; flex:1; word-break:break-word; }
.note-header-actions { display:flex; align-items:center; gap:.2rem; }
.pin-indicator { font-size:.85rem; }
.note-body { font-size:.88rem; line-height:1.5; white-space:pre-wrap; word-break:break-word; }
.note-footer { display:flex; align-items:center; gap:.5rem; margin-top:.25rem; }
.note-meta { font-size:.72rem; flex:1; opacity:.65; }
.note-actions { display:flex; gap:.2rem; }
.note-color-picker { display:flex; gap:.5rem; margin-top:.25rem; flex-wrap:wrap; }
.color-swatch {
  width:2rem; height:2rem; border-radius:50%; cursor:pointer;
  border:2px solid transparent; transition:transform .1s,border-color .1s;
}
.color-swatch.selected,
.color-swatch:hover { transform:scale(1.15); border-color:#fff; }
.color-yellow { background:#fef08a; }
.color-blue   { background:#bae6fd; }
.color-green  { background:#bbf7d0; }
.color-pink   { background:#fbcfe8; }
.color-purple { background:#e9d5ff; }
.checkbox-label { display:flex; align-items:center; gap:.5rem; cursor:pointer; font-size:.9rem; margin-top:.5rem; }
