:root{
  --bg:#0b1220;
  --panel:#0f172a;
  --card:#111c33;
  --muted:#94a3b8;
  --text:#e5e7eb;
  --border:#22304d;
  --accent:#3b82f6;
  --good:#16a34a;
  --warn:#f59e0b;
  --bad:#dc2626;

  --radius:16px;
  --radius2:12px;

  --cal-family:#38bdf8;
  --cal-work:#a78bfa;
  --cal-personal:#34d399;
  --cal-hezzy:#f59e0b;
}

*{box-sizing:border-box}
html{ -webkit-text-size-adjust:100% }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height:1.35;
  background:linear-gradient(180deg, var(--bg), #060a14 60%);
  color:var(--text);
}

.topbar{
  display:flex; justify-content:space-between; align-items:center;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background:rgba(15,23,42,.92);
  backdrop-filter: blur(10px);
  position:sticky; top:0; z-index:20;
}

.brand{display:flex; align-items:center; gap:12px}
.brand .title{font-weight:900; font-size:16px; letter-spacing:.2px}
.brand .subtitle{color:var(--muted); font-size:12px; margin-top:2px}

.top-actions{display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end}

button, .import, select, input, textarea{
  border:1px solid var(--border);
  background:rgba(2,6,23,.45);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:800;
  font-size:12px;
}
button:hover, .import:hover, select:hover{border-color:#35507f}
button.primary{
  background:rgba(59,130,246,.22);
  border-color:#2b4a86;
}
button.ghost{background:transparent}
button.danger{border-color:#4a1d1d; background:#2a0f12}

.import{position:relative; overflow:hidden}
.import input{position:absolute; left:0; top:0; opacity:0; width:100%; height:100%; cursor:pointer}

.iconbtn{
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
  font-weight:900;
}

.chip{
  padding:9px 12px;
  border:1px solid var(--border);
  border-radius:999px;
  background:rgba(17,28,51,.45);
  color:var(--muted);
  font-weight:900;
  font-size:12px;
  white-space:nowrap;
}

.layout{display:grid; grid-template-columns:320px 1fr; min-height:calc(100vh - 64px)}
.sidebar{
  border-right:1px solid var(--border);
  padding:10px;
  background:rgba(15,23,42,.55);
  overflow:auto;
}
.sidebar-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 10px 6px;
}
.sidebar-title{font-weight:900; color:#e2e8f0}

.content{padding:16px; overflow:auto}

.navitem{
  display:block;
  padding:12px 12px;
  border-radius:var(--radius2);
  color:var(--text);
  text-decoration:none;
  border:1px solid transparent;
  margin-bottom:8px;
  background:rgba(17,28,51,.35);
}
.navitem small{color:var(--muted); display:block; margin-top:4px; font-size:12px}
.navitem.active{border-color:#2b4a86; background:rgba(59,130,246,.16)}

.sidecard{
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:rgba(17,28,51,.5);
  margin-top:10px;
}
.sidecard-title{
  padding:10px 12px;
  font-size:12px; font-weight:900;
  border-bottom:1px solid var(--border);
}
.sidecard-body{padding:10px 12px}

.field{display:flex; gap:10px; align-items:center; margin-bottom:10px}
.field span{width:110px; color:var(--muted); font-size:12px; font-weight:900}
.field select, .field input{flex:1}

.legend{display:flex; flex-wrap:wrap; gap:8px; margin-top:6px}
.leg{
  display:flex; align-items:center; gap:8px;
  font-size:12px; color:var(--muted); font-weight:900;
  border:1px solid var(--border); border-radius:999px; padding:7px 10px;
  background:rgba(2,6,23,.25);
}
.dot{width:10px; height:10px; border-radius:999px; display:inline-block}

.tasklist{display:flex; flex-direction:column; gap:8px; margin-bottom:10px}
.task{
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  background:rgba(2,6,23,.35);
  cursor:grab;
  user-select:none;
  touch-action:none;
}
.task strong{display:block; font-size:13px; line-height:1.2}
.task small{display:block; color:var(--muted); font-size:12px; margin-top:4px}

.card{
  background:rgba(17,28,51,.6);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px;
  margin-bottom:14px;
}
.card h2{margin:0 0 10px; font-size:14px}
.hint{color:var(--muted); font-size:12px; margin:0 0 10px; line-height:1.5}
.hint.tight{margin:0}

.grid{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border-radius:var(--radius);
  border:1px solid var(--border);
}
.grid th{
  background:rgba(15,23,42,.9);
  color:#fff;
  font-size:12px;
  text-align:left;
  padding:10px;
  border-bottom:1px solid var(--border);
}
.grid td{
  padding:10px;
  border-bottom:1px solid var(--border);
  background:rgba(15,23,42,.35);
  vertical-align:top;
}
.grid tr:last-child td{border-bottom:none}
.grid input, .grid select, .grid textarea{
  width:100%;
  background:rgba(2,6,23,.5);
  border:1px solid #243658;
  color:var(--text);
  padding:10px 10px;
  border-radius:12px;
  font-size:12px;
}
.grid textarea{min-height:44px; resize:vertical}

.footer{margin-top:14px; color:var(--muted); font-size:12px}

/* Calendar */
.calendar-wrap{
  border:1px solid var(--border);
  border-radius:var(--radius);
  overflow:hidden;
  background:rgba(17,28,51,.5);
}
.cal-head{
  display:flex; justify-content:space-between; align-items:center;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  background:rgba(15,23,42,.86);
}
.cal-head .left{display:flex; gap:8px; align-items:center}
.cal-head .title{font-weight:900; font-size:13px}
.cal-head .sub{color:var(--muted); font-size:12px; font-weight:900}

.week-grid{
  display:grid;
  grid-template-columns: 62px repeat(7, 1fr);
  max-height: 72vh;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
}
.week-grid .cell{
  border-bottom:1px solid var(--border);
  border-right:1px solid var(--border);
  min-height:46px;
  position:relative;
}
.week-grid .cell.time{
  background:rgba(2,6,23,.25);
  color:var(--muted);
  font-size:11px;
  font-weight:900;
  padding:10px 8px;
}
.week-grid .cell.dayhead{
  background:rgba(2,6,23,.25);
  color:#e2e8f0;
  font-size:12px;
  font-weight:900;
  padding:10px 10px;
  position:sticky;
  top:0;
  z-index:5;
}
.week-grid .cell.slot{
  background:rgba(15,23,42,.25);
}
.week-grid .cell.slot:hover{background:rgba(59,130,246,.08)}

.event{
  position:absolute;
  left:6px; right:6px;
  top:6px; bottom:6px;
  border-radius:12px;
  border:1px solid rgba(226,232,240,.18);
  padding:8px 9px;
  overflow:hidden;
  cursor:pointer;
}
.event strong{display:block; font-size:12px; line-height:1.2}
.event small{display:block; color:rgba(226,232,240,.9); font-size:11px; margin-top:4px}

.event.Family{background:rgba(56,189,248,.18); border-color:rgba(56,189,248,.35)}
.event.Work{background:rgba(167,139,250,.18); border-color:rgba(167,139,250,.35)}
.event.Personal{background:rgba(52,211,153,.18); border-color:rgba(52,211,153,.35)}
.event.Hezzy{background:rgba(245,158,11,.16); border-color:rgba(245,158,11,.35)}

.drop-ok{outline:2px dashed rgba(59,130,246,.6); outline-offset:-2px}

/* Modal */
.modal{
  position:fixed; inset:0;
  background:rgba(0,0,0,.55);
  display:none;
  align-items:flex-end;
  justify-content:center;
  padding:14px;
  z-index:30;
}
.modal[aria-hidden="false"]{display:flex}
.modal-card{
  width:min(760px, 100%);
  border-radius:18px;
  border:1px solid var(--border);
  background:rgba(15,23,42,.96);
  backdrop-filter: blur(12px);
  max-height:85vh;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
}
.modal-head{
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  background:rgba(15,23,42,.96);
}
.modal-title{font-weight:900}
.modal-body{padding:14px}
.modal-foot{
  padding:12px 14px;
  border-top:1px solid var(--border);
  display:flex; justify-content:flex-end; gap:10px;
  position:sticky;
  bottom:0;
  background:rgba(15,23,42,.96);
}

/* Mobile */
.mobile-only{display:none}

@media (max-width: 980px){
  .layout{grid-template-columns:1fr}
  .sidebar{
    position:fixed;
    top:64px;
    left:0;
    right:0;
    bottom:0;
    transform:translateY(110%);
    transition:transform .18s ease;
    border-right:none;
    border-top:1px solid var(--border);
    z-index:25;
    padding-bottom:24px;
  }
  body.menu-open .sidebar{transform:translateY(0)}
  .content{padding:14px}
  .mobile-only{display:inline-flex}
  .top-actions{gap:8px}
  .chip{display:none}

  /* Default to day-style clarity on small screens (week view still available). */
  .week-grid{grid-template-columns:62px repeat(7, minmax(160px, 1fr))}
}
