:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --on-surface: #1c1b1f;
  --muted: #6b6772;
  --line: #e6e3ea;
  --primary: #ff6d3f;       /* ember */
  --primary-700: #e04e1f;
  --primary-tint: #fff0ea;
  --accent: #7c4dff;
  --green: #1d9d63;
  --green-tint: #e5f6ee;
  --amber: #c47f12;
  --amber-tint: #fbf1dd;
  --blue: #2f6bd6;
  --blue-tint: #e8f0fd;
  --red: #c8362f;
  --red-tint: #fbe9e8;
  --grey: #7a7680;
  --grey-tint: #efedf1;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(20,12,30,.08);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--on-surface); }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(100deg, #2a2433, #1b1722);
  color: #fff;
  box-shadow: var(--shadow);
}
.appbar__brand { display: flex; align-items: center; gap: 14px; }
.appbar__logo { font-size: 30px; filter: drop-shadow(0 2px 6px rgba(255,109,63,.6)); }
.appbar h1 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.appbar__sub { margin: 2px 0 0; font-size: 12px; color: #b9b3c4; }
.appbar__right { display: flex; align-items: center; gap: 14px; }

.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #cdc8d6; }
.conn__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--grey); box-shadow: 0 0 0 0 rgba(29,157,99,.5); }
.conn--on .conn__dot { background: #36d57f; animation: pulse 2s infinite; }
.conn--off .conn__dot { background: #d8a13a; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(54,213,127,.5)} 70%{box-shadow:0 0 0 7px rgba(54,213,127,0)} 100%{box-shadow:0 0 0 0 rgba(54,213,127,0)} }

/* Buttons */
.btn { font: inherit; font-size: 14px; font-weight: 600; border: none; border-radius: 10px; padding: 9px 16px; cursor: pointer; transition: transform .06s ease, background .15s ease, box-shadow .15s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(255,109,63,.35); }
.btn--primary:hover { background: var(--primary-700); }
.btn--block { width: 100%; margin-top: 14px; padding: 12px; }
.btn--icon { background: transparent; color: inherit; padding: 6px 10px; font-size: 16px; }
.btn--ghost { background: var(--grey-tint); color: var(--on-surface); padding: 7px 12px; font-size: 13px; }
.btn--ghost:hover { background: #e4e1e8; }
.btn--danger { background: var(--red-tint); color: var(--red); padding: 7px 12px; font-size: 13px; }
.btn--danger:hover { background: #f6dcda; }

/* Content */
.content { max-width: 1120px; margin: 0 auto; padding: 24px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-width: 110px; box-shadow: var(--shadow); }
.stat__num { font-size: 24px; font-weight: 700; }
.stat__label { font-size: 12px; color: var(--muted); margin-top: 2px; }

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

/* Capsule card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card__name { font-size: 16px; font-weight: 700; }
.card__id { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card__meta { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; }
.badge--task { background: var(--blue-tint); color: var(--blue); }
.badge--service { background: var(--accent); color: #fff; background: #efeaff; color: #5a37d6; }
.badge--tier { background: var(--grey-tint); color: var(--grey); }

.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.state__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state--running { background: var(--green-tint); color: var(--green); }
.state--starting { background: var(--amber-tint); color: var(--amber); }
.state--exited { background: var(--blue-tint); color: var(--blue); }
.state--failed { background: var(--red-tint); color: var(--red); }
.state--terminated { background: var(--grey-tint); color: var(--grey); }

.progress { }
.progress__bar { height: 8px; background: var(--grey-tint); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; background: linear-gradient(90deg, var(--primary), #ffa177); border-radius: 999px; transition: width .4s ease; }
.progress__msg { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

.card__foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; }
.card__startup { font-size: 12px; color: var(--muted); }
.card__actions { display: flex; gap: 8px; }

/* Empty */
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.empty__art { font-size: 46px; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(20,12,30,.4); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: 420px; max-width: 92vw; background: var(--surface); box-shadow: -8px 0 32px rgba(20,12,30,.2); z-index: 30; padding: 22px; transform: translateX(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1); overflow-y: auto; }
.drawer.open { transform: translateX(0); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; }
.drawer__head h2 { margin: 0; font-size: 18px; }
.drawer__hint { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 20px; }
.chip { text-align: left; background: var(--primary-tint); border: 1px solid #ffd9c9; color: var(--primary-700); font-weight: 700; padding: 12px 14px; border-radius: 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.chip:hover { background: #ffe6db; }
.chip__tag { font-size: 10px; background: #fff; color: var(--muted); padding: 2px 8px; border-radius: 999px; }
.lbl { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.ta { width: 100%; min-height: 200px; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; resize: vertical; }

/* Toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast { background: #2a2433; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: rise .25s ease; }
.toast--err { background: var(--red); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* Tabs */
.tabs { display: flex; gap: 4px; max-width: 1120px; margin: 0 auto; padding: 0 24px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; padding: 14px 18px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--on-surface); }
.tab--active { color: var(--primary-700); border-bottom-color: var(--primary); }

.section-hint { max-width: 1120px; color: var(--muted); font-size: 13px; line-height: 1.5; margin: 4px 0 18px; }

/* Node budget summary */
.node { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; background: linear-gradient(100deg,#2a2433,#1b1722); color: #fff; border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.node__title { font-size: 13px; color: #b9b3c4; text-transform: uppercase; letter-spacing: .5px; }
.node__big { font-size: 22px; font-weight: 700; }
.node__sep { width: 1px; align-self: stretch; background: rgba(255,255,255,.15); }

/* Tenant partitions */
.tenants { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.tenant { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.tenant__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tenant__name { font-size: 17px; font-weight: 800; }
.tenant__count { font-size: 12px; color: var(--muted); }

.meter { margin-bottom: 12px; }
.meter__row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.meter__label { color: var(--muted); font-weight: 600; }
.meter__val { font-variant-numeric: tabular-nums; }
.meter__bar { height: 10px; background: var(--grey-tint); border-radius: 999px; overflow: hidden; }
.meter__fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.meter__fill--ok { background: linear-gradient(90deg,#1d9d63,#3fc98a); }
.meter__fill--warn { background: linear-gradient(90deg,#c47f12,#e8b04b); }
.meter__fill--full { background: linear-gradient(90deg,#c8362f,#e8635c); }

.tenant__caps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.tcap { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--primary-tint); color: var(--primary-700); display: inline-flex; gap: 6px; align-items: center; }
.tcap__dot { width: 6px; height: 6px; border-radius: 50%; }
.tcap--running .tcap__dot { background: var(--green); }
.tcap--starting .tcap__dot { background: var(--amber); }
.tcap--exited .tcap__dot, .tcap--terminated .tcap__dot { background: var(--grey); }
.tcap--failed .tcap__dot { background: var(--red); }
.tenant__none { font-size: 12px; color: var(--muted); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Panels + forms (management views) */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel__title { margin: 0 0 4px; font-size: 16px; }
.form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form--wide label { min-width: 130px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form input, .form select { font: inherit; font-size: 14px; color: var(--on-surface); padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; min-width: 110px; }
.form input:focus, .form select:focus { outline: 2px solid var(--primary-tint); border-color: var(--primary); }
.form .chk { flex-direction: row; align-items: center; gap: 7px; font-size: 13px; color: var(--on-surface); }
.form .chk input { min-width: auto; }

.def__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.def__meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.def__path { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }
.row-actions { display: flex; gap: 8px; }

/* Fleet / packing */
.fleet-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.fleet-bar__label { font-size: 13px; font-weight: 700; color: var(--muted); }
.fleet-bar__hint { font-size: 12px; color: var(--muted); }
.polbtn { font: inherit; font-size: 13px; font-weight: 700; border: 1px solid var(--line); background: #fff; color: var(--muted); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.polbtn:hover { border-color: var(--primary); color: var(--primary-700); }
.polbtn--active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Guided demo */
.scenarios { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.scenario { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.scenario__title { margin: 0; font-size: 16px; }
.scenario p { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.5; flex: 1; }
.scenario .btn { align-self: flex-start; }
.demo-foot { margin: 16px 0 10px; }
.demo-log { background: #1b1722; color: #e8e4f0; border-radius: var(--radius); padding: 16px 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.7; max-height: 340px; overflow-y: auto; box-shadow: var(--shadow); }
.demo-log__empty { color: #6b6478; }
.demo-line { white-space: pre-wrap; }
.demo-line--head { color: #b9b3c4; margin-top: 6px; }
.demo-line--ok { color: #4fd18a; }
.demo-line--deny { color: #ff8a7a; font-weight: 700; }

.hidden { display: none !important; }
