/*!
 * Cloud Console UI v2.0.0 (cloud-console.css)
 * Semantic HTML5 & ARIA Component Library inspired by Google Cloud BigQuery & Bigtable
 * Zero framework dependencies. Designed for standalone static deployment.
 */

/* 1. Design tokens */
:root,
[data-theme="light"] {
  --cc-topbar-bg: #1a73e8;
  --cc-topbar-input-bg: rgba(255, 255, 255, 0.16);
  --cc-topbar-input-focus: #ffffff;
  --cc-primary: #3367d6;
  --cc-primary-hover: #2855b8;
  --cc-primary-active: #1c3aa9;
  --cc-primary-tint: #e8f0fe;
  --cc-primary-focus: rgba(26, 115, 232, 0.24);
  --cc-link: #1a73e8;

  --cc-bg: #ffffff;
  --cc-bg-subtle: #f8f9fa;
  --cc-bg-muted: #f1f3f4;
  --cc-bg-tabstrip: #ebebeb;
  --cc-bg-thead: #f5f5f5;
  --cc-bg-hover: #f5f7fa;

  --cc-border: #e0e0e0;
  --cc-border-strong: #dadce0;
  --cc-border-grid: #ebebeb;

  --cc-text: #202124;
  --cc-text-secondary: #5f6368;
  --cc-text-muted: #757575;
  --cc-text-inverse: #ffffff;

  --cc-success: #1e8e3e;
  --cc-success-bg: #e6f4ea;
  --cc-warning: #e37400;
  --cc-warning-bg: #fef7e0;
  --cc-danger: #d93025;
  --cc-danger-bg: #fce8e6;
  --cc-info: #1a73e8;
  --cc-info-bg: #e8f0fe;

  --cc-syntax-kw: #7b1fa2;
  --cc-syntax-id: #0277bd;
  --cc-syntax-str: #188038;
  --cc-syntax-num: #c5221f;

  --cc-radius: 3px;
  --cc-radius-md: 4px;
  --cc-shadow-xs: 0 1px 2px rgba(60, 64, 67, 0.12);
  --cc-shadow-sm: 0 1px 3px rgba(60, 64, 67, 0.18);
  --cc-shadow-md: 0 3px 8px rgba(60, 64, 67, 0.22);
  --cc-shadow-lg: 0 8px 24px rgba(32, 33, 36, 0.28);
  --cc-transition: 140ms cubic-bezier(0.4, 0, 0.2, 1);

  --cc-font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --cc-font-mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --cc-topbar-bg: #202124;
  --cc-topbar-input-bg: rgba(255, 255, 255, 0.09);
  --cc-topbar-input-focus: #303134;
  --cc-primary: #8ab4f8;
  --cc-primary-hover: #aecbfa;
  --cc-primary-active: #669df6;
  --cc-primary-tint: rgba(138, 180, 248, 0.16);
  --cc-primary-focus: rgba(138, 180, 248, 0.28);
  --cc-link: #8ab4f8;

  --cc-bg: #202124;
  --cc-bg-subtle: #28292c;
  --cc-bg-muted: #303134;
  --cc-bg-tabstrip: #17181b;
  --cc-bg-thead: #292a2d;
  --cc-bg-hover: #2c2e33;

  --cc-border: #3c4043;
  --cc-border-strong: #5f6368;
  --cc-border-grid: #323639;

  --cc-text: #e8eaed;
  --cc-text-secondary: #9aa0a6;
  --cc-text-muted: #80868b;
  --cc-text-inverse: #202124;

  --cc-success: #81c995;
  --cc-success-bg: rgba(129, 201, 149, 0.16);
  --cc-warning: #fdd663;
  --cc-warning-bg: rgba(253, 214, 99, 0.16);
  --cc-danger: #f28b82;
  --cc-danger-bg: rgba(242, 139, 130, 0.16);
  --cc-info: #8ab4f8;
  --cc-info-bg: rgba(138, 180, 248, 0.16);

  --cc-syntax-kw: #d7aefb;
  --cc-syntax-id: #8ab4f8;
  --cc-syntax-str: #81c995;
  --cc-syntax-num: #f28b82;
}

/* 2. Base typography */
*, ::before, ::after { box-sizing: border-box; }

