/* CZSM OS - Launch Zero stylesheet.
   One dependency-free stylesheet shared by the core and every module. */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --brand: #2f5fd0;
  --brand-dark: #23479c;
  --sidebar: #111a2e;
  --sidebar-muted: #93a2bd;
  --ok: #1f9d63;
  --warn: #c9821a;
  --bad: #cf3d3d;
  --info: #2f7ec0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--sidebar);
  color: #e6ecf7;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #4d7ff0, #7a5cf0);
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px; color: #fff;
}
.brand-text { font-weight: 600; letter-spacing: .2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  color: var(--sidebar-muted);
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.is-active { background: rgba(77,127,240,.22); color: #fff; }
.nav-link.subtle { font-size: 13px; }

.sidebar-foot { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; }
.who-name { font-weight: 600; font-size: 13px; }
.who-role { color: var(--sidebar-muted); font-size: 12px; text-transform: capitalize; }

/* ---- Content ---- */
.content { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 21px; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-body { padding: 16px 18px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---- Stat tiles ---- */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 22px; font-weight: 650; margin-top: 4px; letter-spacing: -.4px; }
.stat-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-alt); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: var(--surface-alt); }
td.wrap, th.wrap { white-space: normal; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Buttons and forms ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--sidebar-muted); border-color: rgba(255,255,255,.22); }
.btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-alt); color: var(--text); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f3c9c9; }
.btn-danger:hover { background: #fdf1f1; color: var(--bad); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 4px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,95,208,.25); border-color: var(--brand); }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=text] { max-width: 240px; }
.filters select { max-width: 190px; }

/* ---- Flash ---- */
.flash { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; border: 1px solid transparent; }
.flash-success { background: #e9f8f0; border-color: #bfe8d3; color: #16694a; }
.flash-warning { background: #fdf4e4; border-color: #f2ddb4; color: #8a5a09; }
.flash-error { background: #fdecec; border-color: #f3c9c9; color: #96201f; }
.flash-info { background: #eaf3fc; border-color: #c7ddf3; color: #1d5e93; }
.flash-close { border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; color: inherit; }

/* ---- Alerts list ---- */
.alert-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert-item:last-child { border-bottom: 0; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--info); }
.alert-critical .alert-dot { background: var(--bad); }
.alert-warning .alert-dot { background: var(--warn); }
.alert-success .alert-dot { background: var(--ok); }
.alert-body { min-width: 0; }
.alert-title { font-weight: 600; }
.alert-meta { color: var(--muted); font-size: 12px; }

/* ---- Module cards ---- */
.module-card { display: flex; flex-direction: column; gap: 8px; }
.module-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.module-icon { width: 30px; height: 30px; border-radius: 8px; background: #eef2f8; display: grid; place-items: center; font-size: 14px; }
.module-desc { color: var(--muted); font-size: 12.5px; }
.module-links { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; }

.switch { display: flex; align-items: center; gap: 8px; }
.switch input { width: auto; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 26px 18px; text-align: center; color: var(--muted); }
.error-page { max-width: 620px; margin: 8vh auto; text-align: center; }
.error-code { font-size: 44px; font-weight: 700; color: var(--brand); letter-spacing: -1px; }

.login-wrap { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; background: #eef2f8; color: var(--muted); }
.badge-ok { background: #e6f6ee; color: var(--ok); }
.badge-warn { background: #fdf3e2; color: var(--warn); }
.badge-bad { background: #fdeaea; color: var(--bad); }
.badge-info { background: #e8f2fb; color: var(--info); }
.badge-muted { background: #eef2f8; color: var(--muted); }

/* ---- Project workspace (360 degree / three-pane view) ---- */
.page-workspace .content { padding: 0; }

.workspace {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 328px;
  align-items: start;
}
.ws-pane { min-width: 0; }
.ws-left, .ws-right {
  align-self: start;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  background: var(--surface);
}
.ws-left { border-right: 1px solid var(--border); }
.ws-right { border-left: 1px solid var(--border); }
.ws-center { background: var(--bg); min-height: 100vh; }
.ws-center-body { padding: 18px 20px 60px; }

.ws-project { padding: 16px 14px 13px; border-bottom: 1px solid var(--border); }
.ws-project h1 { margin: 0; font-size: 16px; letter-spacing: -.2px; }
.ws-project .ws-client { font-size: 12.5px; margin-top: 2px; }
.ws-project .ws-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 9px; }

.ws-section { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.ws-section:last-child { border-bottom: 0; }
.ws-section-title {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); margin: 0 0 8px;
}

.ws-nav { display: flex; flex-direction: column; gap: 2px; }
.ws-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 8px;
  color: var(--text); font-size: 13px; font-weight: 500;
}
.ws-nav-item:hover { background: var(--surface-alt); text-decoration: none; }
.ws-nav-item.is-active { background: #eef3ff; color: var(--brand); }
.ws-nav-item .ws-nav-count { margin-left: auto; }

.ws-mod { display: flex; align-items: flex-start; gap: 9px; padding: 7px 8px; border-radius: 8px; }
.ws-mod:hover { background: var(--surface-alt); }
.ws-mod.is-active { background: #eef3ff; }
.ws-mod-main { flex: 1; min-width: 0; }
.ws-mod-main > a { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.ws-mod.is-active .ws-mod-main > a { color: var(--brand); }
.ws-mod-sub { color: var(--muted); font-size: 11.5px; }
.ws-mod-icon {
  flex: none; width: 26px; height: 26px; border-radius: 7px;
  background: #eef2f8; color: var(--brand);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.ws-mod-actions { display: flex; align-items: center; }
.ws-toggle {
  border: 0; cursor: pointer; font-size: 11px; font-weight: 700;
  padding: 3px 7px; border-radius: 6px; font-family: inherit;
}
.ws-toggle-off { color: var(--ok); background: #e6f6ee; }
.ws-toggle-on { color: var(--brand); background: #eef3ff; }

.ws-center-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; padding: 13px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
.ws-center-head h2 { margin: 0; font-size: 15px; }
.ws-center-head .ws-crumb { color: var(--muted); font-size: 12px; }

.ws-frame { display: block; width: 100%; min-height: 640px; border: 0; background: var(--bg); }

.ws-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px;
}
.ws-card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.ws-card-head h3 { margin: 0; font-size: 13.5px; }
.ws-card-body { padding: 14px; }
.ws-right .ws-card { margin: 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.ws-right .ws-card-body { padding: 12px; }
.ws-right .ws-section-title { margin-bottom: 4px; }

.ws-kv { width: 100%; border-collapse: collapse; }
.ws-kv th, .ws-kv td { border: 0; padding: 3px 0; white-space: normal; font-size: 12.5px; }
.ws-kv th { background: transparent; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; width: 46%; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .ws-left, .ws-right { position: static; max-height: none; }
  .ws-left { border-right: 0; border-bottom: 1px solid var(--border); }
  .ws-right { border-left: 0; border-top: 1px solid var(--border); }
}

/* ---- Embedded module views (rendered inside the workspace iframe) ---- */
body.embedded .sidebar { display: none; }
body.embedded .content { padding: 0; }
body.embedded .page-head { padding: 16px 18px 0; }
body.embedded .filters { padding: 0 18px; }
