:root{
  --bg:#f3f6fb;
  --surface:#ffffff;
  --surface2:#f8faff;
  --sidebar:#0b1727;

  --text:#142033;
  --muted:#74849c;
  --border:#dce5f0;

  --accent:#1267e8;
  --accent-hover:#0757cc;

  --danger:#dc4051;
  --success:#158653;

  --shadow:0 8px 28px rgba(22,39,65,.07);
}

html[data-theme="dark"]{
  --bg:#081321;
  --surface:#111f33;
  --surface2:#16263c;
  --sidebar:#07111e;

  --text:#f3f7fd;
  --muted:#9fb0c7;
  --border:#2c4059;

  --accent:#2785ff;
  --accent-hover:#4395ff;

  --danger:#e74d60;
  --success:#49c98a;

  --shadow:0 10px 30px rgba(0,0,0,.18);
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  min-height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,Segoe UI,Arial,sans-serif;
}

button,
input,
select{
  font:inherit;
}

button{
  cursor:pointer;
}

.hidden{
  display:none !important;
}

.muted{
  color:var(--muted);
}

.error{
  margin-top:12px;
  color:var(--danger);
}


/* AUTH */

.auth-page{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:32px;
  background:var(--bg);
}

.auth-card{
  width:min(460px,100%);
  padding:32px;

  background:var(--surface);
  border:1px solid var(--border);
  border-radius:22px;
  box-shadow:var(--shadow);
}

.auth-brand{
  margin-bottom:26px;
}

.auth-brand img{
  width:190px;
  max-height:90px;
  object-fit:contain;
  object-position:left center;
}

.auth-card h1{
  margin:0 0 8px;
  font-size:30px;
}

.auth-card > label{
  display:block;
  margin-top:18px;
  font-weight:600;
}

.auth-card input{
  display:block;
  width:100%;
  margin-top:7px;
}

.auth-actions{
  display:flex;
  gap:10px;
  margin-top:22px;
}


/* INPUTS */

input,
select{
  border:1px solid var(--border);
  background:var(--surface2);
  color:var(--text);

  border-radius:10px;
  padding:11px 12px;
  outline:none;
}

input:focus,
select:focus{
  border-color:var(--accent);
}


/* BUTTONS */

button{
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 14px;

  background:var(--surface2);
  color:var(--text);

  font-weight:650;
}

button:hover{
  filter:brightness(1.03);
}

button.primary{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}

button.primary:hover{
  background:var(--accent-hover);
}

button.danger{
  background:var(--danger);
  border-color:var(--danger);
  color:white;
}

.theme-button{
  width:44px;
  height:44px;
  padding:0;

  display:grid;
  place-items:center;

  font-size:19px;
}

.auth-page > .theme-button{
  position:fixed;
  right:22px;
  top:22px;
}


/* APP */

.app-shell{
  min-height:100vh;

  display:grid;
  grid-template-columns:270px minmax(0,1fr);
}

.sidebar{
  min-height:100vh;
  height:100vh;

  position:sticky;
  top:0;

  display:flex;
  flex-direction:column;

  padding:24px 15px;

  background:var(--sidebar);
  color:#eaf2ff;
}

.sidebar-brand{
  padding:2px 12px 30px;
}

.sidebar-brand img{
  width:205px;
  max-height:90px;
  object-fit:contain;
  object-position:left center;
}

.sidebar nav,
.sidebar-bottom{
  display:flex;
  flex-direction:column;
  gap:5px;
}

.sidebar-bottom{
  margin-top:auto;
}

.nav-item{
  width:100%;

  display:flex;
  gap:12px;
  align-items:center;

  padding:12px 13px;

  text-align:left;

  background:transparent;
  color:#dce8f8;

  border-color:transparent;
}

.nav-item:hover{
  background:rgba(255,255,255,.06);
}

.nav-item.active{
  background:var(--accent);
  color:#fff;
}

.nav-icon{
  width:22px;
  text-align:center;
}


/* WORKSPACE */

.workspace{
  min-width:0;
}

.workspace-header{
  width:calc(100% - 64px);
  margin:26px 32px 0;

  padding:18px 20px;

  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:20px;

  background:var(--surface);
  border:1px solid var(--border);
  border-radius:16px;
}