/* hidden must win over component and inline display values */
[hidden] { display: none !important; }

html {
  font: 13px/1.5 var(--cc-font-sans);
  color: var(--cc-text);
  background: var(--cc-bg);
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; background: var(--cc-bg); color: var(--cc-text); }

h1, h2, h3, h4, h5, h6 { margin: 0 0 0.5rem; font-weight: 500; color: var(--cc-text); line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 18px; font-weight: 400; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
h5 { font-size: 12px; color: var(--cc-text-secondary); }
h6 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--cc-text-muted); }

p { margin: 0 0 0.75rem; max-width: 78ch; }
small { font-size: 12px; color: var(--cc-text-secondary); }
a {
  color: var(--cc-link);
  text-decoration: none;
  cursor: pointer;
  &:hover { text-decoration: underline; }
}
hr { border: 0; border-top: 1px solid var(--cc-border); margin: 1rem 0; }
blockquote {
  margin: 0 0 1rem;
  padding: 8px 14px;
  border-left: 3px solid var(--cc-link);
  background: var(--cc-bg-subtle);
  color: var(--cc-text-secondary);
}

/* Description lists (table details, instance metadata) */
dl {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  margin: 0 0 1rem;
  border-top: 1px solid var(--cc-border);
}
dt, dd { margin: 0; padding: 8px 12px; border-bottom: 1px solid var(--cc-border-grid); font-size: 12.5px; }
dt { font-weight: 500; color: var(--cc-text-secondary); background: var(--cc-bg-subtle); }

code, kbd, pre, samp { font-family: var(--cc-font-mono); font-size: 12px; }
code { padding: 1px 5px; background: var(--cc-bg-muted); border-radius: var(--cc-radius); }
kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--cc-text-secondary);
  background: var(--cc-bg-subtle);
  border: 1px solid var(--cc-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--cc-radius);
}
pre {
  margin: 0 0 1rem;
  padding: 12px 14px;
  background: var(--cc-bg-subtle);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-md);
  overflow-x: auto;
}
pre code { padding: 0; background: transparent; }

.material-icons, .material-icons-outlined { font-size: 18px; line-height: 1; vertical-align: middle; user-select: none; }

summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }

:is(nav[data-drawer], nav[aria-label="Breadcrumb"], nav[data-rail]) ul,
ul[data-tiles] { list-style: none; margin: 0; padding: 0; }

/* 3. Buttons */
button, [type="button"], [type="submit"], [type="reset"], [role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--cc-radius);
  border: 1px solid transparent;
  background-color: var(--cc-primary);
  color: var(--cc-text-inverse);
  box-shadow: var(--cc-shadow-xs);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: var(--cc-transition);
  transition-property: background-color, border-color, box-shadow;
}
button:hover:not(:disabled),
[type="button"]:hover:not(:disabled),
[type="submit"]:hover:not(:disabled),
[role="button"]:hover:not([aria-disabled="true"]) { background-color: var(--cc-primary-hover); text-decoration: none; }
button:focus-visible,
[role="button"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--cc-primary-focus); }
button:disabled,
[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* Outlined secondary ("Save query", pagination) */
button.secondary, [type="reset"], [role="button"].secondary {
  background-color: var(--cc-bg);
  color: var(--cc-text);
  border-color: var(--cc-border-strong);
  font-weight: 400;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
button.secondary:hover:not(:disabled),
[type="reset"]:hover:not(:disabled) { background-color: var(--cc-bg-subtle); }

/* Flat uppercase action ("+ CREATE TABLE") and raised action ("+ CREATE A VM") */
button.ghost, button.action, [role="button"].ghost,
button.raised, [role="button"].raised { text-transform: uppercase; font-size: 12px; letter-spacing: 0.35px; }
button.ghost, button.action, [role="button"].ghost {
  background-color: transparent;
  color: var(--cc-link);
  border-color: transparent;
  box-shadow: none;
  padding: 0 8px;
}
button.ghost:hover:not(:disabled),
button.action:hover:not(:disabled),
[role="button"].ghost:hover:not([aria-disabled="true"]) { background-color: var(--cc-primary-tint); }
button.raised, [role="button"].raised {
  background-color: var(--cc-bg);
  color: var(--cc-link);
  border-color: var(--cc-border);
  box-shadow: var(--cc-shadow-sm);
}
button.raised:hover:not(:disabled),
[role="button"].raised:hover:not([aria-disabled="true"]) { background-color: var(--cc-bg-subtle); box-shadow: var(--cc-shadow-md); }

button.danger {
  background-color: var(--cc-danger);
  color: #ffffff;
  &:hover:not(:disabled) { filter: brightness(0.92); }
}

button.icon, [role="button"].icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cc-text-secondary);
  box-shadow: none;
}
button.icon:hover:not(:disabled) { background-color: var(--cc-bg-muted); color: var(--cc-text); }

