/* ============================================================
   CB Design System — matches CB Cloud Portal (route53 pages)
   ============================================================ */
:root {
  --brand-500: #00528b;
  --brand-600: #004778;
  --brand-700: #003d68;
  --brand-100: #dbeafe;
  --brand-50:  #f0f8ff;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 0.75rem;
  --radius-lg: 1rem;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: Arial, Helvetica, ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(0, 82, 139, 0.06), transparent),
    radial-gradient(700px 500px at 85% 35%, rgba(0, 82, 139, 0.04), transparent),
    linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  color: #1e293b;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header — sticky dark blue bar */
header {
  position: sticky; top: 0; z-index: 40;
  background: var(--brand-600); color: #fff;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 1.5rem;
  height: 4rem; display: flex; align-items: center; gap: 1rem;
}
.header-logo {
  height: 2rem; width: auto; background: #fff;
  border-radius: 4px; padding: 0.15rem 0.5rem;
}
.header-title { flex: 1; }
.header-title h1 { font-size: 1.125rem; font-weight: 600; line-height: 1.2; }
.header-title p { font-size: 0.7rem; opacity: 0.8; margin-top: -1px; }

#header-right { display: flex; align-items: center; gap: 0.75rem; }
#user-info { display: flex; align-items: center; gap: 0.6rem; }
.header-username { font-size: 0.8rem; color: rgba(255, 255, 255, 0.85); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2); color: #fff;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 700;
}
.btn-signout {
  background: rgba(255, 255, 255, 0.15); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3); box-shadow: none;
}
.btn-signout:hover { background: rgba(255, 255, 255, 0.25); }

/* Main */
main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 1.5rem; }
.screen { display: block; }
.hidden { display: none !important; }

/* Cards */
.card {
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-soft);
}
.card.centered { max-width: 420px; margin: 4rem auto; text-align: center; }
.card.centered .logo-circle {
  width: 56px; height: 56px; border-radius: 50%; background: var(--brand-500);
  color: #fff; display: grid; place-items: center; font-weight: 800;
  font-size: 1.25rem; margin: 0 auto 1rem;
}
.card h2 { font-size: 1.25rem; color: #0f172a; }
.card p { margin: 0.75rem 0 1.5rem; color: #64748b; font-size: 0.9rem; line-height: 1.5; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.toolbar h2 { flex: 1; font-size: 1.25rem; font-weight: 600; color: #0f172a; }
.toolbar .count { color: #94a3b8; font-weight: 400; font-size: 0.85rem; margin-left: 0.4rem; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem; border: 1px solid transparent; border-radius: var(--radius);
  font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(0, 82, 139, 0.25); }
.btn-primary { background: var(--brand-500); color: #fff; border-color: var(--brand-600); }
.btn-primary:hover { background: var(--brand-600); }
.btn-secondary { background: #fff; color: #475569; border-color: #e2e8f0; box-shadow: var(--shadow-soft); }
.btn-secondary:hover { background: #f8fafc; color: #1e293b; }
.btn-block { display: block; width: 100%; padding: 0.65rem; font-size: 0.9rem; }

/* App grid */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.9rem; }
.app-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow-soft); transition: all 0.15s;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.app-card:hover { box-shadow: 0 10px 30px rgba(0, 82, 139, 0.12); border-color: #93c5fd; transform: translateY(-2px); }
.app-card .icon { font-size: 1.75rem; }
.app-card .tag {
  align-self: flex-start; font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--brand-500); background: var(--brand-50);
  border: 1px solid var(--brand-100); padding: 0.1rem 0.5rem; border-radius: 999px;
}
.app-card h3 { font-size: 1rem; font-weight: 600; color: #0f172a; }
.app-card p { font-size: 0.82rem; color: #64748b; line-height: 1.5; flex: 1; }
.app-card .id { font-family: ui-monospace, "SF Mono", monospace; font-size: 0.7rem; color: #94a3b8; }
.app-card a.open { text-decoration: none; margin-top: 0.25rem; }

/* Empty / status states */
.empty {
  grid-column: 1 / -1; text-align: center; color: #94a3b8; padding: 3.5rem 1rem;
  border: 1px dashed #cbd5e1; border-radius: var(--radius-lg); background: #fff;
}
.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.82rem;
  margin-top: 1rem; text-align: left; word-break: break-word;
}
.spinner {
  width: 26px; height: 26px; border: 3px solid #e2e8f0; border-top-color: var(--brand-500);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 3rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
footer { text-align: center; padding: 1rem; font-size: 0.72rem; color: #94a3b8; border-top: 1px solid #e2e8f0; }

/* Dialog */
dialog {
  border: 1px solid #e2e8f0; border-radius: var(--radius-lg); padding: 0; max-width: 560px;
  width: 92%; box-shadow: var(--shadow-soft); color: #1e293b;
}
dialog::backdrop { background: rgba(15, 23, 42, 0.4); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid #e2e8f0;
}
.modal-head strong { font-size: 1rem; }
.modal-body { padding: 1.25rem; font-size: 0.85rem; line-height: 1.6; color: #475569; }
.modal-body ol { padding-left: 1.25rem; margin: 0.5rem 0; }
.modal-body code { font-family: ui-monospace, monospace; color: var(--brand-500); }
pre {
  background: #0b1220; border-radius: var(--radius); padding: 0.75rem 0.9rem;
  overflow-x: auto; font-size: 0.78rem; color: #cbd5e1; font-family: ui-monospace, monospace;
}

/* Toast */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 0.6rem 1.1rem; border-radius: var(--radius);
  font-size: 0.82rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60;
}
.toast.show { opacity: 0.95; }

/* ============================================================
   Tabbed shell — apps open as kept-alive iframes (state persists)
   ============================================================ */
html, body { height: 100%; }
#shell { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#tabstrip {
  display: flex; align-items: stretch; gap: 4px; padding: 6px 12px 0;
  background: #fff; border-bottom: 1px solid #e2e8f0; overflow-x: auto;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid #e2e8f0; border-bottom: none; border-radius: 8px 8px 0 0;
  background: #f1f5f9; color: #475569; font-size: 0.82rem; cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #e7edf3; }
.tab.active { background: #fff; color: var(--brand-500); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand-500); }
.tab .tab-ico { font-size: 0.95rem; }
.tab .tab-close {
  border: none; background: transparent; color: #94a3b8; cursor: pointer;
  font-size: 0.95rem; line-height: 1; padding: 1px 3px; border-radius: 4px;
}
.tab .tab-close:hover { color: #ef4444; background: #fee2e2; }
#content { flex: 1; position: relative; min-height: 0; }
#view-home { position: absolute; inset: 0; overflow: auto; padding: 1.5rem; }
.appframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }

/* Compact chrome — keep the app area tall, no page scroll (only inner areas scroll) */
html, body { overflow: hidden; }
header .header-inner { height: 3rem; max-width: none; }
.header-title h1 { font-size: 1rem; }
.header-title p { display: none; }
#tabstrip { padding: 4px 1.5rem 0; }
.tab { padding: 6px 11px; }
.lang-select {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35);
  border-radius: 8px; padding: 5px 8px; font: 600 12px Arial, Helvetica, sans-serif; cursor: pointer;
}
.lang-select option { color: #1e293b; }
