/* ------------------------------------------------------------------ tokens */
:root {
  --g-blue: #1a73e8;
  --g-blue-dark: #174ea6;
  --g-blue-tint: #e8f0fe;
  --g-red: #d93025;
  --g-red-tint: #fce8e6;
  --g-yellow: #f9ab00;
  --g-yellow-tint: #fef7e0;
  --g-green: #188038;
  --g-green-tint: #e6f4ea;
  --ink: #202124;
  --ink-2: #5f6368;
  --ink-3: #80868b;
  --line: #dadce0;
  --line-soft: #e8eaed;
  --bg: #f8f9fa;
  --surface: #fff;
  --hover: rgba(60, 64, 67, .08);
  --focus: rgba(26, 115, 232, .35);
  --shadow-1: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --shadow-2: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --r: 8px;
  --r-sm: 4px;
  --font: "Google Sans", Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --topbar: 64px;
  --sidenav: 256px;
}

* { box-sizing: border-box; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}
h1, h2, h3 { font-weight: 400; margin: 0; }
p { margin: 0; }
a { color: var(--g-blue); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--line-soft); padding: 1px 5px; border-radius: 3px; }
code.block { display: block; padding: 10px 12px; margin-top: 6px; white-space: pre-wrap; word-break: break-all; }
.muted { color: var(--ink-2); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--g-blue); outline-offset: 2px; }