/* Split button ("Run | v") */
[role="group"][data-split] {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow-xs);
  overflow: hidden;
  & > button { border-radius: 0; box-shadow: none; }
  & > button + button { padding: 0 5px; border-left: 1px solid rgba(255, 255, 255, 0.28); }
}

[aria-busy="true"] {
  position: relative;
  pointer-events: none;
  &::before {
    content: "";
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 6px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: cc-spin 0.65s linear infinite;
  }
}
@keyframes cc-spin { to { transform: rotate(360deg); } }

/* 4. Forms & search bars */
label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 500; color: var(--cc-text-secondary); }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
select,
textarea {
  display: block;
  width: 100%;
  height: 30px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--cc-text);
  background-color: var(--cc-bg);
  border: 1px solid var(--cc-border-strong);
  border-radius: var(--cc-radius);
  transition: var(--cc-transition);
  transition-property: border-color, box-shadow;
}
textarea { height: auto; min-height: 74px; padding: 8px 10px; resize: vertical; }

:is(input, select, textarea) {
  &:focus { outline: none; border-color: var(--cc-link); box-shadow: 0 0 0 2px var(--cc-primary-focus); }
  &[aria-invalid="true"] { border-color: var(--cc-danger); }
  &[aria-invalid="false"] { border-color: var(--cc-success); }
  /* helper text: <small> after a field, linked via aria-describedby */
  & + small { display: block; margin-top: 4px; }
}
[aria-invalid="true"] + small { color: var(--cc-danger); }
[aria-invalid="false"] + small { color: var(--cc-success); }
:is(input, select, textarea):disabled { background-color: var(--cc-bg-muted); color: var(--cc-text-muted); cursor: not-allowed; }

fieldset { margin: 0 0 1rem; padding: 12px 14px; border: 1px solid var(--cc-border); border-radius: var(--cc-radius-md); }
legend { padding: 0 6px; font-size: 12px; font-weight: 500; color: var(--cc-text-secondary); }

input:is([type="checkbox"], [type="radio"]) {
  width: 15px;
  height: 15px;
  margin: 0 6px 0 0;
  accent-color: var(--cc-primary);
  vertical-align: middle;
  cursor: pointer;
}
input[type="checkbox"][role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 18px;
  background: var(--cc-border-strong);
  border-radius: 999px;
  position: relative;
  transition: background-color var(--cc-transition);
  &::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform var(--cc-transition);
  }
  &:checked { background: var(--cc-primary); }
  &:checked::after { transform: translateX(14px); }
}

input[type="range"] {
  display: block;
  width: 100%;
  margin: 6px 0;
  accent-color: var(--cc-primary);
  cursor: pointer;
  &:focus { box-shadow: none; }
  &:focus-visible { outline: 2px solid var(--cc-link); outline-offset: 2px; }
}

/* <output for="slider-id">, kept in sync by cloud-console.js */
output { font-weight: 500; color: var(--cc-text); font-variant-numeric: tabular-nums; }

input[type="file"] {
  padding: 3px 10px 3px 3px;
  color: var(--cc-text-secondary);
  cursor: pointer;
  &::file-selector-button {
    height: 22px;
    margin-right: 10px;
    padding: 0 10px;
    font-family: inherit;
    font-size: 12px;
    color: var(--cc-text);
    background: var(--cc-bg);
    border: 1px solid var(--cc-border-strong);
    border-radius: var(--cc-radius);
    cursor: pointer;
    transition: background-color var(--cc-transition);
  }
  &:hover:not(:disabled)::file-selector-button { background: var(--cc-bg-subtle); }
}

