:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --border: #e4e6ef;
  --text: #14142b;
  --muted: #6e7191;
  --primary: #4d3edb;
  --primary-dark: #372aa8;
  --danger: #b42318;
  --pending: #b54708;
  --pending-bg: #fef0c7;
  --approved: #067647;
  --approved-bg: #d1fadf;
  --declined: #b42318;
  --declined-bg: #fee4e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.topbar .brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.topbar nav {
  display: flex;
  gap: 24px;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding-bottom: 4px;
}

.topbar nav a.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.topbar .clinic-name {
  color: var(--muted);
  font-size: 14px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
}

h1 {
  font-size: 28px;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.pending { color: var(--pending); background: var(--pending-bg); }
.badge.approved { color: var(--approved); background: var(--approved-bg); }
.badge.declined, .badge.auto_declined { color: var(--declined); background: var(--declined-bg); }

.actions { display: flex; gap: 8px; justify-content: flex-end; }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 18px;
  border: none;
  cursor: pointer;
}

button.btn-primary {
  background: var(--primary);
  color: #fff;
}
button.btn-primary:hover { background: var(--primary-dark); }

button.btn-secondary {
  background: #eceefb;
  color: var(--text);
}

button.btn-secondary:hover { background: #dde0f7; }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 43, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 28px;
}

.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.modal label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.modal textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.modal select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: inherit;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.modal select:focus {
  outline: none;
  border-color: var(--primary);
}

.modal .field-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p.subtitle { margin-bottom: 24px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin: 10px 0 0;
  display: none;
}

.error-text.visible { display: block; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters button {
  background: #eceefb;
  color: var(--text);
  padding: 6px 14px;
  font-size: 13px;
}
.filters button.active { background: var(--primary); color: #fff; }

/* ===========================================================================
   Platform console (platform.html) — the platform owner's app designer.
   Everything here is prefixed pc- so it cannot leak into the clinic-admin
   pages that share this stylesheet.
   ======================================================================== */

.pc-body { height: 100vh; overflow: hidden; }
#pc-app { height: 100vh; display: flex; flex-direction: column; }
#pc-app[hidden], #pc-gate[hidden], .pc-footer[hidden], .pc-problems[hidden] { display: none; }

.pc-visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.pc-brand-sub { font-weight: 500; color: var(--muted); font-size: 14px; margin-left: 4px; }
.pc-topbar-right { display: flex; align-items: center; gap: 16px; }
.pc-hint { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 8px 0 0; }

.pc-layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 372px;
}
.pc-orgs, .pc-preview { background: var(--card); padding: 16px; overflow-y: auto; }
.pc-orgs { border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.pc-preview { border-left: 1px solid var(--border); }
.pc-editor { overflow-y: auto; padding: 24px 28px 120px; }

.pc-input, .pc-editor input[type="text"], .pc-editor input[type="url"],
.pc-editor input[type="number"], .pc-editor input[type="tel"],
.pc-editor select, .pc-editor textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.pc-editor textarea { resize: vertical; min-height: 64px; }
.pc-input:focus, .pc-editor input:focus, .pc-editor select:focus, .pc-editor textarea:focus,
.pc-org:focus-visible, .pc-editor button:focus-visible, .pc-footer button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}

/* Organization list */
.pc-org-list { display: flex; flex-direction: column; gap: 4px; }
.pc-org {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px; border-radius: 10px; background: transparent;
  text-align: left; color: var(--text); font-weight: 500;
}
.pc-org:hover { background: var(--bg); }
.pc-org.selected { background: #ecebfb; }
.pc-org-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.pc-org-code { color: var(--muted); font-size: 11px; display: block; font-weight: 400; }
.pc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pending); flex: none; }
.pc-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--muted); flex: none;
}
.pc-badge.custom { background: var(--pending-bg); color: var(--pending); }

