:root{
  --bg:#0f1115;
  --panel:#171b24;
  --panel-2:#1d2430;
  --panel-3:#11161e;
  --line:#2b3444;
  --line-2:#38455b;
  --text:#e8edf6;
  --muted:#a9b3c5;
  --accent:#69a7ff;
  --accent-2:#866dff;
  --good:#42c47d;
  --warn:#efb24a;
  --bad:#e07176;
  --shadow:0 10px 30px rgba(0,0,0,.25);
}

*{box-sizing:border-box}

html,body{
  height:100%;
}

body{
  margin:0;
  font-family:Arial, Helvetica, sans-serif;
  background:var(--bg);
  color:var(--text);
}

.app-shell{
  height:100vh;
  display:grid;
  grid-template-columns:320px 1fr;
  overflow:hidden;
}

.sidebar{
  background:var(--panel);
  border-right:1px solid var(--line);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.sidebar-header{
  padding:18px 16px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
}

.brand-title{
  font-size:20px;
  font-weight:700;
  letter-spacing:.04em;
}

.brand-subtitle{
  margin-top:6px;
  font-size:12px;
  line-height:1.4;
  color:var(--muted);
}

.sidebar-section{
  padding:14px 14px 16px;
  border-bottom:1px solid var(--line);
  overflow:hidden;
}

.sidebar-section:last-of-type{
  border-bottom:none;
}

.sidebar-section-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}

.sidebar-section-header h2{
  margin:0;
  font-size:13px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.05em;
}

.main{
  display:grid;
  grid-template-rows:auto auto 1fr auto;
  overflow:hidden;
}

.main-header{
  padding:18px 20px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  border-bottom:1px solid var(--line);
  background:var(--panel);
}

.main-header h1{
  margin:0;
  font-size:22px;
  line-height:1.2;
}

.main-header p{
  margin:6px 0 0;
  font-size:13px;
  color:var(--muted);
  max-width:920px;
  line-height:1.45;
}

.context-strip{
  padding:10px 20px;
  display:flex;
  flex-wrap:wrap;
  gap:20px;
  font-size:12px;
  color:var(--muted);
  background:var(--panel-2);
  border-bottom:1px solid var(--line);
}

.workspace{
  overflow:auto;
  padding:18px;
}

.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
  box-shadow:var(--shadow);
  overflow:hidden;
  margin-bottom:18px;
}

.panel-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.02);
}

.panel-header h2{
  margin:0;
  font-size:15px;
}

.panel-body{
  padding:14px;
}

.stack{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.grid{
  display:grid;
  gap:14px;
}

.grid-2{
  grid-template-columns:repeat(2, minmax(0, 1fr));
}

.grid-3{
  grid-template-columns:repeat(3, minmax(0, 1fr));
}

.grid-4{
  grid-template-columns:repeat(4, minmax(0, 1fr));
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.field label{
  font-size:12px;
  color:var(--muted);
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea,
input[type="file"]{
  width:100%;
  border:1px solid var(--line-2);
  border-radius:10px;
  background:var(--panel-3);
  color:var(--text);
  padding:10px 12px;
  font-size:14px;
  outline:none;
}

input[type="file"]{
  padding:8px 10px;
}

textarea{
  min-height:100px;
  resize:vertical;
  line-height:1.45;
}

.tall-textarea{
  min-height:240px;
}

.code-textarea{
  min-height:220px;
  font-family:Consolas, "Courier New", monospace;
  font-size:12px;
}

.button-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}

button{
  border:none;
  border-radius:10px;
  background:var(--accent);
  color:#07111f;
  font-size:13px;
  font-weight:700;
  padding:10px 14px;
  cursor:pointer;
  transition:transform .08s ease, opacity .12s ease, box-shadow .12s ease;
}

button:hover{
  opacity:.95;
}

button:active{
  transform:translateY(1px);
}

button:disabled{
  opacity:.6;
  cursor:not-allowed;
}

button.secondary{
  background:#334055;
  color:var(--text);
}

button.ghost{
  background:transparent;
  color:var(--muted);
  border:1px solid var(--line-2);
}

button.good{
  background:var(--good);
  color:#08150f;
}

button.warn{
  background:var(--warn);
  color:#1b1306;
}

button.bad{
  background:var(--bad);
  color:#170c0d;
}

.list{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:220px;
  overflow:auto;
}

.list-item{
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:10px;
  padding:10px;
  cursor:pointer;
}

.list-item:hover{
  border-color:var(--line-2);
}

.list-item.active{
  border-color:var(--accent);
  box-shadow:0 0 0 1px rgba(105,167,255,.18) inset;
}

.list-item .name{
  font-size:13px;
  font-weight:700;
  line-height:1.35;
  margin-bottom:4px;
}

.list-item .meta{
  font-size:11px;
  line-height:1.4;
  color:var(--muted);
}

.metrics-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:14px;
}

.metric-card{
  padding:14px;
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:12px;
}

.metric-label{
  font-size:11px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.05em;
}

.metric-value{
  margin-top:6px;
  font-size:24px;
  font-weight:800;
}

.table-wrap{
  overflow:auto;
  border:1px solid var(--line);
  border-radius:10px;
}

.data-table{
  width:100%;
  border-collapse:collapse;
  min-width:760px;
}

.data-table th,
.data-table td{
  padding:10px 10px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
  font-size:12px;
}

.data-table th{
  background:var(--panel-2);
  color:var(--muted);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.04em;
}

.data-table tr:last-child td{
  border-bottom:none;
}

.gallery-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));
  gap:14px;
}