[role="search"] {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 8px;
  background: var(--cc-bg);
  border: 1px solid var(--cc-border-strong);
  border-radius: var(--cc-radius-md);
  &:focus-within { border-color: var(--cc-link); box-shadow: 0 0 0 2px var(--cc-primary-focus); }
  & input {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 2px;
    height: 100%;
  }
}

/* Bigtable filter bar ("Filter | Filter tables ...") */
[role="search"][data-filter-bar] {
  height: 40px;
  border: none;
  border-top: 1px solid var(--cc-border);
  border-bottom: 1px solid var(--cc-border);
  border-radius: 0;
  padding: 0 14px;
  box-shadow: none !important;
  gap: 10px;
  & .filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: var(--cc-text);
    white-space: nowrap;
  }
}

/* 5. Topbar & product subheader */
header[data-topbar] {
  height: 48px;
  background-color: var(--cc-topbar-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 60;

  & .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: -0.2px;
    white-space: nowrap;
    color: inherit;
  }
  & a.brand:hover { text-decoration: none; }
}

/* Navigation drawer (<nav popover data-drawer>, opened by <button popovertarget>; native light dismiss) */
nav[data-drawer] {
  inset: 48px auto 0 0;
  width: 280px;
  height: auto;
  max-height: none;
  margin: 0;
  padding: 8px 0;
  border: none;
  border-right: 1px solid var(--cc-border);
  background: var(--cc-bg);
  color: var(--cc-text);
  box-shadow: var(--cc-shadow-lg);
  overflow-y: auto;
  &::backdrop { background: transparent; }
  & h6 { margin: 12px 24px 4px; }
  & hr { margin: 8px 0; }
  & a {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 40px;
    margin-right: 8px;
    padding: 0 24px;
    border-radius: 0 20px 20px 0;
    color: var(--cc-text);
    font-size: 13px;
    &:hover { background: var(--cc-bg-hover); text-decoration: none; }
    &:focus-visible { outline: 2px solid var(--cc-link); outline-offset: -2px; }
    &[aria-current="page"] { background: var(--cc-primary-tint); color: var(--cc-link); font-weight: 500; }
  }
  & a > :is(.material-icons, .material-icons-outlined) { font-size: 20px; color: var(--cc-text-secondary); }
  & a[aria-current="page"] > :is(.material-icons, .material-icons-outlined) { color: var(--cc-link); }
}

header[data-topbar] {
  & :is(button.icon, button.ghost) { color: #ffffff; }
  & :is(button.icon, button.ghost):hover { background: rgba(255, 255, 255, 0.14); }

  & [role="search"] {
    flex: 0 1 540px;
    height: 34px;
    background: var(--cc-topbar-input-bg);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--cc-radius-md);
    color: #ffffff;
    padding: 0 10px;
    transition: var(--cc-transition);
    transition-property: background-color, color;
    & input { color: inherit; }
    & input::placeholder { color: rgba(255, 255, 255, 0.82); }
    &:focus-within { background: var(--cc-topbar-input-focus); color: var(--cc-text); border-color: transparent; box-shadow: var(--cc-shadow-sm); }
    &:focus-within input::placeholder { color: var(--cc-text-muted); }
  }
}

