:root {
  --oa-ui-bg: #f3f6f7;
  --oa-ui-surface: #ffffff;
  --oa-ui-surface-soft: #eef5f3;
  --oa-ui-text: #17252b;
  --oa-ui-muted: #607078;
  --oa-ui-line: #d8e2e4;
  --oa-ui-brand: #087b75;
  --oa-ui-brand-strong: #05625e;
  --oa-ui-brand-soft: #dff3ef;
  --oa-ui-info: #2867a9;
  --oa-ui-success: #147647;
  --oa-ui-warning: #8a5b00;
  --oa-ui-danger: #b42318;
  --oa-ui-shadow: 0 10px 28px rgba(19, 48, 59, .12);
  --oa-ui-radius: 10px;
  --oa-ui-control-height: 40px;
}

html { color-scheme: light; }
body[data-oa-ui] {
  color: var(--oa-ui-text);
  background: var(--oa-ui-bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-oa-ui] *,
body[data-oa-ui] *::before,
body[data-oa-ui] *::after { box-sizing: border-box; }

body[data-oa-ui] a { color: var(--oa-ui-brand-strong); }
body[data-oa-ui] button,
body[data-oa-ui] input,
body[data-oa-ui] select,
body[data-oa-ui] textarea { font: inherit; }
body[data-oa-ui] input:not([type="checkbox"]):not([type="radio"]),
body[data-oa-ui] select,
body[data-oa-ui] textarea {
  min-height: var(--oa-ui-control-height);
  border: 1px solid var(--oa-ui-line);
  border-radius: 8px;
  color: var(--oa-ui-text);
  background: var(--oa-ui-surface);
  transition: border-color .16s ease, box-shadow .16s ease;
}
body[data-oa-ui] input:not([type="checkbox"]):not([type="radio"]):focus,
body[data-oa-ui] select:focus,
body[data-oa-ui] textarea:focus {
  outline: 0;
  border-color: #5bb3a8;
  box-shadow: 0 0 0 3px rgba(8, 123, 117, .14);
}
body[data-oa-ui] button,
body[data-oa-ui] a,
body[data-oa-ui] input,
body[data-oa-ui] select,
body[data-oa-ui] textarea { scroll-margin-top: 76px; }
body[data-oa-ui] :where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid rgba(8, 123, 117, .34);
  outline-offset: 2px;
}

.oa-skip-link {
  position: fixed;
  z-index: 1100;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff !important;
  background: var(--oa-ui-brand-strong);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: transform .16s ease;
}
.oa-skip-link:focus { transform: translateY(0); }

.oa-context-bar {
  position: sticky;
  z-index: 1000;
  top: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  width: 100%;
  padding: 8px clamp(14px, 3vw, 32px);
  border-bottom: 1px solid var(--oa-ui-line);
  color: var(--oa-ui-text);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 5px rgba(19, 48, 59, .07);
  backdrop-filter: blur(14px);
}
/*
 * Some OA pages use the document body itself as a two-column grid. The
 * context bar is inserted as the first body child, so it must occupy its own
 * full-width row instead of being auto-placed into the sidebar column.
 */