.workspace-header h1{
  margin:0;
  font-size:24px;
}

.workspace-header p{
  margin:5px 0 0;
}

.content{
  padding:22px 32px 50px;
}


/* GENERAL */

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

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

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

.card-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:15px;
  margin-bottom:16px;
}

.card-header h2{
  margin:0;
  font-size:19px;
}

.list-item{
  padding:14px;
  margin-top:10px;

  border:1px solid var(--border);
  border-radius:12px;

  background:var(--surface2);
}

.list-item.clickable{
  cursor:pointer;
}

.list-item.clickable:hover{
  border-color:var(--accent);
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.spacer{
  flex:1;
}

.badge{
  display:inline-flex;
  align-items:center;

  padding:5px 8px;

  border-radius:999px;

  font-size:12px;
  font-weight:700;
}

.badge.online{
  color:#087444;
  background:#dff7ea;
}

.badge.offline{
  color:#7e8793;
  background:#e9edf2;
}


/* DEVICE */

.device-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:20px;
}

.device-head h2{
  margin:0;
}

.device-tabs{
  display:flex;
  gap:3px;

  margin-top:18px;

  border-bottom:1px solid var(--border);
  overflow:auto;
}

.device-tabs button{
  background:transparent;
  border:0;
  border-bottom:3px solid transparent;

  border-radius:0;

  color:var(--muted);
}

.device-tabs button.active{
  color:var(--accent);
  border-bottom-color:var(--accent);
}

.device-tab-body{
  padding-top:20px;
}

.stat-card .label{
  color:var(--muted);
}

.stat-card .value{
  margin-top:8px;

  display:block;

  font-size:24px;
  font-weight:800;
}

.app-toolbar{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;

  margin-bottom:16px;
}

.app-toolbar .search{
  flex:1;
  min-width:250px;
}

.app-card{
  margin-bottom:12px;
}

.app-title{
  display:flex;
  justify-content:space-between;
  gap:12px;
}

.app-name{
  font-weight:800;
}

.package{
  margin-top:3px;
  font-size:13px;
  color:var(--muted);
}

.usage-line{
  margin-top:11px;
}

.progress{
  height:8px;
  margin-top:8px;

  background:var(--border);
  border-radius:999px;

  overflow:hidden;
}

.progress > div{
  height:100%;
  background:var(--accent);
}

.time-actions{
  display:flex;
  gap:7px;
  flex-wrap:wrap;

  margin-top:14px;
}


/* QR */

.qr-layout{
  display:grid;
  grid-template-columns:1fr 230px;
  gap:24px;
  align-items:start;
}

.qr-box{
  text-align:center;

  padding:16px;

  border:1px solid var(--border);
  border-radius:14px;

  background:#fff;
}

.qr-box img,
.qr-box canvas{
  margin:auto;
}


/* MODAL */

.modal-backdrop{
  position:fixed;
  inset:0;

  z-index:5000;

  display:grid;
  place-items:center;

  padding:20px;

  background:rgba(0,0,0,.52);
}

.modal{
  width:min(600px,100%);
  max-height:90vh;
  overflow:auto;

  padding:24px;

  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:15px;

  margin-bottom:20px;
}

.modal-header h2{
  margin:0;
}

.icon-button{
  width:40px;
  height:40px;
  padding:0;
}


/* RESPONSIVE */

@media(max-width:950px){
  .app-shell{
    grid-template-columns:90px minmax(0,1fr);
  }

  .sidebar-brand img{
    width:60px;
  }

  .nav-item span:last-child{
    display:none;
  }

  .nav-item{
    justify-content:center;
    font-size:20px;
  }

  .grid-2,
  .grid-3{
    grid-template-columns:1fr;
  }
}

@media(max-width:650px){
  .app-shell{
    display:block;
  }

  .sidebar{
    position:fixed;
    z-index:100;

    top:auto;
    bottom:0;
    left:0;
    right:0;

    width:100%;
    height:auto;
    min-height:0;

    padding:6px;

    flex-direction:row;
  }

  .sidebar-brand,
  .sidebar-bottom{
    display:none;
  }

  .sidebar nav{
    width:100%;
    flex-direction:row;
    justify-content:space-around;
  }

  .workspace-header{
    width:calc(100% - 28px);
    margin:14px;
  }

  .content{
    padding:0 14px 90px;
  }

  .qr-layout{
    grid-template-columns:1fr;
  }
}