[data-notification-badge] {
  position: relative;
  &::after {
    content: attr(data-notification-badge);
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    background: #00bfa5;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

[data-avatar] {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  background: #fbbc04;
  color: #202124;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

/* Product subheader: title + breadcrumb + global actions */
header[data-subheader] {
  min-height: 48px;
  background: var(--cc-bg);
  border-bottom: 1px solid var(--cc-border);
  display: flex;
  align-items: stretch;
  & .product-title {
    width: 256px;
    min-width: 256px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    color: var(--cc-text);
    border-right: 1px solid var(--cc-border);
  }
  & .subheader-bar {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
    flex-wrap: wrap;
  }
}

/* Breadcrumb ("All instances > INSTANCE / prod-hbase-database") */
nav[aria-label="Breadcrumb"] {
  & ul { display: flex; align-items: center; gap: 8px; }
  & li + li::before { content: "›"; margin-right: 8px; font-size: 16px; color: var(--cc-text-secondary); }
}
.breadcrumb-stack {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.18;
  vertical-align: middle;
  & small { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; color: var(--cc-text-secondary); }
}

/* 6. Shell: activity rail, sidebar, workspace, info panel */
.cc-shell { display: flex; min-height: calc(100vh - 96px); position: relative; }

:is(nav[data-rail], details[data-nav-group]) :is(a, button),
details[role="list"] > ul :is(a, button) { border: none; border-radius: 0; background: transparent; box-shadow: none; }

nav[data-rail] {
  width: 48px;
  min-width: 48px;
  background: var(--cc-bg);
  border-right: 1px solid var(--cc-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 0;
  & ul { display: flex; flex-direction: column; align-items: center; gap: 2px; }
  & :is(button, a) { width: 48px; height: 40px; color: var(--cc-text-secondary); }
  & :is(button, a):hover { background: var(--cc-bg-subtle); color: var(--cc-text); text-decoration: none; }
  & :is([aria-current="true"], [aria-current="page"]) { background: var(--cc-primary-tint); color: var(--cc-link); }
}

aside[data-sidebar] {
  width: 256px;
  min-width: 256px;
  background: var(--cc-bg);
  border-right: 1px solid var(--cc-border);
  display: flex;
  flex-direction: column;
  user-select: none;
}

:is(details[data-nav-group], details[data-tree]) > summary { display: flex; align-items: center; }
details[data-nav-group] > summary::after,
details[data-tree] > summary::before {
  font-family: 'Material Icons';
  font-size: 18px;
  color: var(--cc-text-secondary);
  transition: transform var(--cc-transition);
}

/* Collapsible sidebar sections ("Instance ^", "Insights ^") */
details[data-nav-group] {
  border: none;
  border-bottom: 1px solid var(--cc-border-grid);
  border-radius: 0;
  margin: 0;
  background: transparent;
  & > summary {
    padding: 12px 16px 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cc-text);
    justify-content: space-between;
    &::after { content: "expand_less"; }
  }
  &:not([open]) > summary::after { transform: rotate(180deg); }
  & > ul { list-style: none; margin: 0; padding: 0 0 8px 0; }
  & :is(a, button) {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    width: 100%;
    height: 38px;
    padding: 0 16px;
    color: var(--cc-text);
    font-weight: 400;
    font-size: 13px;
  }
  & :is(a, button):hover { background: var(--cc-bg-subtle); text-decoration: none; }
  & :is([aria-current="page"], [aria-current="true"]) { background: var(--cc-primary-tint); color: var(--cc-link); font-weight: 500; }
}

/* Explorer resource tree (projects > datasets > tables) */
details[data-tree] {
  border: none;
  margin: 0;
  background: transparent;
  & > summary {
    padding: 5px 10px;
    font-weight: 400;
    font-size: 12.5px;
    gap: 6px;
    &::before { content: "arrow_right"; }
  }
  &[open] > summary::before { transform: rotate(90deg); }
}
details[data-tree] > summary:hover,
.tree-leaf:hover { background: var(--cc-bg-subtle); }
.tree-leaf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 12px 5px 38px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--cc-text);
  &[aria-selected="true"] { background: var(--cc-primary-tint); color: var(--cc-link); font-weight: 500; }
}
.pin-btn { margin-left: auto; color: var(--cc-link); opacity: 0.85; font-size: 15px !important; }

main[data-workspace] { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--cc-bg); }

aside[data-info-panel] {
  width: 310px;
  min-width: 310px;
  border-left: 1px solid var(--cc-border);
  background: var(--cc-bg);
  display: flex;
  flex-direction: column;
  transition: margin-right var(--cc-transition);
}

/* 7. Tabs */
[data-workspace-tabbar] {
  display: flex;
  align-items: stretch;
  height: 38px;
  background: var(--cc-bg-tabstrip);
  border-bottom: 1px solid var(--cc-border);
  user-select: none;
  & .tab-scroll-list { display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; }
}
/* <div class="ws-tab" role="none"><button role="tab">…</button><button class="close-tab">…</button></div>
   The close button sits beside the tab because a tab may not contain a button. */
