:root{
  --bg: #0b1220;
  --panel: rgba(255,255,255,0.06);
  --card: rgba(255,255,255,0.08);
  --stroke: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.68);
  --primary: #4ea1ff;
  --danger: #ff5c7a;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

[data-theme="light"]{
  --bg: #f5f6fa;
  --panel: rgba(255,255,255,0.9);
  --card: white;
  --stroke: rgba(0,0,0,0.08);
  --text: rgba(15,23,42,0.92);
  --muted: rgba(15,23,42,0.62);
  --primary: #2e86de;
  --danger: #d7263d;
  --shadow: 0 10px 30px rgba(15,23,42,0.12);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(78,161,255,0.25), transparent 60%),
              radial-gradient(900px 500px at 90% 10%, rgba(255,92,122,0.18), transparent 55%),
              var(--bg);
  color: var(--text);
}

.app{ min-height:100%; display:flex; flex-direction:column; }

.topbar{
  position: sticky;
  top:0;
  z-index: 10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(0,0,0,0.08);
  backdrop-filter: blur(12px);
}

.brand{ display:flex; gap:12px; align-items:center; }
.logo{
  width:38px; height:38px;
  border-radius: 12px;
  display:flex; align-items:center; justify-content:center;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(78,161,255,0.95), rgba(255,92,122,0.75));
  box-shadow: var(--shadow);
}
.brand-title{ font-weight:700; }
.brand-subtitle{ font-size:12px; color: var(--muted); margin-top:2px; }

.main{ flex:1; display:flex; justify-content:center; padding: 22px 14px 30px; }

.screen{ width: min(1200px, 100%); }

.layout{
  display:grid;
  grid-template-columns: 310px 1fr;
  gap: 16px;
  align-items:start;
}

.sidebar{
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 92px);
  overflow:auto;
}

.userbox{
  display:flex; gap:12px; align-items:center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.10);
  border: 1px solid var(--stroke);
}
.avatar{
  width:40px; height:40px;
  border-radius: 14px;
  display:flex; align-items:center; justify-content:center;
  font-weight:800;
  background: rgba(78,161,255,0.20);
  border: 1px solid var(--stroke);
}
.user-name{ font-weight:700; }
.user-role{ font-size:12px; }

.nav{ margin-top: 12px; display:flex; flex-direction:column; gap:8px; }
.nav .navbtn{
  width:100%;
  text-align:left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.07);
  color: var(--text);
  cursor:pointer;
}
.nav .navbtn.active{
  border-color: rgba(78,161,255,0.6);
  background: rgba(78,161,255,0.12);
}
.sidebar-foot{ margin-top: 14px; font-size:12px; }

.content{
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.content-header{
  padding: 4px 2px 14px;
  border-bottom: 1px solid var(--stroke);
  margin-bottom: 14px;
}

.card{
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 16px;
}

.grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stack{ display:flex; flex-direction:column; gap:10px; }

.h1{ font-size: 22px; margin: 0 0 8px; }
.h2{ font-size: 18px; margin: 0; }
.h3{ font-size: 16px; margin: 0 0 8px; }

.muted{ color: var(--muted); }

.label{ display:block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.input, .textarea, select.input{
  width:100%;
  margin-top:6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.06);
  color: var(--text);
  outline:none;
}
.textarea{ min-height: 90px; resize: vertical; }

.row{ display:flex; align-items:center; }
.row.gap{ gap:10px; }
.row.space{ justify-content:space-between; }

.btn{
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  cursor:pointer;
  color: var(--text);
  background: rgba(0,0,0,0.07);
}
.btn-primary{
  border-color: rgba(78,161,255,0.55);
  background: rgba(78,161,255,0.18);
}
.btn-secondary{
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
}
.btn-ghost{
  border-color: transparent;
  background: transparent;
}

.alert{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
}
.alert-danger{
  border-color: rgba(255,92,122,0.55);
  background: rgba(255,92,122,0.14);
}

.details{
  margin-top: 12px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.05);
}

.list{
  margin-top: 8px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.list .item{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.06);
  cursor:pointer;
}
.list .item:hover{ background: rgba(0,0,0,0.10); }

.note{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(78,161,255,0.55);
  background: rgba(78,161,255,0.10);
}

.table-wrap{
  margin-top: 10px;
  overflow:auto;
  border-radius: 12px;
  border: 1px solid var(--stroke);
}
table{
  width:100%;
  border-collapse:collapse;
  font-size: 13px;
}
th, td{
  padding: 10px 10px;
  border-bottom: 1px solid var(--stroke);
  vertical-align: top;
}
th{
  text-align:left;
  color: var(--muted);
  font-weight:700;
  position: sticky;
  top: 0;
  background: rgba(0,0,0,0.10);
}
tr:hover td{ background: rgba(0,0,0,0.04); }

.filters{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.toast{
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: min(520px, 92vw);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.55);
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events:none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* Modal */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;
  z-index: 50;
}
.modal{
  width: min(640px, 100%);
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.modal-body{ margin-top: 10px; }

/* Mobile */
@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{ position: static; max-height: none; }
  .grid{ grid-template-columns: 1fr; }
  .filters{ grid-template-columns: 1fr; }
}