/* Editor */
.pc-editor h1 { margin: 0; font-size: 22px; }
.pc-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.pc-editor-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.pc-panel { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.pc-panel > h2 { margin: 0 0 4px; font-size: 15px; }
.pc-panel > .pc-hint { margin: 0 0 14px; }
.pc-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pc-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pc-field > label, .pc-field > .pc-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.pc-field.wide { grid-column: 1 / -1; }
.pc-field .pc-count { font-size: 11px; color: var(--muted); align-self: flex-end; }
.pc-field.invalid input, .pc-field.invalid select, .pc-field.invalid textarea { border-color: var(--danger); }
.pc-colour { display: flex; gap: 8px; align-items: center; }
.pc-colour input[type="color"] { width: 38px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: #fff; flex: none; }
.pc-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.pc-toggle input { width: 16px; height: 16px; }

.pc-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.pc-row > .pc-field { flex: 1; }
.pc-icon-btn { padding: 7px 9px; background: var(--bg); color: var(--text); border-radius: 8px; font-size: 13px; line-height: 1; }
.pc-icon-btn:hover:not(:disabled) { background: #e6e8f3; }
.pc-icon-btn.danger { color: var(--danger); }
.pc-btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.pc-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pc-tab { background: var(--bg); color: var(--muted); padding: 7px 12px; border-radius: 8px; font-size: 13px; }
.pc-tab.active { background: var(--primary); color: #fff; }

.pc-section { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: #fff; }
.pc-section.flash { box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.35); }
.pc-section-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.pc-section-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: transparent; padding: 4px; text-align: left; color: var(--text); }
.pc-section-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--primary); flex: none; }
.pc-section-summary { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-section-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.pc-section-body > .pc-grid { margin-top: 12px; }
.pc-native-note { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }

.pc-items { margin-top: 14px; }
.pc-items > .pc-label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 8px; }
.pc-item { border: 1px dashed var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fbfbfe; }
.pc-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pc-item-title { flex: 1; font-size: 12.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-action { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: #fff; }
.pc-action > .pc-label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 8px; }

.pc-empty { color: var(--muted); text-align: center; padding: 64px 24px; font-size: 14px; }
.pc-error-box { background: var(--declined-bg); color: var(--declined); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }

/* Footer */
.pc-footer {
  position: fixed; left: 260px; right: 372px; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 28px; background: var(--card); border-top: 1px solid var(--border);
  box-shadow: 0 -6px 18px rgba(20, 20, 43, 0.06);
}
.pc-footer-status { font-size: 13px; color: var(--muted); min-width: 0; }
.pc-footer-status .dirty { color: var(--pending); font-weight: 600; }
.pc-footer-status .ok { color: var(--approved); font-weight: 600; }
.pc-footer-status .bad { color: var(--danger); font-weight: 600; }
.pc-footer-actions { display: flex; gap: 8px; flex: none; }
.pc-problems {
  position: fixed; left: 276px; right: 388px; bottom: 68px; max-height: 40vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--declined); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(20, 20, 43, 0.18);
}
.pc-problems-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; font-size: 13px; color: var(--danger); }
.pc-problem { display: block; width: 100%; text-align: left; background: transparent; padding: 6px 4px; border-radius: 6px; color: var(--text); font-weight: 400; font-size: 13px; }
.pc-problem:hover { background: var(--declined-bg); }
.pc-problem code { color: var(--danger); font-size: 12px; }

