:root{
  --bg:#0d1117; --bg-2:#161b22; --bg-3:#1c2230; --line:#2b3240;
  --line-2:#3a4353; --text:#e6edf3; --muted:#8b949e; --muted-2:#6e7681;
  --primary:#3b82f6; --primary-hover:#2f6fd6; --danger:#e5484d; --danger-hover:#c93c40;
  --green:#2ea043; --grey:#6e7681; --amber:#d29922; --red:#e5484d; --blue:#3b82f6;
  --radius:10px; --radius-sm:6px;
  --font: system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --mono: ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--text); font-family:var(--font);
  font-size:14px; line-height:1.45; -webkit-font-smoothing:antialiased;
}
.hidden{display:none !important}
.muted{color:var(--muted)}
.small{font-size:12px}
a{color:var(--primary); text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3,h4{margin:0; font-weight:600}
hr.divider{border:none; border-top:1px solid var(--line); margin:18px 0}

/* ---------- Buttons ---------- */
.btn{
  font:inherit; font-weight:500; cursor:pointer; border:1px solid transparent;
  border-radius:var(--radius-sm); padding:7px 14px; color:var(--text);
  background:var(--bg-3); transition:background .12s,border-color .12s,opacity .12s;
}
.btn:hover{background:var(--line)}
.btn:disabled{opacity:.45; cursor:not-allowed}
.btn-primary{background:var(--primary); border-color:var(--primary); color:#fff}
.btn-primary:hover:not(:disabled){background:var(--primary-hover); border-color:var(--primary-hover)}
.btn-danger{background:var(--danger); border-color:var(--danger); color:#fff}
.btn-danger:hover:not(:disabled){background:var(--danger-hover); border-color:var(--danger-hover)}
.btn-ghost{background:transparent; border-color:var(--line-2)}
.btn-ghost:hover{background:var(--bg-3)}
.btn-sm{padding:5px 11px; font-size:13px}
.btn-block{width:100%; margin-top:8px}

/* Google sign-in button + "or" divider on the login card. */
.login-divider{display:flex; align-items:center; gap:10px; margin:14px 0 4px;
  color:var(--muted-2); font-size:12px}
.login-divider::before,.login-divider::after{content:""; flex:1;
  border-top:1px solid var(--line)}
.google-btn{display:flex; align-items:center; justify-content:center; gap:9px}
.google-btn .google-g{flex:none}

/* ---------- Inputs ---------- */
input,select{
  font:inherit; width:100%; padding:8px 10px; color:var(--text);
  background:var(--bg); border:1px solid var(--line-2); border-radius:var(--radius-sm);
  margin:4px 0 2px;
}
input:focus,select:focus{outline:none; border-color:var(--primary); box-shadow:0 0 0 2px rgba(59,130,246,.25)}
label{display:block; font-size:12px; color:var(--muted); margin-top:10px; font-weight:500}
.form-error{color:var(--danger); font-size:12.5px; margin:6px 0}

/* ---------- Pills ---------- */
.pill{
  display:inline-flex; align-items:center; gap:5px; padding:2px 9px; border-radius:999px;
  font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:.3px;
  background:var(--bg-3); color:var(--text); white-space:nowrap;
}
.pill::before{content:""; width:7px; height:7px; border-radius:50%; background:currentColor}
.pill.state-running{color:#7ee2a0; background:rgba(46,160,67,.16)}
.pill.state-stopped{color:#b6bdc8; background:rgba(110,118,129,.2)}
.pill.state-pending,.pill.state-stopping{color:#f0c674; background:rgba(210,153,34,.16)}
.pill.state-terminated{color:#ff8085; background:rgba(229,72,77,.16)}
.pill.state-unknown{color:#b6bdc8; background:rgba(110,118,129,.2)}
.pill.state-success{color:#7ee2a0; background:rgba(46,160,67,.16)}
.pill.state-failed{color:#ff8085; background:rgba(229,72,77,.16)}
.pill.no-dot::before{display:none}
.role-pill{background:var(--line); color:var(--muted); text-transform:capitalize}
.owner-pill{background:rgba(59,130,246,.16); color:#9ec5fe; text-transform:none; letter-spacing:0}
.version-pill{background:var(--bg-3); color:var(--muted); text-transform:none; letter-spacing:0; font-weight:500}
.system-tag{background:rgba(210,153,34,.16); color:#f0c674; text-transform:uppercase}
.expired-badge{background:rgba(229,72,77,.18); color:#ff8085; text-transform:uppercase; letter-spacing:.4px}

/* ---------- Login ---------- */
.login-screen{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px}
.login-card{
  width:100%; max-width:380px; background:var(--bg-2); border:1px solid var(--line);
  border-radius:var(--radius); padding:28px; box-shadow:0 20px 60px rgba(0,0,0,.4);
}
.login-brand{display:flex; align-items:center; gap:14px; margin-bottom:22px}
.login-brand h1{font-size:18px}
.login-brand p{margin:2px 0 0}
.login-logo{
  width:44px; height:44px; border-radius:10px; background:linear-gradient(135deg,#3b82f6,#6366f1);
  display:flex; align-items:center; justify-content:center; font-weight:700; color:#fff; flex:none;
}
.login-logo.sm{width:30px; height:30px; border-radius:8px; font-size:12px}
.logo-glyph{width:74%; height:74%; display:block}

/* ---------- Topbar ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:12px 22px; background:var(--bg-2); border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:20;
}
.topbar-left{display:flex; align-items:center; gap:12px}
.app-title{font-weight:600; font-size:15px}
.topbar-right{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
.userchip{display:flex; align-items:center; gap:8px; padding:0 4px}
.user-name{font-weight:500}

/* ---------- Content ---------- */
.content{max-width:1200px; margin:0 auto; padding:24px 22px 60px}
.section{margin-bottom:34px}
.section-head{display:flex; align-items:baseline; gap:12px; margin-bottom:14px}
.section-head h2{font-size:16px}
.empty{color:var(--muted); padding:16px 0}

/* ---------- Getting-started card ---------- */
.gs-card{
  position:relative; background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius);
  padding:20px 22px;
}
.gs-card h2{font-size:16px; margin:0 0 6px}
.gs-card p{margin:0 0 10px}
.gs-steps{margin:0; padding-left:20px; display:flex; flex-direction:column; gap:6px; font-size:13.5px}
.gs-steps li{line-height:1.5}
.gs-steps code{background:var(--bg-3); border:1px solid var(--line); border-radius:4px; padding:1px 6px; font-size:12.5px}

/* ---------- Env grid ---------- */
.env-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:16px}
.env-card{
  background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius);
  padding:16px; display:flex; flex-direction:column; gap:12px; position:relative;
}
.env-card.busy{border-color:var(--amber)}
.env-card-head{display:flex; align-items:center; justify-content:space-between; gap:10px}
.env-name{font-size:16px; font-weight:600}
.env-name-row{display:flex; align-items:center; gap:9px}
.busy-tag{
  display:inline-flex; align-items:center; gap:6px; font-size:11px; color:var(--amber);
  font-weight:600;
}
.busy-tag .spinner{
  width:11px; height:11px; border:2px solid rgba(210,153,34,.35); border-top-color:var(--amber);
  border-radius:50%; animation:spin .8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.env-meta{display:flex; flex-direction:column; gap:6px; font-size:13px}
.env-row{display:flex; gap:8px}
.env-row .k{color:var(--muted); min-width:66px}
.env-row .v{color:var(--text); word-break:break-all}
.agents{display:flex; flex-direction:column; gap:6px}
.agents-title{font-size:11px; text-transform:uppercase; letter-spacing:.4px; color:var(--muted-2); font-weight:600}
.agent-row{display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12.5px}
/* margin-right:auto keeps the label left and groups the state pill with the
   per-agent power button on the right, instead of space-between spreading all
   three evenly across the row. */
.agent-row .agent-label{color:var(--muted); margin-right:auto}
.btn-xs{padding:2px 8px; font-size:11.5px; line-height:1.6}
.env-actions{display:flex; gap:8px; flex-wrap:wrap; margin-top:auto; padding-top:6px; border-top:1px solid var(--line)}

/* ---------- Env lifecycle (auto-stop / delete-by) ---------- */
.env-life{display:flex; flex-direction:column; gap:6px; align-items:flex-start}
.env-note{word-break:break-word}
.env-countdown{color:var(--amber); font-weight:600}
.env-deleteby{color:var(--muted)}

/* ---------- Cleanup section ---------- */
.cleanup-list{display:flex; flex-direction:column; gap:8px}
.cleanup-item{
  display:flex; align-items:center; gap:12px; padding:10px 14px; background:var(--bg-2);
  border:1px solid rgba(229,72,77,.35); border-radius:var(--radius-sm);
}
.cleanup-item .cleanup-name{font-weight:600; min-width:76px}
.cleanup-item .cleanup-owner{color:var(--muted); min-width:90px}
.cleanup-item .cleanup-age{color:var(--muted-2); font-size:12px}
.cleanup-item .cleanup-deleteby{color:var(--muted); font-size:12px; margin-left:auto}
.cleanup-item .btn-danger{flex:none}

/* ---------- Jobs list ---------- */
.jobs-list{display:flex; flex-direction:column; gap:8px}
.job-item{
  display:flex; align-items:center; gap:12px; padding:10px 14px; background:var(--bg-2);
  border:1px solid var(--line); border-radius:var(--radius-sm); cursor:pointer;
}
.job-item:hover{border-color:var(--line-2); background:var(--bg-3)}
.job-item .job-action{font-weight:600; text-transform:capitalize; min-width:76px}
.job-item .job-env{color:var(--muted); min-width:70px}
.job-item .job-who{color:var(--muted); margin-left:auto}
.job-item .job-when{color:var(--muted-2); font-size:12px; min-width:120px; text-align:right}

/* ---------- Modals ---------- */
.modal-overlay{
  position:fixed; inset:0; background:rgba(2,6,15,.66); display:flex; align-items:center;
  justify-content:center; padding:20px; z-index:60;
}
.modal{
  width:100%; max-width:440px; background:var(--bg-2); border:1px solid var(--line);
  border-radius:var(--radius); box-shadow:0 24px 70px rgba(0,0,0,.5); max-height:90vh; overflow:auto;
}
.modal-wide{max-width:620px}
.modal-head{
  display:flex; align-items:center; justify-content:space-between; padding:16px 20px;
  border-bottom:1px solid var(--line);
}
.modal-head h3{font-size:16px}
.modal-body{padding:18px 20px}
.modal-close{
  background:none; border:none; color:var(--muted); font-size:24px; line-height:1; cursor:pointer;
  padding:0 4px;
}
.modal-close:hover{color:var(--text)}
.modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:20px}
.danger-text{color:var(--danger)}
.warn-banner{
  background:rgba(210,153,34,.12); border:1px solid rgba(210,153,34,.35); color:#f0c674;
  padding:10px 12px; border-radius:var(--radius-sm); font-size:13px; margin-bottom:12px;
}
.danger-banner{
  background:rgba(229,72,77,.12); border:1px solid rgba(229,72,77,.35); color:#ff9599;
  padding:10px 12px; border-radius:var(--radius-sm); font-size:13px; margin-bottom:12px;
}

/* ---------- User table ---------- */
.user-table{width:100%; border-collapse:collapse; font-size:13.5px}
.user-table th{text-align:left; color:var(--muted); font-weight:600; padding:6px 8px; border-bottom:1px solid var(--line)}
.user-table td{padding:8px; border-bottom:1px solid var(--line)}
.user-table td:last-child{text-align:right}
.user-form{display:flex; gap:8px; flex-wrap:wrap; align-items:center}
.user-form input,.user-form select{width:auto; flex:1 1 120px; margin:0}
.user-form button{flex:none}
/* In-place role editor in each user row. */
.user-table select.row-role{width:auto; min-width:126px; margin:0; padding:4px 8px; font-size:13px}
.user-table select.row-role:disabled{opacity:.55; cursor:not-allowed}
.user-table td:last-child{white-space:nowrap}
.user-table td:last-child .btn+.btn{margin-left:6px}

/* ---------- Password result (admin reset) ---------- */
.pw-result{
  margin-top:14px; padding:12px 14px; background:var(--bg-3); border:1px solid var(--line-2);
  border-radius:var(--radius-sm);
}
.pw-row{display:flex; gap:8px; align-items:center}
.pw-row input{
  flex:1 1 auto; margin:0; font-family:var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.pw-row button{flex:none}

/* ---------- Guest grants ---------- */
.grant-result{
  margin-top:14px; padding:12px 14px; background:var(--bg-3); border:1px solid var(--line-2);
  border-radius:var(--radius-sm);
}
.grant-result-label{font-size:12px; color:var(--muted); font-weight:600; margin-bottom:6px}
.grant-link-row{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.grant-link-row input{flex:1 1 200px; margin:0; font-family:var(--mono); font-size:12.5px}
.grant-link-row .btn{flex:none}
.grant-table{width:100%; border-collapse:collapse; font-size:13px}
.grant-table th{text-align:left; color:var(--muted); font-weight:600; padding:6px 8px; border-bottom:1px solid var(--line)}
.grant-table td{padding:8px; border-bottom:1px solid var(--line); vertical-align:middle}
.grant-table td.grant-actions{text-align:right; white-space:nowrap}
.grant-actions .btn{margin-left:6px}
.pill.grant-active{color:#7ee2a0; background:rgba(46,160,67,.16)}
.pill.grant-revoked{color:#b6bdc8; background:rgba(110,118,129,.2)}
.pill.grant-exhausted{color:#f0c674; background:rgba(210,153,34,.16)}

/* ---------- Job log side panel ---------- */
.job-panel{
  position:fixed; top:0; right:0; height:100vh; width:min(620px,92vw); z-index:70;
  background:var(--bg-2); border-left:1px solid var(--line); box-shadow:-16px 0 50px rgba(0,0,0,.5);
  display:flex; flex-direction:column;
}
.job-panel-head{
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
  padding:16px 20px; border-bottom:1px solid var(--line);
}
.job-panel-head h3{font-size:15px; margin-bottom:6px}
.job-meta{display:flex; align-items:center; gap:10px}
.job-log{
  flex:1; margin:0; padding:16px 20px; overflow:auto; font-family:var(--mono);
  font-size:12.5px; line-height:1.5; white-space:pre-wrap; word-break:break-word;
  background:var(--bg); color:#c9d1d9;
}

/* ---------- Self-service usage bars ---------- */
.usage-bars{display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:16px; margin-bottom:12px}
.usage-bar{background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius); padding:14px 16px}
.usage-bar-label{font-size:13px; color:var(--text); font-weight:500; margin-bottom:8px}
.usage-track{height:8px; border-radius:999px; background:var(--bg-3); overflow:hidden}
.usage-fill{height:100%; width:0; border-radius:999px; background:var(--primary); transition:width .3s}
.usage-fill.warn{background:var(--amber)}
.usage-fill.full{background:var(--danger)}
.usage-note{margin:8px 0 0}
.portal-reason{color:var(--amber); font-weight:500}

/* ---------- Self-service quota fields (admin users modal) ---------- */
.quota-fields{margin-top:16px; padding:14px 16px; background:var(--bg-3); border:1px solid var(--line-2); border-radius:var(--radius-sm)}
.quota-title{font-size:13px; margin-bottom:6px}
.quota-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px}
.quota-grid label{margin-top:0}
.quota-grid input{margin:2px 0 0}
.quota-sizes{display:flex; flex-wrap:wrap; gap:8px 16px; margin-top:6px}
.quota-sizes label{display:flex; align-items:center; gap:6px; margin-top:6px; color:var(--text); font-size:13px; font-weight:400; cursor:pointer}
.quota-sizes input[type=checkbox]{width:auto; margin:0}
/* Inline editor row under a self-service user (grant more time / edit quota). */
.quota-editor-row > td{padding:0 0 12px}
.quota-editor-row .quota-fields{margin-top:8px}
.quota-hours{display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin-top:12px;
  padding-top:12px; border-top:1px solid var(--line-2)}
.quota-hours .quota-give{width:90px; margin:0}
.quota-actions{margin-top:12px; display:flex; justify-content:flex-end}

/* ---------- Toasts ---------- */
.toasts{position:fixed; bottom:20px; right:20px; z-index:90; display:flex; flex-direction:column; gap:10px}
.toast{
  min-width:220px; max-width:360px; padding:11px 15px; border-radius:var(--radius-sm);
  background:var(--bg-3); border:1px solid var(--line-2); font-size:13.5px;
  box-shadow:0 8px 26px rgba(0,0,0,.4); animation:slidein .18s ease;
}
.toast.ok{border-color:rgba(46,160,67,.5); background:rgba(46,160,67,.14)}
.toast.err{border-color:rgba(229,72,77,.5); background:rgba(229,72,77,.14)}
.toast.info{border-color:var(--line-2)}
@keyframes slidein{from{opacity:0; transform:translateX(20px)}to{opacity:1; transform:none}}

@media(max-width:560px){
  .topbar{padding:10px 14px}
  .content{padding:18px 14px 50px}
  .env-grid{grid-template-columns:1fr}
  .job-item{flex-wrap:wrap}
  .job-item .job-when{text-align:left}
  .cleanup-item{flex-wrap:wrap}
  .cleanup-item .cleanup-deleteby{margin-left:0}
}