.gallery-card{
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
}

.gallery-image{
  background:#0b1017;
  aspect-ratio:1/1;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}

.gallery-image img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.gallery-meta{
  padding:10px;
  font-size:11px;
  line-height:1.45;
  color:var(--muted);
}

.gallery-meta strong{
  color:var(--text);
}

.anchor-gallery-image{
  min-height:220px;
}

.anchor-gallery-meta{
  min-height:118px;
}

.anchor-card-missing{
  opacity:.92;
}

.anchor-missing{
  padding:16px;
  text-align:center;
  font-size:12px;
  line-height:1.45;
  color:var(--muted);
}

.anchor-empty-state{
  grid-column:1 / -1;
}

.developer-override{
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--panel-2);
  overflow:hidden;
}

.developer-override summary{
  list-style:none;
  cursor:pointer;
  padding:12px 14px;
  font-size:13px;
  font-weight:700;
  color:var(--text);
  background:rgba(255,255,255,.02);
  border-bottom:1px solid transparent;
}

.developer-override[open] summary{
  border-bottom-color:var(--line);
}

.developer-override summary::-webkit-details-marker{
  display:none;
}

.developer-override summary::before{
  content:"▸";
  display:inline-block;
  margin-right:8px;
  color:var(--muted);
  transform:translateY(-1px);
}

.developer-override[open] summary::before{
  content:"▾";
}

.developer-override-body{
  padding:12px 14px 14px;
}

.anchor-controls-row{
  padding-top:2px;
}

.statusbar{
  min-height:42px;
  display:flex;
  align-items:center;
  padding:10px 14px;
  border-top:1px solid var(--line);
  background:var(--panel-3);
  color:var(--muted);
  font-size:12px;
}

.statusbar.good{
  color:var(--good);
}

.statusbar.warn{
  color:var(--warn);
}

.statusbar.bad{
  color:var(--bad);
}

.inline-pills{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:5px 8px;
  border-radius:999px;
  border:1px solid var(--line-2);
  background:var(--panel-3);
  color:var(--muted);
  font-size:11px;
}

.empty-state{
  padding:14px;
  border:1px dashed var(--line-2);
  border-radius:10px;
  color:var(--muted);
  font-size:12px;
  background:rgba(255,255,255,.015);
}

.auth-shell{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:
    radial-gradient(circle at top, rgba(105,167,255,.14), rgba(15,17,21,0) 40%),
    linear-gradient(180deg, #0d1015 0%, #0f1115 100%);
}

.auth-card{
  width:100%;
  max-width:460px;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
  padding:24px;
}

.auth-brand{
  font-size:14px;
  font-weight:800;
  letter-spacing:.14em;
  color:var(--accent);
  text-transform:uppercase;
}

.auth-title{
  margin-top:10px;
  font-size:26px;
  line-height:1.2;
  font-weight:800;
}

.auth-subtitle{
  margin-top:8px;
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}

.auth-form{
  margin-top:20px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.auth-message{
  padding:12px 14px;
  border-radius:10px;
  background:var(--panel-3);
  border:1px solid var(--line);
  color:var(--muted);
  font-size:12px;
  line-height:1.45;
}

.auth-message.bad{
  border-color:rgba(224,113,118,.45);
  color:#ffd2d4;
  background:rgba(224,113,118,.08);
}

@media (max-width: 1280px){
  .grid-4{grid-template-columns:repeat(2, minmax(0, 1fr));}
}

@media (max-width: 980px){
  .app-shell{grid-template-columns:1fr;}
  .sidebar{display:none;}
  .grid-2,.grid-3,.grid-4,.metrics-grid{grid-template-columns:1fr;}
  .main-header{flex-direction:column; align-items:flex-start;}
}

@media (max-width: 640px){
  .auth-card{
    padding:18px;
  }

  .auth-title{
    font-size:22px;
  }
}