[data-workspace-tabbar] .ws-tab {
  display: inline-flex;
  align-items: center;
  min-width: 145px;
  max-width: 210px;
  padding-right: 8px;
  background: transparent;
  border-right: 1px solid var(--cc-border);
  border-bottom: 2px solid transparent;
  &:hover { background: rgba(0, 0, 0, 0.03); }
  &:has(> [aria-selected="true"]) { background: var(--cc-bg); border-bottom-color: var(--cc-link); }
  & > [role="tab"] {
    flex: 1;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    height: 100%;
    padding: 0 4px 0 12px;
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: none;
    &:hover { background: transparent; }
    &:focus-visible { box-shadow: inset 0 0 0 2px var(--cc-primary-focus); }
    & > span:last-child { overflow: hidden; text-overflow: ellipsis; }
  }
  & .close-tab {
    flex: none;
    width: 22px;
    height: 22px;
    padding: 0;
    color: var(--cc-text-secondary);
    background: transparent;
    border: none;
    border-radius: 50%;
    box-shadow: none;
    &:hover { background: var(--cc-bg-muted); color: var(--cc-text); }
  }
}

/* Underline section tabs ("Schema | Details | Preview") */
[role="tablist"] {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 16px;
  border-bottom: 1px solid var(--cc-border);
  background: var(--cc-bg);
}
[role="tab"] {
  height: 36px;
  padding: 0 2px;
  background: transparent;
  color: var(--cc-text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  box-shadow: none;
  font-size: 12.5px;
  font-weight: 500;
  &:hover:not(:disabled) { background: transparent; color: var(--cc-text); }
  &[aria-selected="true"] { color: var(--cc-link); border-bottom-color: var(--cc-link); }
}

/* 8. Data tables & pagination */
.table-wrap { width: 100%; overflow-x: auto; background: var(--cc-bg); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; text-align: left; background: var(--cc-bg); }
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--cc-bg-thead);
  color: var(--cc-text);
  font-weight: 500;
  padding: 8px 12px;
  border-bottom: 1px solid var(--cc-border);
  border-right: 1px solid var(--cc-border-grid);
  white-space: nowrap;
}
thead th:last-child,
tbody td:last-child { border-right: none; }

/* Bigtable clean grid: no vertical gridlines */
table[data-grid="clean"] :is(thead th, tbody td) { border-right: none; padding: 9px 14px; }

tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--cc-border-grid);
  border-right: 1px solid var(--cc-border-grid);
  color: var(--cc-text);
  white-space: nowrap;
}
tbody tr:hover { background: var(--cc-bg-hover); }
tbody tr[aria-selected="true"] { background: var(--cc-primary-tint); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

th[data-sort] {
  cursor: pointer;
  user-select: none;
  &:hover { background: var(--cc-bg-muted); }
}
th[aria-sort="ascending"]::after,
th[aria-sort="descending"]::after { content: " ↑"; font-weight: 700; color: var(--cc-text); }
th[aria-sort="descending"]::after { content: " ↓"; }

.cc-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 6px 16px;
  border-top: 1px solid var(--cc-border);
  background: var(--cc-bg);
  font-size: 12px;
  color: var(--cc-text-secondary);
  flex-wrap: wrap;
  & select { width: auto; height: 26px; padding: 0 22px 0 8px; font-size: 12px; }
  & button.secondary { height: 26px; padding: 0 8px; font-size: 12px; }
}