/* JSON drawer */
.pc-json-modal { width: min(820px, 92vw); max-width: none; }
.pc-json-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.pc-json-tab.active { background: var(--primary); color: #fff; }
.pc-json-pre { background: #0f1226; color: #e6e8ff; border-radius: 10px; padding: 14px; font-size: 12px; line-height: 1.5; max-height: 52vh; overflow: auto; margin: 0; white-space: pre; }

/* Phone preview */
.pc-preview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pc-preview-head label { font-weight: 700; font-size: 13px; flex: none; }
.pc-phone {
  --p-primary: #3355D8; --p-primary-dark: #1E2E7A; --p-primary-light: #6E8BF5;
  --p-hero-start: #2C6E9E; --p-hero-end: #3355D8; --p-tint: #e7ecfc;
  width: 320px; height: 620px; margin: 0 auto;
  border: 9px solid #14142b; border-radius: 38px; background: #f5f7fb;
  display: flex; flex-direction: column; overflow: hidden; font-size: 13px; color: #14172b;
}
.pp-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 700; font-size: 15px; }
.pp-scroll { flex: 1; overflow-y: auto; padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.pp-tabs { display: flex; background: #fff; border-top: 1px solid #e4e7f0; padding: 7px 4px 9px; }
.pp-tab { flex: 1; text-align: center; font-size: 10px; color: #9aa1b6; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.pp-tab.active { color: var(--p-primary); font-weight: 700; }
.pp-tab .pp-glyph { font-size: 15px; }
.pp-native { border: 1px dashed #b9c0d6; border-radius: 14px; padding: 12px; color: #666e86; font-size: 12px; background: #fff; }
.pp-native b { display: block; color: #14172b; font-size: 13px; }
.pp-native.hero { border: none; color: rgba(255,255,255,0.85); background: linear-gradient(135deg, var(--p-hero-start), var(--p-hero-end)); }
.pp-native.hero b { color: #fff; }
.pp-native .pp-live { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.8; }
.pp-banner { display: flex; align-items: center; gap: 10px; border-radius: 14px; padding: 12px; }
.pp-banner .pp-circle { width: 34px; height: 34px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.pp-banner .pp-chev, .pp-row .pp-chev { margin-left: auto; opacity: 0.6; flex: none; }
.pp-title { font-weight: 600; }
.pp-sub { color: #666e86; font-size: 11.5px; }
.pp-h3 { font-size: 15px; font-weight: 700; }
.pp-h2 { font-size: 18px; font-weight: 700; }
.pp-secondary { color: #666e86; }
.pp-grid { display: grid; gap: 8px; }
.pp-tile { background: #fff; border: 1px solid #e4e7f0; border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 10.5px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.pp-tile span.pp-label { overflow-wrap: break-word; max-width: 100%; }
.pp-square { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex: none; }
.pp-group { background: #fff; border-radius: 14px; overflow: hidden; }
.pp-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid #eef0f6; }
.pp-row:first-child { border-top: none; }
.pp-row .pp-text { min-width: 0; }
.pp-price { margin-left: auto; font-weight: 700; flex: none; }
.pp-card { background: #fff; border: 1px solid #e4e7f0; border-radius: 14px; padding: 12px; display: flex; gap: 10px; }
.pp-emergency { background: #fbe6e6; color: #d64545; border-radius: 14px; padding: 12px; display: flex; gap: 10px; align-items: center; }
.pp-emergency .pp-sub { color: #666e86; }
.pp-image { border-radius: 14px; background: #e4e7f0; overflow: hidden; }
.pp-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pp-hidden-note { font-size: 11px; color: #9aa1b6; text-align: center; }
.pp-tone-primary { color: var(--p-primary); background: var(--p-tint); }
.pp-tone-teal { color: #1e9e96; background: #e1f5f3; }
.pp-tone-purple { color: #7a5af8; background: #ede7fe; }
.pp-tone-pink { color: #e0568c; background: #fce7ef; }
.pp-tone-grey { color: #6b7280; background: #eef0f4; }
.pp-tone-success { color: #1ea672; background: #e4f7ef; }
.pp-tone-warning { color: #e0a324; background: #fbf1dc; }
.pp-tone-emergency { color: #d64545; background: #fbe6e6; }

/* Narrower windows: the preview shrinks before the editor does. */
@media (max-width: 1240px) {
  .pc-layout { grid-template-columns: 220px minmax(0, 1fr) 316px; }
  .pc-phone { width: 272px; height: 560px; }
  .pc-footer { left: 220px; right: 316px; padding: 12px 16px; }
  .pc-problems { left: 232px; right: 328px; }
  .pc-editor { padding: 20px 16px 120px; }
}
@media (max-width: 1040px) {
  .pc-footer-actions .btn-secondary, .pc-footer-actions .btn-primary { padding: 8px 10px; }
  .pc-footer { flex-direction: column; align-items: stretch; gap: 8px; }
  .pc-footer-actions { justify-content: flex-end; }
}

/* --- Platform console: sign-in, app switcher, icon picker, staff and
   built-in screen editors ------------------------------------------------ */

/* The app's own icon font, served from this folder so the console needs no
   other origin (the production Content-Security-Policy allows none). */
@font-face {
  font-family: "TrityMed Icons";
  src: url("fonts/MaterialIcons-Regular.otf") format("opentype");
  font-display: block;
}
.pc-mi {
  font-family: "TrityMed Icons";
  font-style: normal; font-weight: normal; line-height: 1;
  display: inline-block; width: 1em; height: 1em; text-align: center;
  -webkit-font-smoothing: antialiased; flex: none;
}
img.pc-mi-img { width: 1em; height: 1em; object-fit: contain; flex: none; display: inline-block; vertical-align: middle; }
.pc-mi-dot { display: inline-block; width: 0.42em; height: 0.42em; margin: 0.29em; border-radius: 50%; background: currentColor; opacity: 0.55; flex: none; }

.pc-password { display: flex; gap: 8px; }
.pc-password input { flex: 1; min-width: 0; }
.pc-password button { flex: none; min-width: 64px; }
.pc-admin { font-size: 13px; font-weight: 600; color: var(--text); }

.pc-apps { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; margin: 0 0 18px; width: fit-content; max-width: 100%; flex-wrap: wrap; }
.pc-app-tab { background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; }
.pc-app-tab.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(20, 20, 43, 0.12); }
.pc-app-tab .pc-app-count { font-size: 11px; font-weight: 700; background: var(--pending-bg); color: var(--pending); border-radius: 999px; padding: 1px 7px; margin-left: 6px; }

.pc-icon-field { display: flex; align-items: center; gap: 8px; width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--text); text-align: left; min-height: 34px; }
.pc-icon-field:hover { border-color: var(--primary); }
.pc-icon-field .pc-icon-preview { font-size: 20px; color: var(--primary); display: flex; }
.pc-icon-field .pc-icon-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-icon-field .pc-icon-change { color: var(--muted); font-size: 12px; flex: none; }

.pc-icon-modal { width: min(640px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.pc-icon-modal .pc-input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.pc-icon-modal label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.pc-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-top: 12px; overflow-y: auto; max-height: 46vh; padding: 2px; }
.pc-icon-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; background: var(--bg); border-radius: 10px; color: var(--text); font-size: 11px; border: 2px solid transparent; }
.pc-icon-cell .pc-mi, .pc-icon-cell .pc-mi-dot { font-size: 26px; color: var(--text); }
.pc-icon-cell:hover { background: #e6e8f3; }
.pc-icon-cell.selected { border-color: var(--primary); background: #ecebfb; }
.pc-icon-cell:focus-visible, .pc-icon-field:focus-visible, .pc-icon-tab:focus-visible, .pc-app-tab:focus-visible, .pc-switch:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.pc-icon-empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; padding: 18px 4px; }
.pc-icon-thumb { display: flex; align-items: center; gap: 14px; margin: 12px 0; min-height: 64px; color: var(--muted); font-size: 13px; }
.pc-icon-thumb .pc-thumb-box { width: 64px; height: 64px; border-radius: 12px; background: var(--bg); display: flex; align-items: center; justify-content: center; flex: none; }
.pc-icon-thumb .pc-thumb-box.dark { background: #14172b; }
.pc-icon-thumb img { width: 36px; height: 36px; object-fit: contain; }
.pc-icon-tab.active { background: var(--primary); color: #fff; }

.pc-roles { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pc-role { background: var(--bg); color: var(--muted); padding: 7px 12px; border-radius: 8px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pc-role.active { background: var(--primary); color: #fff; }
.pc-role .pc-dot { background: var(--pending); }
.pc-role.active .pc-dot { background: #fff; }
.pc-stafftab { display: grid; grid-template-columns: 96px minmax(120px, 1.2fr) minmax(140px, 1fr) 210px; gap: 8px; align-items: end; padding: 10px 0; border-top: 1px solid var(--border); }
.pc-stafftab:first-of-type { border-top: none; }
.pc-stafftab.off .pc-field input, .pc-stafftab.off .pc-icon-field { opacity: 0.5; }
.pc-stafftab .pc-switch { align-self: center; }
.pc-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; border-radius: 8px; background: var(--bg); white-space: nowrap; }
.pc-switch input { width: 16px; height: 16px; }
.pc-switch.disabled { opacity: 0.6; }

.pc-native-group { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 22px 0 8px; }
.pc-native-group:first-child { margin-top: 0; }
.pc-text-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pc-text-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--border); }
.pc-text-table td { padding: 8px 8px 8px 0; vertical-align: middle; border-bottom: 1px solid var(--border); }
.pc-text-table tr:last-child td { border-bottom: none; }
.pc-text-table td.pc-builtin { color: var(--muted); }
.pc-text-table td.pc-desc { width: 26%; }
.pc-text-table td.pc-reset-cell { width: 1%; white-space: nowrap; padding-right: 0; }
.pc-text-table tr.changed td.pc-builtin { text-decoration: line-through; }
.pc-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin-top: 12px; }
.pc-part { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg); border-radius: 10px; font-size: 13px; }
.pc-part.off { color: var(--muted); text-decoration: line-through; }
.pc-part input { width: 16px; height: 16px; flex: none; }
.pc-subhead { font-size: 13px; font-weight: 700; margin: 16px 0 6px; }
.pc-panel.flash, .pc-stafftab.flash, .pc-text-table tr.flash td, .pc-part.flash { box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.35); }

/* Preview: real glyphs, the staff tab bar, and the built-in screen outline. */
.pp-tab .pp-glyph { font-size: 20px; display: flex; }
.pp-square .pc-mi, .pp-circle .pc-mi, .pp-emergency .pc-mi { font-size: 18px; }
.pp-square img.pc-mi-img, .pp-circle img.pc-mi-img { font-size: 18px; }
.pp-staff-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 24px; color: #666e86; font-size: 12.5px; }
.pp-staff-body b { color: #14172b; font-size: 15px; }
.pp-staff-body .pc-mi { font-size: 40px; color: var(--p-primary); }
.pp-outline { background: #fff; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pp-outline .pp-line { display: flex; flex-direction: column; gap: 1px; }
.pp-outline .pp-line small { color: #9aa1b6; font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.pp-outline .pp-line.changed span { color: var(--p-primary); font-weight: 700; }
.pp-outline .pp-part { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.pp-outline .pp-part.off { color: #9aa1b6; text-decoration: line-through; }
.pp-outline .pp-part i { width: 8px; height: 8px; border-radius: 50%; background: #1ea672; flex: none; }
.pp-outline .pp-part.off i { background: #d0d4e2; }

.pc-stafftab-actions { justify-content: flex-end; }
@media (max-width: 1180px) {
  .pc-stafftab { grid-template-columns: 80px 1fr 1fr; }
  .pc-stafftab .pc-stafftab-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

.pc-icon-modal { max-width: 640px; }

/* --- Platform console: organization, screen lists, built-in screen editor - */

.pc-rename { align-items: flex-end; max-width: 560px; margin-bottom: 0; }
.pc-rename .btn-primary { flex: none; }
.pc-rename-status { font-size: 13px; margin: 8px 0 0; min-height: 1em; }
.pc-rename-status.ok { color: var(--approved); font-weight: 600; }
.pc-rename-status.bad { color: var(--danger); font-weight: 600; }

.pc-screenlist { display: flex; flex-direction: column; gap: 4px; }
.pc-screen-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 10px 0 2px; }
.pc-screen-group:first-child { margin-top: 0; }
.pc-screen {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 10px; background: var(--bg); color: var(--text);
  font-size: 13px; font-weight: 500; border: 2px solid transparent;
}
button.pc-screen:hover:not(:disabled) { background: #e6e8f3; }
.pc-screen.selected { border-color: var(--primary); background: #ecebfb; }
.pc-screen.static { color: var(--muted); background: transparent; border: 1px dashed var(--border); }
.pc-screen.off .pc-screen-title, .pc-screen.off .pc-screen-tab { opacity: 0.55; }
.pc-screen.add { justify-content: center; color: var(--primary); font-weight: 600; background: transparent; border: 1px dashed var(--border); margin-top: 6px; }
.pc-screen-tab { flex: none; min-width: 92px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; color: var(--primary); background: #fff; border-radius: 6px; padding: 3px 8px; }
.pc-screen-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-screen-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pc-screen-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-screen-kind { font-size: 11px; color: var(--muted); flex: none; }
.pc-screen-subs { display: flex; flex-direction: column; gap: 1px; }
.pc-screen-note { font-size: 11.5px; color: var(--muted); }
.pc-screen-note.shared { color: #7a5af8; }
.pc-screen .pc-app-count { font-size: 11px; font-weight: 700; background: var(--pending-bg); color: var(--pending); border-radius: 999px; padding: 1px 7px; flex: none; }

.pc-screen-notes { margin: 0 0 6px; }
.pc-note { font-size: 12.5px; margin: 0 0 6px; color: var(--text); background: var(--bg); border-radius: 8px; padding: 7px 10px; }
.pc-note.shared { background: #ede7fe; color: #4b2fb8; }
.pc-note.muted { background: var(--pending-bg); color: var(--pending); }

.pc-partlist { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.pc-partrow { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg); border-radius: 10px; border: 2px solid transparent; }
.pc-partrow.movable { background: #fff; border-color: var(--border); }
.pc-partrow.off .pc-partrow-desc { color: var(--muted); text-decoration: line-through; }
.pc-partrow.dragging { opacity: 0.45; }
.pc-partrow.drop-target { border-color: var(--primary); border-style: dashed; }
.pc-partrow.movable[draggable="true"] { cursor: grab; }
.pc-grip { width: 14px; flex: none; color: var(--muted); font-size: 14px; text-align: center; }
.pc-partrow-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.pc-partrow-label input { width: 16px; height: 16px; flex: none; }
.pc-partrow-label > span { display: flex; flex-direction: column; min-width: 0; }
.pc-partrow-label code { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-fixed-note { font-size: 11px; color: var(--muted); flex: none; padding: 0 4px; }
.pc-blocks { margin-left: 22px; }
.pc-blocks .pc-section { border-color: #c9c2f5; background: #fbfaff; }
.pc-addblock { margin-left: 22px; display: flex; gap: 8px; align-items: center; }
.pc-addblock.open { background: var(--bg); padding: 8px; border-radius: 10px; }
.pc-addblock.open .pc-field { flex: 1; max-width: 280px; }
.pc-addblock-btn { background: transparent; color: var(--primary); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; border: 1px dashed transparent; }
.pc-addblock-btn:hover:not(:disabled) { border-color: var(--primary); }
.pc-addblock-btn:disabled { color: var(--muted); }
.pc-partrow.flash, .pc-addblock.flash, .pc-partlist.flash { box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.35); }

/* Preview of a built-in screen. */
.pp-placeholder { border: 1px dashed #b9c0d6; border-radius: 14px; padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: #14172b; }
.pp-placeholder small { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: #9aa1b6; }
.pp-added { position: relative; outline: 2px solid rgba(122, 90, 248, 0.35); outline-offset: 3px; border-radius: 12px; }

@media (max-width: 1240px) {
  .pc-screen-tab { min-width: 72px; }
  .pc-blocks, .pc-addblock { margin-left: 12px; }
}
