/* ═══════════════════════════════════════════════════════════════════════════
   Kodama Business Hub — same design tokens and base components as the applications
   (Production Scheduler 2.0, SAP Horizon inspired), light/dark.
   Tokens and the "base components" block are the shared UI kit: keep them identical in every app.
   ═══════════════════════════════════════════════════════════════════════════ */
@font-face { font-family: "72"; src: url("https://ui5.sap.com/resources/sap/ui/core/themes/sap_horizon/fonts/72-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "72"; src: url("https://ui5.sap.com/resources/sap/ui/core/themes/sap_horizon/fonts/72-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "72"; src: url("https://ui5.sap.com/resources/sap/ui/core/themes/sap_horizon/fonts/72-Semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --font: "72", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f4;
  --border: #dfe3e8;
  --border-strong: #c9ced6;
  --text: #1d2d3e;
  --text-2: #556b82;
  --text-3: #8396a8;
  --brand: #0070f2;
  --brand-strong: #0057d2;
  --brand-soft: #e8f2ff;
  --accent: #7858ff;
  --accent-soft: #f0ecff;
  --ok: #256f3a;
  --ok-bg: #e5f5e9;
  --warn: #c35500;
  --warn-bg: #fff3e0;
  --err: #d20a0a;
  --err-bg: #ffeaea;
  --info-bg: #e8f2ff;
  --shadow-1: 0 1px 2px rgba(29, 45, 62, .08), 0 0 0 1px rgba(29, 45, 62, .04);
  --shadow-2: 0 6px 24px rgba(29, 45, 62, .14), 0 0 0 1px rgba(29, 45, 62, .06);
  --radius: 8px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  --bg: #0f141a;
  --surface: #171d24;
  --surface-2: #1c232b;
  --surface-3: #232b35;
  --border: #2a333e;
  --border-strong: #3a4552;
  --text: #e8edf2;
  --text-2: #a4b2c1;
  --text-3: #74859a;
  --brand: #4b9bff;
  --brand-strong: #6aadff;
  --brand-soft: #142740;
  --accent: #9b85ff;
  --accent-soft: #241f3d;
  --ok: #5fd08a;
  --ok-bg: #12291b;
  --warn: #ffb24a;
  --warn-bg: #2e2110;
  --err: #ff6b6f;
  --err-bg: #331417;
  --info-bg: #142740;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
}

/* ── base components (shared with the applications) ─────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.4 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ico svg { width: 100%; height: 100%; }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .input:focus-visible, a:focus-visible, .switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--err); }
.btn.lg { height: 40px; padding: 0 22px; font-size: 14px; font-weight: 600; }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-group { display: inline-flex; gap: 4px; align-items: center; }
.input { height: 30px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; min-width: 0; width: 100%; }
textarea.input { height: auto; padding: 6px 8px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
select.input { padding-right: 4px; cursor: pointer; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--radius-sm); padding: 2px; gap: 2px; height: 30px; }
.seg button { border: 0; background: transparent; border-radius: 5px; padding: 0 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.err { background: var(--err-bg); color: var(--err); }
.chip.info { background: var(--info-bg); color: var(--brand); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 0%, var(--brand-soft), transparent), var(--bg); overflow: auto; }
.auth-card { width: min(440px, 94vw); padding: 40px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-2); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.auth-card h1 { margin: 8px 0 0; font-size: 24px; }
.auth-card p { margin: 0 0 8px; color: var(--text-2); }
.auth-card form { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-card form .btn { justify-content: center; margin-top: 6px; }
.auth-error { color: var(--err); background: var(--err-bg); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px; width: 100%; }
.auth-credits { margin-top: 22px; font-size: 11px; color: var(--text-3); }
.kv-logo { display: block; width: auto; height: 40px; max-width: 100%; margin: 2px auto 8px; }
.kv-dark { display: none; }
:root[data-theme="dark"] .kv-light { display: none; }
:root[data-theme="dark"] .kv-dark { display: block; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); position: relative; flex: none; box-shadow: inset 0 -8px 16px rgba(0, 0, 0, .12); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; height: 4px; border-radius: 2px; background: #fff; }
.brand-mark::before { left: 6px; top: 9px; width: 12px; }
.brand-mark::after { left: 11px; top: 17px; width: 13px; opacity: .8; }
.brand-mark.lg { width: 56px; height: 56px; border-radius: 14px; }
.brand-mark.lg::before { left: 11px; top: 17px; width: 22px; height: 7px; border-radius: 4px; }
.brand-mark.lg::after { left: 20px; top: 31px; width: 25px; height: 7px; border-radius: 4px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 56px; position: sticky; top: 0; z-index: 50; }
.brand { display: flex; gap: 10px; align-items: center; min-width: 190px; }
.brand-title { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--text-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user { font-size: 12px; color: var(--text-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nav { display: flex; gap: 2px; }
.app-nav a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; text-decoration: none; }
.app-nav a:hover { background: var(--surface-3); }
.app-nav a.on { background: var(--brand-soft); color: var(--brand); }

.tabs { display: flex; align-items: center; gap: 2px; padding: 4px 8px 0; border-bottom: 1px solid var(--border); flex: none; }
.tabs > button[data-tab] { border: 0; background: transparent; padding: 8px 12px; border-bottom: 2px solid transparent; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); font-weight: 600; }
.tabs > button[data-tab].on { color: var(--brand); border-bottom-color: var(--brand); }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1100; }
.toast { display: flex; gap: 10px; align-items: flex-start; min-width: 300px; max-width: 460px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-2); padding: 11px 12px; border-left: 4px solid var(--brand); animation: tin .18s ease-out; }
.toast.success { border-left-color: var(--ok); } .toast.error { border-left-color: var(--err); } .toast.warn { border-left-color: var(--warn); }
.toast .t-title { font-weight: 700; }
.toast .t-msg { color: var(--text-2); font-size: 12px; margin-top: 2px; white-space: pre-line; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.dlg-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 26, .42); z-index: 900; display: grid; place-items: center; animation: fin .12s; }
@keyframes fin { from { opacity: 0; } }
.dlg { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2); width: min(760px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.dlg.narrow { width: min(480px, 94vw); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; font-size: 16px; }
.dlg-head .sub { color: var(--text-2); font-size: 12px; }
.dlg-body { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); align-items: center; }
.dlg-foot .dlg-err { color: var(--err); font-size: 12px; margin-right: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.fg { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fg > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.fg .hint { font-size: 11.5px; color: var(--text-3); }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.radio-card { border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; background: transparent; text-align: left; }
.radio-card:hover { border-color: var(--brand); }
.radio-card.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.radio-card b { font-size: 12.5px; }
.radio-card span { font-size: 11.5px; color: var(--text-2); }
.note { background: var(--info-bg); color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 12px; display: flex; gap: 8px; align-items: center; }
.note.warn { background: var(--warn-bg); }
.note.err { background: var(--err-bg); }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--brand); animation: rot .8s linear infinite; margin: 40px auto; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ── portal ─────────────────────────────────────────────────────────────── */
.acting { display: flex; align-items: center; gap: 10px; padding: 7px 14px; background: var(--warn-bg); color: var(--warn); font-weight: 600; font-size: 12px; }
.page { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--text-2); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-3); }
.sec-title { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; margin: 4px 0 0; }