/* 9. SQL editor, split resizer & bottom drawer */
.cc-sql-editor {
  display: grid;
  grid-template-columns: 40px 1fr;
  border-top: 1px solid var(--cc-border);
  border-bottom: 1px solid var(--cc-border);
  background: var(--cc-bg);
  min-height: 128px;
  font-family: var(--cc-font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}
.cc-sql-gutter {
  background: var(--cc-bg-subtle);
  border-right: 1px solid var(--cc-border);
  color: var(--cc-text-muted);
  padding: 10px 6px;
  text-align: right;
  user-select: none;
}
.cc-sql-input {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 10px 12px !important;
  font-family: var(--cc-font-mono) !important;
  font-size: 12.5px !important;
  line-height: 1.55 !important;
  resize: none !important;
  min-height: 128px !important;
}

.cc-split-divider {
  height: 8px;
  background: var(--cc-bg-subtle);
  border-top: 1px solid var(--cc-border);
  border-bottom: 1px solid var(--cc-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: row-resize;
  &::after {
    content: "";
    width: 28px;
    height: 3px;
    border-top: 1px solid var(--cc-border-strong);
    border-bottom: 1px solid var(--cc-border-strong);
  }
}

.cc-bottom-drawer { margin-top: auto; border-top: 1px solid var(--cc-border); background: var(--cc-bg-tabstrip); }
.cc-bottom-drawer-bar { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 12px 0 0; }

/* 10. Dropdowns, accordions, chips, alerts, gauges, modals & tooltips */
details[role="list"] {
  position: relative;
  display: inline-block;
  border: none;
  margin: 0;
  background: transparent;
  & > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    font-size: 12.5px;
    font-weight: 400;
    background: var(--cc-bg);
    color: var(--cc-text);
    border: 1px solid var(--cc-border-strong);
    border-radius: var(--cc-radius);
    &::after { content: "▾"; font-size: 11px; opacity: 0.75; }
  }
  &[data-ghost] > summary {
    background: transparent;
    border-color: transparent;
    color: var(--cc-link);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 12px;
    &:hover { background: var(--cc-primary-tint); }
  }
}
header[data-topbar] details[role="list"] > summary {
  background: transparent;
  border-color: transparent;
  color: #ffffff;
  font-weight: 500;
  &:hover { background: rgba(255, 255, 255, 0.14); }
}
details[role="list"] > ul {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 80;
  min-width: 190px;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--cc-bg);
  border: 1px solid var(--cc-border-strong);
  border-radius: var(--cc-radius-md);
  box-shadow: var(--cc-shadow-md);
  & li[role="separator"] { height: 1px; margin: 4px 0; background: var(--cc-border); }
  & :is(button, a) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 30px;
    padding: 0 14px;
    color: var(--cc-text);
    font-weight: 400;
    font-size: 12.5px;
  }
  & :is(button, a):is(:hover, :focus-visible) { background: var(--cc-bg-muted); text-decoration: none; outline: none; box-shadow: none; }
}
details[role="list"][data-align="right"] > ul { left: auto; right: 0; }

/* Accordion: plain <details>; share a name="" for exclusive groups */
details:not([role], [data-nav-group], [data-tree]) {
  margin: 0;
  padding: 0 12px;
  border-top: 1px solid var(--cc-border);
  border-bottom: 1px solid var(--cc-border);
  & + & { border-top: none; }
  &[open] { padding-bottom: 12px; }
  & > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 40px;
    margin: 0 -12px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cc-text);
    transition: background-color var(--cc-transition);
    &::after {
      content: "";
      flex: none;
      width: 6px;
      height: 6px;
      margin: 0 4px 3px 0;
      border-right: 2px solid var(--cc-text-secondary);
      border-bottom: 2px solid var(--cc-text-secondary);
      transform: rotate(45deg);
      transition: transform var(--cc-transition);
    }
    &:hover { background: var(--cc-bg-hover); }
    &:focus-visible { outline: 2px solid var(--cc-link); outline-offset: -2px; }
  }
  &[open] > summary {
    margin-bottom: 8px;
    &::after { margin-bottom: 0; margin-top: 3px; transform: rotate(-135deg); }
  }
}

/* Pills, chips & status ("Processing location: US", "✓ Ready") */
[data-pill], .cc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--cc-bg-muted);
  color: var(--cc-text-secondary);
  font-size: 11.5px;
  font-weight: 500;
}
[data-badge="success"] { background: var(--cc-success-bg); color: var(--cc-success); }
[data-badge="warning"] { background: var(--cc-warning-bg); color: var(--cc-warning); }
[data-badge="danger"]  { background: var(--cc-danger-bg); color: var(--cc-danger); }
[data-badge="info"]    { background: var(--cc-info-bg); color: var(--cc-info); }

.cc-status-ready, .cc-status-stopped {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--cc-text);
  &::before { content: "check_circle"; font-family: 'Material Icons'; font-size: 16px; color: var(--cc-success); }
}
.cc-status-stopped::before { content: "stop_circle"; color: var(--cc-text-muted); }