.limit-editor{
  margin-top:16px;
  padding-top:14px;

  border-top:1px solid var(--border);
}

.limit-label{
  margin-bottom:7px;
}

.limit-input{
  width:110px;
}

.time-actions{
  margin-top:12px;
  padding-top:12px;

  border-top:1px solid var(--border);
}


.app-control-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;

  margin-top:16px;
  padding-top:14px;

  border-top:1px solid var(--border);
}

.app-control-actions button.danger{
  background:var(--danger);
  border-color:var(--danger);
  color:#fff;
}


.download-link{
  text-decoration:none;
}

.download-link:hover{
  text-decoration:none;
}


.primary-download{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  padding:10px 16px;

  border-radius:10px;

  background:var(--accent);
  color:#fff;

  text-decoration:none;
  font-weight:700;
}

.primary-download:hover{
  background:var(--accent-hover);
  color:#fff;
  text-decoration:none;
}


.primary-download{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  padding:10px 16px;

  border-radius:10px;

  background:var(--accent);
  color:#fff;

  text-decoration:none;
  font-weight:700;
}

.primary-download:hover{
  background:var(--accent-hover);
  color:#fff;
  text-decoration:none;
}



/* FamiPilot 0.1.5 family roles */

.role-badge{
  display:inline-flex;
  align-items:center;

  padding:5px 9px;

  border-radius:999px;

  font-size:12px;
  font-weight:750;

  background:var(--surface2);
  border:1px solid var(--border);
}

.role-owner{
  background:#e8f1ff;
  color:#145fb8;
}

.role-parent{
  background:#e6f8ef;
  color:#137347;
}

.role-grandmother,
.role-grandfather{
  background:#fff3db;
  color:#8b5a00;
}

.role-guardian{
  background:#f0eaff;
  color:#6847a8;
}


/* Full phone lock schedule */

.schedule-enable{
  display:flex;
  gap:10px;
  align-items:center;

  margin:8px 0 22px;

  font-weight:700;
}

.schedule-times{
  display:flex;
  gap:14px;
  align-items:end;
  flex-wrap:wrap;

  margin-bottom:20px;
}

.schedule-times label{
  display:flex;
  flex-direction:column;
  gap:7px;

  font-weight:650;
}

.schedule-times input[type="time"]{
  width:150px;
}

.schedule-arrow{
  padding-bottom:12px;
  font-size:22px;
  color:var(--muted);
}

.schedule-days{
  display:flex;
  gap:8px;
  flex-wrap:wrap;

  margin-bottom:18px;
}

.day-check input{
  display:none;
}

.day-check span{
  display:grid;
  place-items:center;

  width:44px;
  height:40px;

  cursor:pointer;

  border:1px solid var(--border);
  border-radius:10px;

  background:var(--surface2);

  font-weight:700;
}

.day-check input:checked + span{
  background:var(--accent);
  color:#fff;
  border-color:var(--accent);
}

.schedule-note{
  margin-bottom:18px;

  padding:12px 14px;

  background:var(--surface2);
  border:1px solid var(--border);
  border-radius:10px;

  color:var(--muted);
}



/* Temporary phone access */

.temporary-access-card{
  margin-top:18px;
}

.temporary-quick-buttons{
  display:flex;
  gap:8px;
  flex-wrap:wrap;

  margin-top:16px;
}

.temporary-state{
  display:flex;
  align-items:center;
  gap:18px;

  padding:16px;

  border:1px solid var(--border);
  border-radius:14px;

  background:var(--surface2);
}

.temporary-state.active{
  border-color:var(--accent);
}

.temporary-state.expired{
  border-color:var(--danger);
}

.temporary-countdown{
  min-width:145px;

  font-size:31px;
  line-height:1;

  font-weight:850;
  font-variant-numeric:tabular-nums;

  color:var(--accent);
}

.temporary-lock-icon{
  font-size:32px;
}

.temporary-actions{
  margin-top:12px;
}

.danger-soft{
  color:var(--danger);
  border-color:var(--danger);
  background:transparent;
}