/* ------------------------------------------------------------ google mark */
.g-mark {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 44px;
  height: 44px;
  padding: 4px;
}
.g-mark span { border-radius: 3px; }
.g-mark span:nth-child(1) { background: #4285f4; border-top-left-radius: 12px; }
.g-mark span:nth-child(2) { background: #ea4335; border-top-right-radius: 12px; }
.g-mark span:nth-child(3) { background: #fbbc04; border-bottom-left-radius: 12px; }
.g-mark span:nth-child(4) { background: #34a853; border-bottom-right-radius: 12px; }
.g-mark-sm { width: 30px; height: 30px; gap: 2px; padding: 2px; }
.g-mark-sm span:nth-child(1) { border-top-left-radius: 8px; }
.g-mark-sm span:nth-child(2) { border-top-right-radius: 8px; }
.g-mark-sm span:nth-child(3) { border-bottom-left-radius: 8px; }
.g-mark-sm span:nth-child(4) { border-bottom-right-radius: 8px; }

/* ----------------------------------------------------------------- buttons */
.btn {
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: .25px;
  border-radius: var(--r-sm);
  padding: 0 24px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s, box-shadow .12s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--g-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--g-blue-dark); box-shadow: var(--shadow-1); }
.btn-outline { background: var(--surface); color: var(--g-blue); border-color: var(--line); }
.btn-outline:hover:not(:disabled) { background: var(--g-blue-tint); }
.btn-text { background: transparent; color: var(--g-blue); padding: 0 12px; }
.btn-text:hover:not(:disabled) { background: var(--g-blue-tint); }
.btn-danger { background: var(--g-red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b3261e; }
.btn-danger-outline { background: var(--surface); color: var(--g-red); border-color: var(--line); }
.btn-danger-outline:hover:not(:disabled) { background: var(--g-red-tint); }
.btn-sm { height: 30px; padding: 0 14px; font-size: 13px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }

/* ------------------------------------------------------------------ fields */
.field {
  position: relative;
  display: block;
}
.field > input, .field > textarea, .field > select {
  font: inherit;
  font-size: 15px;
  width: 100%;
  height: 52px;
  padding: 14px 14px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.field > textarea { height: auto; min-height: 84px; padding-top: 20px; resize: vertical; font-family: var(--mono); font-size: 13px; }
.field > input:hover, .field > textarea:hover { border-color: var(--ink-2); }
.field > input:focus, .field > textarea:focus { outline: 0; border-color: var(--g-blue); box-shadow: 0 0 0 1px var(--g-blue); }
.field > span {
  position: absolute; left: 14px; top: 16px;
  color: var(--ink-2); font-size: 15px; pointer-events: none;
  transition: transform .12s, font-size .12s, color .12s;
  background: var(--surface); padding: 0 2px;
  max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.field > input:focus + span, .field > input:not(:placeholder-shown) + span,
.field > textarea:focus + span, .field > textarea:not(:placeholder-shown) + span {
  transform: translateY(-11px); font-size: 12px;
}
.field > input:focus + span, .field > textarea:focus + span { color: var(--g-blue); }
.field-file > input { padding: 14px; height: auto; }
.field-file > span { position: static; display: block; font-size: 12px; margin-top: 4px; }
.field-email { display: grid; grid-template-columns: 1fr auto; }
.field-email > input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.field-email > .domain-select {
  height: 52px; padding: 0 12px; border: 1px solid var(--line); border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--bg); color: var(--ink-2); font-size: 14px; max-width: 220px;
}
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; color: var(--ink); line-height: 1.4; padding: 4px 0; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--g-blue); flex: none; }
.check-row { display: flex; gap: 20px; flex-wrap: wrap; }
.list-input {
  font: 13px/1.5 var(--mono); width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px; resize: vertical; background: var(--surface); color: var(--ink);
}
.list-input:focus { outline: 0; border-color: var(--g-blue); box-shadow: 0 0 0 1px var(--g-blue); }

/* ------------------------------------------------------------- auth pages */
.page-auth {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px; background: var(--surface);
}
.auth-card {
  width: 100%; max-width: 450px; border: 1px solid var(--line); border-radius: var(--r);
  padding: 44px 40px 36px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.auth-card-wide { max-width: 640px; align-items: stretch; text-align: left; }
.auth-card-wide .g-mark { align-self: center; }
.auth-title { font-size: 24px; margin-top: 18px; }
.auth-sub { color: var(--ink-2); margin-top: 8px; font-size: 15px; }
.auth-form { width: 100%; margin-top: 32px; text-align: left; }
.auth-form .field + .field { margin-top: 16px; }
.auth-step { color: var(--ink); margin-bottom: 16px; }
.auth-error { color: var(--g-red); font-size: 13px; margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.auth-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 32px; gap: 12px; }
.auth-note { font-size: 12px; color: var(--ink-2); }
.auth-footer { margin-top: 20px; font-size: 12px; color: var(--ink-2); }
.auth-body { width: 100%; margin-top: 24px; text-align: left; font-size: 14px; }
.auth-body ol, .auth-body ul { padding-left: 20px; }
.auth-body li + li { margin-top: 10px; }
.auth-body h2 { font-size: 16px; font-weight: 500; margin: 24px 0 12px; }
.auth-body .btn { margin-top: 24px; }
.setup-form h2 { font-size: 13px; font-weight: 500; color: var(--ink-2); margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); }
.setup-form .field + .field, .setup-form .check + .field, .setup-form .field + .check { margin-top: 16px; }
.setup-form .auth-note { margin-top: 8px; }
.callout { background: var(--g-blue-tint); border-radius: var(--r); padding: 14px 16px; font-size: 14px; line-height: 1.5; margin-bottom: 20px; }
.callout-warn { background: var(--g-yellow-tint); }
.callout .big { font-size: 22px; letter-spacing: 2px; margin: 10px 0 6px; }
.callout .small { font-size: 12px; word-break: break-all; color: var(--ink-2); }

/* ----------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar); display: flex; align-items: center; gap: 12px; padding: 0 16px 0 8px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 22px; min-width: 0; margin-right: 12px; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search {
  flex: 1; max-width: 720px; display: flex; align-items: center; gap: 12px;
  background: var(--bg); border-radius: var(--r); height: 46px; padding: 0 16px; color: var(--ink-2);
}
.topbar-search:focus-within { background: var(--surface); box-shadow: var(--shadow-1); }
.topbar-search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 16px; color: var(--ink); outline: 0; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.session-chip {
  display: inline-flex; align-items: center; gap: 6px; color: var(--g-green); font-size: 13px; font-weight: 500;
  padding: 6px 10px; border-radius: 16px; background: var(--g-green-tint); font-variant-numeric: tabular-nums;
}
.session-chip.is-low { color: var(--g-red); background: var(--g-red-tint); }
.nav-toggle { display: none; }

/* ---------------------------------------------------------------- layout */
.shell { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidenav {
  width: var(--sidenav); flex: none; padding: 8px 12px 8px 0;
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto;
  display: flex; flex-direction: column;
}
.nav-item {
  display: flex; align-items: center; gap: 16px; height: 40px; padding: 0 24px 0 24px;
  border-radius: 0 20px 20px 0; color: var(--ink); font-weight: 500; font-size: 14px; letter-spacing: .2px;
}
.nav-item svg { color: var(--ink-2); flex: none; }
.nav-item:hover { background: var(--hover); }
.nav-item.is-active { background: var(--g-blue-tint); color: var(--g-blue-dark); }
.nav-item.is-active svg { color: var(--g-blue-dark); }
.nav-divider { height: 1px; background: var(--line); margin: 8px 0 8px 24px; }
.nav-foot { margin-top: auto; padding: 16px 24px 8px; font-size: 12px; color: var(--ink-2); }
.nav-foot-value { display: block; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.content { flex: 1; min-width: 0; padding: 24px 32px 64px; max-width: 1180px; }
.view { display: none; }
.view.is-active { display: block; }
.view-head { margin-bottom: 20px; }
.view-head h1 { font-size: 28px; line-height: 1.25; }
.view-head p { color: var(--ink-2); margin-top: 6px; font-size: 15px; max-width: 70ch; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 16px; font-weight: 500; margin-bottom: 16px; }
.card-quiet { background: var(--bg); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  font: inherit; font-weight: 500; font-size: 14px; color: var(--ink-2); background: transparent; border: 0;
  padding: 12px 20px; cursor: pointer; position: relative; border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tab:hover { background: var(--hover); color: var(--ink); }
.tab.is-active { color: var(--g-blue); }
.tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--g-blue); border-radius: 3px 3px 0 0; }
.tabpanel { display: none; }
.tabpanel.is-active { display: block; }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.form-inline { display: flex; gap: 12px; align-items: center; }
.form-inline .grow { flex: 1; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.search-inline { display: flex; gap: 8px; flex: 1; max-width: 560px; }
.search-inline input, #auditFilter {
  flex: 1; height: 36px; font: inherit; font-size: 14px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
}
.search-inline input:focus, #auditFilter:focus { outline: 0; border-color: var(--g-blue); box-shadow: 0 0 0 1px var(--g-blue); }
#auditFilter { flex: 1; max-width: 480px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover { background: var(--bg); }
.table-dense td { padding: 8px 12px; font-size: 13px; }
.th-actions { width: 1%; }
.empty-row td { color: var(--ink-2); text-align: center; padding: 40px 12px; }
.table-foot { display: flex; justify-content: center; padding-top: 12px; }
.user-cell { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 500; font-size: 14px; flex: none;
}
.user-cell .name { font-weight: 500; }
.user-cell .email { color: var(--ink-2); font-size: 13px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-active { background: var(--g-green-tint); color: var(--g-green); }
.status-suspended { background: var(--g-red-tint); color: var(--g-red); }
.status-admin { background: var(--g-blue-tint); color: var(--g-blue-dark); }
.status-archived { background: var(--line-soft); color: var(--ink-2); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.chip-ok { color: var(--g-green); font-weight: 500; }
.chip-fail { color: var(--g-red); font-weight: 500; }
.ip { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }

/* -------------------------------------------------------------- results */
.result { margin-top: 20px; border-radius: var(--r); padding: 16px 18px; font-size: 14px; line-height: 1.5; }
.result.ok { background: var(--g-green-tint); border-left: 4px solid var(--g-green); }
.result.err { background: var(--g-red-tint); border-left: 4px solid var(--g-red); }
.result.info { background: var(--g-blue-tint); border-left: 4px solid var(--g-blue); }
.result.warn { background: var(--g-yellow-tint); border-left: 4px solid var(--g-yellow); }
.result h3 { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.result .table-wrap { margin: 12px 0 0; padding: 0; }
.result .btn { margin-top: 12px; }
.pw {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 15px; background: var(--surface);
  border: 1px dashed var(--line); padding: 6px 10px; border-radius: var(--r-sm); margin-top: 6px;
}
.pw button { font: inherit; font-size: 12px; border: 0; background: var(--g-blue-tint); color: var(--g-blue-dark); border-radius: 12px; padding: 3px 10px; cursor: pointer; font-family: var(--font); }
.user-summary { margin-top: 20px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r); display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.user-summary .grow { flex: 1; min-width: 200px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-word; }

/* --------------------------------------------------------------- bulk */
.bulk-intro { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; color: var(--ink-2); font-size: 14px; margin-bottom: 16px; line-height: 1.5; }
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--r); padding: 36px 20px; text-align: center; color: var(--ink-2); cursor: pointer;
  transition: border-color .12s, background-color .12s; font-size: 15px;
}
.dropzone:hover, .dropzone.is-over, .dropzone:focus-visible { border-color: var(--g-blue); background: var(--g-blue-tint); color: var(--g-blue-dark); }
.dropzone-compact { padding: 12px; margin-top: 8px; font-size: 13px; }
.bulk-preview { margin-top: 16px; }
.bulk-preview .summary { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; margin-bottom: 8px; }
.bulk-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.progress { margin-top: 20px; }
.progress-bar { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--g-blue); border-radius: 3px; transition: width .2s; }
.progress-bar.is-done span { background: var(--g-green); }
.progress-text { margin-top: 8px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.drive-status { margin-top: 20px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r); font-size: 14px; }
.drive-status .kv { margin-top: 8px; }
.steps { padding-left: 20px; font-size: 14px; line-height: 1.6; }
.steps li + li { margin-top: 10px; }
.plain { padding-left: 18px; font-size: 14px; line-height: 1.6; color: var(--ink); }
.plain li + li { margin-top: 6px; }
.copyable { cursor: copy; }
.copyable:hover { background: var(--g-blue-tint); }

/* ------------------------------------------------------------- dialogs */
.dialog { border: 0; border-radius: var(--r); padding: 24px; box-shadow: var(--shadow-2); width: min(92vw, 480px); color: var(--ink); }
.dialog::backdrop { background: rgba(32, 33, 36, .5); }
.dialog h2 { font-size: 20px; margin-bottom: 12px; }
.dialog p { color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.dialog .kv { margin: 12px 0 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.dialog-actions-wrap { flex-wrap: wrap; justify-content: flex-start; }
.toast {
  position: fixed; left: 24px; bottom: 24px; z-index: 50; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-sm);
  font-size: 14px; box-shadow: var(--shadow-2); max-width: 420px;
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; }
  .sidenav {
    position: fixed; top: var(--topbar); left: 0; bottom: 0; background: var(--surface); z-index: 15;
    transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow-2); height: auto;
  }
  .sidenav.is-open { transform: none; }
  .content { padding: 20px 16px 48px; }
  .topbar-search { display: none; }
  .brand-text { font-size: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .auth-card { padding: 32px 24px; border: 0; }
  .field-email > .domain-select { max-width: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