/* Quick access tiles: <ul data-tiles><li><a><small>Project</small><strong>Product › Page</strong></a></li></ul> */
ul[data-tiles] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  & a {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    padding: 12px 14px;
    color: var(--cc-text);
    background: var(--cc-bg);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius-md);
    box-shadow: var(--cc-shadow-xs);
    transition: box-shadow var(--cc-transition);
    &:hover { box-shadow: var(--cc-shadow-md); text-decoration: none; }
    &:focus-visible { outline: 2px solid var(--cc-link); outline-offset: 2px; }
  }
  & small { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--cc-border); }
  & strong { display: flex; align-items: center; gap: 8px; font-weight: 500; }
}

article {
  background: var(--cc-bg);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-md);
  padding: 16px;
  margin-bottom: 16px;
  & > header {
    margin: -16px -16px 14px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--cc-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  & > footer, & > form > footer {
    margin: 14px -16px -16px;
    padding: 10px 16px;
    border-top: 1px solid var(--cc-border);
    background: var(--cc-bg-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }
}

[role="alert"] {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--cc-radius);
  border-left: 3px solid var(--cc-info);
  background: var(--cc-info-bg);
  color: var(--cc-text);
  margin-bottom: 12px;
  font-size: 12.5px;
  &[data-variant="success"] { border-left-color: var(--cc-success); background: var(--cc-success-bg); }
  &[data-variant="warning"] { border-left-color: var(--cc-warning); background: var(--cc-warning-bg); }
  &[data-variant="danger"]  { border-left-color: var(--cc-danger);  background: var(--cc-danger-bg); }
}

progress {
  width: 100%;
  height: 4px;
  appearance: none;
  border: none;
  background: var(--cc-primary-tint);
  border-radius: 2px;
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--cc-primary-tint); }
progress::-webkit-progress-value { background: var(--cc-primary); }

/* Quota gauge (<meter low high optimum>): blue, amber, red */
meter {
  display: block;
  width: 100%;
  height: 8px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: var(--cc-bg-muted);
  border-radius: 4px;
  overflow: hidden;
}
meter::-webkit-meter-bar { height: 8px; background: var(--cc-bg-muted); border: none; border-radius: 4px; }
meter::-webkit-meter-optimum-value { background: var(--cc-primary); }
meter::-webkit-meter-suboptimum-value { background: var(--cc-warning); }
meter::-webkit-meter-even-less-good-value { background: var(--cc-danger); }
meter::-moz-meter-bar { background: var(--cc-primary); }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--cc-warning); }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--cc-danger); }

dialog {
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-md);
  padding: 0;
  max-width: 480px;
  width: 92%;
  background: var(--cc-bg);
  color: var(--cc-text);
  box-shadow: var(--cc-shadow-lg);
  &::backdrop { background: rgba(32, 33, 36, 0.48); }
  & > article { margin: 0; border: none; }
}

/* Tooltip ([data-tooltip="..."]); non-interactive hosts need tabindex="0" */
[data-tooltip] {
  position: relative;
  &:is(:hover, :focus-visible)::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    border-radius: var(--cc-radius);
    background: #3c4043;
    color: #ffffff;
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    white-space: nowrap;
    pointer-events: none;
    z-index: 95;
    box-shadow: var(--cc-shadow-sm);
  }
}

.cc-toast-stack { position: fixed; bottom: 18px; right: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.cc-toast {
  background: #323232;
  color: #ffffff;
  padding: 9px 14px;
  border-radius: var(--cc-radius-md);
  font-size: 12.5px;
  box-shadow: var(--cc-shadow-md);
  animation: cc-toast-in 160ms ease-out;
}
@keyframes cc-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

@media (max-width: 900px) {
  header[data-subheader] .product-title { width: auto; min-width: 0; border-right: none; }
  .cc-shell { flex-direction: column; }
  nav[data-rail] { width: 100%; flex-direction: row; height: 42px; border-right: none; border-bottom: 1px solid var(--cc-border); }
  nav[data-rail] ul { flex-direction: row; }
  aside[data-sidebar], aside[data-info-panel] { width: 100%; min-width: 0; border-right: none; border-left: none; border-bottom: 1px solid var(--cc-border); }
}