body[data-oa-ui] > .oa-context-bar {
  grid-column: 1 / -1;
  grid-row: 1;
  align-self: start;
}
.oa-context-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  color: var(--oa-ui-text) !important;
  text-decoration: none;
}
.oa-context-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #087b75, #1f9b8d);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
}
.oa-context-brand-copy { font-size: 14px; font-weight: 800; white-space: nowrap; }
.oa-context-current {
  min-width: 0;
  overflow: hidden;
  color: var(--oa-ui-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.oa-context-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.oa-context-home,
.oa-context-switcher-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--oa-ui-line);
  border-radius: 8px;
  color: var(--oa-ui-text) !important;
  background: var(--oa-ui-surface);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.oa-context-home:hover,
.oa-context-switcher-trigger:hover,
.oa-context-switcher-trigger[aria-expanded="true"] {
  border-color: #8bc6bc;
  color: var(--oa-ui-brand-strong) !important;
  background: var(--oa-ui-brand-soft);
}

.oa-switcher {
  position: absolute;
  top: calc(100% + 8px);
  right: clamp(14px, 3vw, 32px);
  width: min(540px, calc(100vw - 28px));
  max-height: min(680px, calc(100vh - 82px));
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--oa-ui-line);
  border-radius: 14px;
  color: var(--oa-ui-text);
  background: var(--oa-ui-surface);
  box-shadow: var(--oa-ui-shadow);
}
.oa-switcher[hidden] { display: none; }
.oa-switcher-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.oa-switcher-header strong { font-size: 15px; }
.oa-switcher-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 7px;
  color: var(--oa-ui-muted);
  background: var(--oa-ui-surface-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.oa-switcher-search { width: 100%; padding: 0 12px; }
.oa-switcher-groups { display: flex; gap: 6px; margin: 12px 0; overflow-x: auto; scrollbar-width: thin; }
.oa-switcher-group {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--oa-ui-line);
  border-radius: 999px;
  color: var(--oa-ui-muted);
  background: var(--oa-ui-surface);
  font-size: 12px;
  cursor: pointer;
}
.oa-switcher-group:hover,
.oa-switcher-group.is-selected {
  border-color: var(--oa-ui-brand);
  color: var(--oa-ui-brand-strong);
  background: var(--oa-ui-brand-soft);
  font-weight: 750;
}
.oa-switcher-list { display: grid; gap: 6px; }
.oa-switcher-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--oa-ui-text) !important;
  text-decoration: none;
}
.oa-switcher-item:hover,
.oa-switcher-item:focus-visible,
.oa-switcher-item.is-current { border-color: #a4d3cb; background: var(--oa-ui-brand-soft); }
.oa-switcher-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--oa-ui-brand-strong);
  background: var(--oa-ui-brand-soft);
  font-size: 11px;
  font-weight: 900;
}
.oa-switcher-copy { min-width: 0; display: grid; gap: 3px; }
.oa-switcher-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.oa-switcher-copy small { overflow: hidden; color: var(--oa-ui-muted); font-size: 11px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.oa-switcher-arrow { color: var(--oa-ui-brand); font-size: 16px; }
.oa-switcher-empty { padding: 24px 12px; color: var(--oa-ui-muted); text-align: center; font-size: 13px; }
.oa-ui-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }

body[data-oa-ui] :where(.panel, .card, .widget, .frappe-card, .table-panel, .content-card) {
  border-color: var(--oa-ui-line);
  border-radius: var(--oa-ui-radius);
}
body[data-oa-ui] :where(.table-wrap, .table-panel, .datatable, .dt-scrollable) {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-color: #9fc1ba #edf4f2;
  scrollbar-width: thin;
}
body[data-oa-ui] :where(table) { font-variant-numeric: tabular-nums; }
body[data-oa-ui] :where(table th) { color: var(--oa-ui-muted); font-weight: 700; }
body[data-oa-ui] :where(table tbody tr:hover td) { background: #edf8f5; }
body[data-oa-ui] :where(.status, .badge, .pill, .indicator-pill) { border-radius: 999px; }

@media (max-width: 720px) {
  .oa-context-bar { gap: 9px; min-height: 52px; padding: 7px 12px; }
  .oa-context-brand-copy { display: none; }
  .oa-context-current { font-size: 11px; }
  .oa-context-home, .oa-context-switcher-trigger { min-height: 38px; padding: 0 10px; font-size: 11px; }
  .oa-switcher { position: fixed; top: auto; right: 0; bottom: 0; width: 100%; max-height: min(78vh, 640px); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); }
  .oa-switcher-item { min-height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --oa-ui-bg: #0e171c;
    --oa-ui-surface: #162228;
    --oa-ui-surface-soft: #203038;
    --oa-ui-text: #edf4f6;
    --oa-ui-muted: #afbec5;
    --oa-ui-line: #35464e;
    --oa-ui-brand: #38b8ad;
    --oa-ui-brand-strong: #72d7ce;
    --oa-ui-brand-soft: #173c3b;
    --oa-ui-info: #83b5ec;
    --oa-ui-success: #68d59b;
    --oa-ui-warning: #f2c668;
    --oa-ui-danger: #ff8b82;
    --oa-ui-shadow: 0 14px 34px rgba(0, 0, 0, .34);
  }
  html { color-scheme: dark; }
  .oa-context-bar { background: rgba(22, 34, 40, .94); }
  .oa-switcher-item:hover, .oa-switcher-item:focus-visible, .oa-switcher-item.is-current { border-color: #2d7355; }
  body[data-oa-ui] :where(.panel, .card, .widget, .frappe-card, .table-panel, .content-card) { box-shadow: none; }
}