/* launchpad */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-1); padding: 18px; display: flex; flex-direction: column; gap: 12px; transition: box-shadow .15s, transform .15s; }
.tile:hover { box-shadow: var(--shadow-2); }
.tile.off { opacity: .6; }
.tile-head { display: flex; gap: 12px; align-items: center; }
.tile-icon { width: 48px; height: 48px; border-radius: 12px; flex: none; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, var(--accent))); box-shadow: inset 0 -8px 16px rgba(0, 0, 0, .12); }
.tile-icon .ico { width: 26px; height: 26px; }
.tile-name { font-size: 16px; font-weight: 700; }
.tile-ver { font-size: 11px; color: var(--text-3); }
.tile-desc { color: var(--text-2); font-size: 12.5px; line-height: 1.45; flex: 1; }
.tile-envs { display: flex; flex-direction: column; gap: 6px; }
.env-btn { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); text-decoration: none; color: var(--text); background: var(--surface); transition: border-color .12s, background .12s; }
.env-btn:hover { border-color: var(--brand); background: var(--brand-soft); }
.env-btn .env-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-btn .env-host { color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.env-btn .ico { color: var(--brand); }

/* tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; color: var(--text-2); padding: 7px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl .main { font-weight: 600; }
.tbl .sub { font-size: 11.5px; color: var(--text-3); }

/* KPI strip (same card as the scheduler) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 9px 12px 10px; min-width: 0; }
.kpi .k-label { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-value { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.3px; white-space: nowrap; }
.kpi .k-value small { font-size: 12px; font-weight: 600; color: var(--text-2); }
.kpi .k-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, var(--accent))); color: #fff; }
.kpi.hero .k-label, .kpi.hero .k-sub { color: rgba(255, 255, 255, .85); }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { width: 34px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(14px); }

.secret { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); font-family: var(--mono); font-size: 14px; user-select: all; word-break: break-all; }
.app-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.app-row:last-child { border-bottom: 0; }
.app-row .tile-icon { width: 36px; height: 36px; border-radius: 9px; }
.app-row .tile-icon .ico { width: 20px; height: 20px; }
.app-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .brand { min-width: 0; }
  .user { display: none; }
  .page { padding: 14px 12px 40px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* environments */
a.tile, button.tile { text-decoration: none; color: inherit; text-align: left; border: 0; cursor: pointer; font: inherit; }
a.tile:hover, button.tile:hover { transform: translateY(-1px); }
.env-go { display: flex; align-items: center; justify-content: flex-end; gap: 6px; color: var(--brand); font-weight: 600; }
.env-tile { border-top: 3px solid var(--accent); }
.env-tile.env-TEST { border-top-color: var(--warn); }
.env-tile.env-PROD { border-top-color: var(--err); }
.env-now { display: flex; align-items: center; gap: 8px; padding: 0 4px 0 0; }
.env-now-name { font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td.center, .tbl th.center { text-align: center; }
.tbl input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* Brand: Kodama Business Hub is the product (icon + name), Kodamaverse the company (logo in the credits) */
#root { min-height: 100%; display: flex; flex-direction: column; }
.page { flex: 1; width: 100%; }
a.brand { text-decoration: none; color: inherit; }
.hub-icon { width: 32px; height: 32px; flex: none; display: block; border-radius: 8px; }
.hub-icon.lg { width: 64px; height: 64px; border-radius: 16px; box-shadow: var(--shadow-2); }
.auth-credits { line-height: 1.5; }
.kv-footer { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px 18px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 11px; }

/* environment administration: one card per environment — 1 SAP connection, 2 applications, 3 who uses what */
.env-card { border-top: 3px solid var(--accent); box-shadow: var(--shadow-1); }
.env-card.env-TEST { border-top-color: var(--warn); }
.env-card.env-PROD { border-top-color: var(--err); }
.env-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.env-card-name { font-size: 15px; font-weight: 700; }
.env-steps { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.300fr); border-top: 1px solid var(--border); }
.env-step { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 14px; min-width: 0; }
.env-steps > .env-step + .env-step { border-left: 1px solid var(--border); }
.env-step-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.env-step-head h3 { margin: 0; font-size: 13px; }
.step-n { width: 20px; height: 20px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none; align-self: center; }
.env-step .grow { flex: 1; min-width: 0; }
.link-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.link-row.off { opacity: .55; }
.link-row .tile-icon { width: 32px; height: 32px; border-radius: 8px; }
.link-row .tile-icon .ico { width: 18px; height: 18px; }
.env-step .tbl-wrap { border: 1px solid var(--border); border-radius: var(--radius); }
@media (max-width: 900px) { .env-steps { grid-template-columns: 1fr; } .env-steps > .env-step + .env-step { border-left: 0; border-top: 1px solid var(--border); } }
.topbar .env-now { padding: 4px 6px 4px 12px; border-left: 1px solid var(--border-strong); margin-left: 4px; }
