:root {
  --bg: #0b0c0f; --panel: #13151a; --panel2: #191c22; --line: #262a33; --line2: #323743;
  --text: #e8eaee; --muted: #8b92a0; --faint: #5d6472;
  --accent: #d4af37; --accent-ink: #1a1405;
  --green: #3fb950; --amber: #e3a008; --red: #f05252; --blue: #4f8cff;
  --radius: 10px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #0e1013; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .mark { width: 36px; height: 36px; flex: none; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 12px; letter-spacing: -0.03em; }
.brand b { display: block; font-size: 14px; } .brand span { display: block; font-size: 11px; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; text-decoration: none; color: var(--muted); }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--panel2); color: var(--text); }
.nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 4px; }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.side .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.main { padding: 26px 32px 60px; min-width: 0; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.apps { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .g2, .g3, .g4 { grid-template-columns: 1fr; } .main { padding: 18px; } }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 0; overflow: hidden; }
.card h2 { margin-bottom: 12px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: -8px 0 12px; }
.stat { padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 12px; }
.appcard { cursor: pointer; transition: border-color .15s, transform .15s; position: relative; overflow: hidden; }
.appcard:hover { border-color: var(--line2); }
.appcard .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.appcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.appcard .dom { color: var(--muted); font-size: 12.5px; }
.appcard .meta { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.appcard .meta b { color: var(--text); font-weight: 600; }
.bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 22px; margin-top: 12px; }
.bars i { border-radius: 2px; background: var(--line); }
.bars i.up { background: var(--green); } .bars i.part { background: var(--amber); } .bars i.down { background: var(--red); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live { color: var(--green); background: rgba(63,185,80,.1); border-color: rgba(63,185,80,.25); }
.pill.maintenance { color: var(--amber); background: rgba(227,160,8,.1); border-color: rgba(227,160,8,.25); }
.pill.locked { color: var(--red); background: rgba(240,82,82,.1); border-color: rgba(240,82,82,.25); }
.pill.down { color: var(--red); background: rgba(240,82,82,.1); }
.pill.gray { color: var(--muted); background: var(--panel2); }
.pill.plain::before { display: none; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; font-weight: 550; font-size: 13px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #444b59; background: #1f232a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.green { background: rgba(63,185,80,.14); color: var(--green); border-color: rgba(63,185,80,.35); }
.btn.amber { background: rgba(227,160,8,.12); color: var(--amber); border-color: rgba(227,160,8,.35); }
.btn.danger { background: rgba(240,82,82,.12); color: var(--red); border-color: rgba(240,82,82,.35); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.big { padding: 12px 16px; font-size: 14px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; font-weight: 550; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; background: #0e1013; border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,175,55,.15); }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; cursor: pointer; margin: 0; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 550; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { background: var(--red); color: #fff; font-size: 10.5px; padding: 0 6px; border-radius: 99px; margin-left: 5px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }

/* ---------- status picker ---------- */
.states { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.state { border: 1px solid var(--line2); border-radius: 10px; padding: 14px; cursor: pointer; background: #0e1013; text-align: left; }
.state:hover { border-color: #444b59; }
.state b { display: block; font-size: 15px; margin-bottom: 3px; }
.state span { color: var(--muted); font-size: 12.5px; }
.state.sel.live { border-color: var(--green); background: rgba(63,185,80,.07); }
.state.sel.maintenance { border-color: var(--amber); background: rgba(227,160,8,.07); }
.state.sel.locked { border-color: var(--red); background: rgba(240,82,82,.07); }
.langtabs { display: flex; gap: 4px; margin-bottom: 6px; }
.langtabs button { background: none; border: 1px solid var(--line2); border-radius: 6px; padding: 1px 8px; font-size: 11.5px; cursor: pointer; color: var(--muted); text-transform: uppercase; }
.langtabs button.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* ---------- content editor ---------- */
.cgroup { margin-bottom: 22px; }
.cgroup > h3 { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; }
.citem { display: grid; grid-template-columns: 220px 1fr auto; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: start; }
.citem:last-child { border-bottom: none; }
.citem .k b { display: block; } .citem .k code { font-size: 11.5px; color: var(--faint); }
.citem .who { font-size: 11px; color: var(--faint); margin-top: 6px; }
.citem img.prev { max-height: 80px; max-width: 200px; border-radius: 6px; border: 1px solid var(--line); margin-top: 6px; display: block; }
.price-row { display: grid; grid-template-columns: 70px 1fr; gap: 6px; margin-bottom: 6px; }
@media (max-width: 900px) { .citem { grid-template-columns: 1fr; } }
.dirty { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- errors ---------- */
.err { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.err:last-child { border-bottom: 0; }
.err .msg { font-family: var(--mono); font-size: 12.5px; word-break: break-word; }
.err pre { background: #0b0c0f; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; max-height: 260px; font-size: 11.5px; margin: 8px 0 0; }

/* ---------- code / terminal ---------- */
.ide { display: grid; grid-template-columns: 250px 1fr; grid-template-rows: minmax(260px, 1fr) 330px; gap: 10px; height: calc(100vh - 150px); min-height: 640px; }
.ide .files { grid-row: 1 / 3; overflow: auto; padding: 8px 0; }
.ide .files .crumb { padding: 4px 12px 8px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); word-break: break-all; }
.ide .files a { display: flex; gap: 8px; padding: 3px 12px; text-decoration: none; font-family: var(--mono); font-size: 12.5px; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ide .files a:hover { background: var(--panel2); }
.ide .files a.dir { color: #9ecbff; }
.ide .files a.on { background: rgba(212,175,55,.12); }
.ide .editor { display: flex; flex-direction: column; min-height: 0; }
.ide .editor .bar, .term .bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.ide .editor textarea { flex: 1; border: 0; border-radius: 0; background: #0b0c0f; font-family: var(--mono); font-size: 13px; line-height: 1.55; tab-size: 2; white-space: pre; resize: none; padding: 12px 14px; box-shadow: none; }
.term { display: flex; flex-direction: column; min-height: 0; background: #07080a; }
.term .out { flex: 1; overflow: auto; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-all; color: #d6d9df; }
.term .in { display: flex; border-top: 1px solid var(--line); }
.term .in span { padding: 8px 4px 8px 12px; color: var(--accent); font-family: var(--mono); }
.term .in input { border: 0; border-radius: 0; background: transparent; font-family: var(--mono); font-size: 13px; box-shadow: none; }
.term .quick { display: flex; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; flex-wrap: nowrap; }
.term .quick .btn { flex: none; }
@media (max-width: 900px) { .ide { grid-template-columns: 1fr; grid-template-rows: 200px 360px 330px; height: auto; } .ide .files { grid-row: auto; } }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
.secret { display: flex; gap: 6px; } .secret input { font-family: var(--mono); font-size: 12px; }
.banner-prev { padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-top: 10px; }
.banner-prev.info { background: rgba(79,140,255,.12); color: #9ec0ff; }
.banner-prev.warning { background: rgba(227,160,8,.12); color: #f5c75a; }
.banner-prev.success { background: rgba(63,185,80,.12); color: #7ee28d; }
.chart { width: 100%; height: 140px; display: block; }
.alertbox { border: 1px solid rgba(240,82,82,.35); background: rgba(240,82,82,.08); border-radius: 10px; padding: 12px 14px; color: #ffb4b4; }
.alertbox.warn { border-color: rgba(227,160,8,.35); background: rgba(227,160,8,.08); color: #f5c75a; }
.alertbox.ok { border-color: rgba(63,185,80,.35); background: rgba(63,185,80,.08); color: #7ee28d; }
pre.code { background: #0b0c0f; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-family: var(--mono); font-size: 12px; margin: 6px 0 0; white-space: pre; }
.logs { max-height: 460px; }
.meter { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.meter i.mid { background: var(--amber); } .meter i.hi { background: var(--red); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at top, #1a1710 0%, var(--bg) 60%); }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth .brand { padding: 0 0 22px; }

/* ---------- toast & modal ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 3px solid var(--green); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: slide .2s ease; }
.toast.err { border-left-color: var(--red); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 90; padding: 20px; backdrop-filter: blur(2px); }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 22px; }
.modal.wide { max-width: 760px; }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- iPad / kosketusnäyttö & asennettu sovellus ---------- */
@supports (padding: env(safe-area-inset-top)) {
  .side { padding-top: calc(18px + env(safe-area-inset-top)); padding-left: calc(12px + env(safe-area-inset-left)); }
  .main { padding-top: calc(26px + env(safe-area-inset-top)); padding-right: calc(32px + env(safe-area-inset-right)); padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(18px + env(safe-area-inset-bottom)); }
}
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
@media (pointer: coarse) {
  .btn { padding: 10px 15px; font-size: 14px; min-height: 42px; }
  .btn.sm { padding: 7px 11px; min-height: 36px; font-size: 13px; }
  .nav a { padding: 11px 12px; font-size: 15px; }
  .tabs a { padding: 12px 16px; font-size: 15px; }
  input, select, textarea { font-size: 16px !important; min-height: 42px; } /* estää iOS:n automaattisen zoomauksen */
  .ide .files a { padding: 8px 12px; font-size: 14px; }
  .langtabs button { padding: 5px 12px; font-size: 13px; }
  .check { font-size: 15px; } input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
  .state { padding: 18px; }
  tr.click td { padding: 14px; }
}
/* iPad pystyasennossa (1024 px): kapeampi sivupalkki */
@media (min-width: 901px) and (max-width: 1100px) {
  .shell { grid-template-columns: 200px 1fr; }
  .main { padding-left: 22px; padding-right: 22px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ide { grid-template-columns: 210px 1fr; }
}
/* asennettuna sovelluksena (Koti-valikosta) */
@media (display-mode: standalone) { body { overscroll-behavior: none; } .side { user-select: none; -webkit-user-select: none; } }
.install-tip { display: none; }


/* Ohjeet */
ol.guide{margin:6px 0 0;padding-left:22px;display:grid;gap:10px}
ol.guide li b{display:block;margin-bottom:2px}
ol.guide li div{color:var(--muted);line-height:1.5}
pre.guidecode{background:var(--bg);border:1px solid var(--line);border-radius:10px;padding:10px 12px;overflow-x:auto;white-space:pre-wrap;word-break:break-all;font-size:12.5px;margin:6px 0 14px}
