:root {
  --surface: #fff;
  --workspace-ink: #162436;
  --workspace-muted: #4e5f73;
  --workspace-line: #dbe2ea;
  --workspace-canvas: #f4f6f8;
  --workspace-sidebar: #142237;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --control-size: 42px;
  --motion-instant: 80ms;
  --motion-fast: 140ms;
  --motion-standard: 210ms;
  --motion-moderate: 275ms;
  --motion-data: 360ms;
  --motion-ease: cubic-bezier(.2, 0, 0, 1);
  --motion-enter: cubic-bezier(.16, 1, .3, 1);
  --motion-exit: cubic-bezier(.4, 0, 1, 1);
  --layer-popover: 4;
}

#workspace-shell {
  --radius: 10px;
  --ink: var(--workspace-ink);
  --muted: var(--workspace-muted);
  --line: var(--workspace-line);
  background: var(--workspace-canvas);
  color: var(--ink);
  font-family: Inter, "IBM Plex Sans Thai", "Noto Sans Thai", Tahoma, system-ui, sans-serif;
}
#workspace-shell:focus-within { scroll-margin-top: 12px; }
#workspace-shell .sidebar {
  padding: var(--space-6) var(--space-3) var(--space-4);
  background: var(--workspace-sidebar);
  height: 100dvh;
}
#workspace-shell #nav {
  gap: var(--space-3);
  min-height: 0;
  overflow: auto;
  margin-top: var(--space-6);
  scrollbar-width: thin;
  scrollbar-color: #607087 transparent;
}
#workspace-shell #nav a:focus-visible { outline-offset: -3px; }
.shell-nav-group { display: grid; align-content: start; gap: 2px; min-width: 0; }
.shell-nav-group p {
  margin: 0;
  padding: var(--space-2) var(--space-3) 2px;
  color: #c0cee0;
  font-size: .75rem;
  font-weight: 650;
}
#workspace-shell .nav-link {
  position: relative;
  padding-block: var(--space-2);
  border-radius: 7px;
  min-height: 40px;
  transition: background-color var(--motion-fast) var(--motion-ease);
}
#workspace-shell .nav-link[aria-current="page"] { background: #293d58; }
#workspace-shell .nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 2px;
  border-radius: 3px;
  background: #8cb7fa;
}
#workspace-shell .sidebar-bottom { padding-top: var(--space-3); }
#workspace-shell #main :focus-visible, #editor :focus-visible { outline-offset: 2px; }
#workspace-shell .topbar {
  min-height: 64px;
  height: auto;
  background: var(--surface);
  justify-content: flex-start;
  padding-block: var(--space-2);
  gap: var(--space-2);
}
.shell-context, .shell-tools, .editor-controls {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: var(--space-2);
}
.shell-tools { margin-inline-start: auto; }
.shell-context .crumb {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}
#workspace-shell #admin { margin-inline-start: auto; }
#workspace-shell .shell-tools:not([hidden]) + #admin { margin-inline-start: 0; }
.shell-control {
  position: relative;
  display: inline-flex;
  min-height: var(--control-size);
  min-width: var(--control-size);
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  border: 1px solid var(--workspace-line);
  border-radius: 7px;
  color: var(--workspace-ink);
  background: var(--surface);
  font-size: .875rem;
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--motion-ease);
}
.shell-control .icon { stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shell-control:hover { background: var(--workspace-canvas); }
.shell-control kbd {
  color: var(--workspace-muted);
  font: inherit;
  font-size: .75rem;
  padding: 0 var(--space-1);
}
.shell-pop { position: relative; }
.shell-pop > summary { list-style: none; }
.shell-pop > summary::-webkit-details-marker { display: none; }
.shell-pop-menu {
  position: absolute;
  display: grid;
  min-width: 128px;
  gap: var(--space-1);
  z-index: var(--layer-popover);
  inset: calc(100% + var(--space-1)) 0 auto auto;
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--workspace-line);
  border-radius: 8px;
  box-shadow: 0 6px 20px #10223818;
}
#shell-unread {
  position: absolute;
  inset: -6px -5px auto auto;
  font-size: .6875rem;
  padding: 2px 4px;
}
#workspace-menu { display: none; }
.workspace-connection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) clamp(16px, 4vw, 54px);
  background: #ffefd3;
  color: #582d02;
  font-size: .875rem;
}
#workspace-shell .content { padding-top: var(--space-6); }
#workspace-shell .heading h1 { font-size: clamp(1.5rem, 3vw, 2.125rem); }
#workspace-shell .table-scroll:focus-visible { outline-offset: -2px; }
#workspace-shell .task-secondary { overflow-wrap: anywhere; }

#editor .close-button { width: 42px; height: 42px; }
#editor .dialog-head h2 { overflow-wrap: anywhere; }
#editor .dialog-fields textarea { resize: none; overflow: auto; }
#editor .dialog-actions { background: var(--surface); flex-wrap: wrap; }
.editor-record-nav { display: flex; gap: var(--space-2); padding: var(--space-2) 20px 0; }
.editor-record-nav:not(:has(button:not([hidden]))) { display: none; }
#editor.record-drawer {
  inset: 0 0 0 auto;
  margin: 0;
  width: min(100%, 640px);
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  border-inline-start: 1px solid var(--workspace-line);
  border-radius: 0;
  overscroll-behavior: contain;
}
#editor.record-expanded {
  inset-inline: 0;
  width: min(100%, 1000px);
  margin-inline: auto;
}
#editor.record-drawer .dialog-head { background: var(--surface); }
#editor.record-drawer .dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
}
@media (min-width: 861px) {
  #workspace-shell.sidebar-collapsed { grid-template-columns: 74px minmax(0, 1fr); }
  #workspace-shell.sidebar-collapsed :is(.workspace-brand-name, .sidebar-bottom, .shell-nav-group p, .nav-link span) { display: none; }
  #workspace-shell.sidebar-collapsed .brand { margin-inline: auto; padding: 0; }
  #workspace-shell.sidebar-collapsed .nav-link { justify-content: center; padding-inline: 0; }
}
@media (max-width: 860px) {
  #workspace-shell .sidebar {
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: var(--space-2) var(--space-4);
  }
  #workspace-menu { display: inline-flex; background: #20334d; color: #fff; border-color: #647792; }
  #workspace-menu:hover { background: #293d58; }
  #sidebar-toggle { display: none; }
  #workspace-shell #nav { display: none; grid-column: 1 / -1; margin-top: var(--space-2); max-height: 52dvh; padding: var(--space-1); }
  #workspace-shell.mobile-menu-open #nav { display: grid; }
  #workspace-shell .shell-nav-group .nav-link { min-height: 44px; }
  #workspace-shell .topbar { min-height: 56px; }
  #workspace-shell .topbar .account-copy { display: none; }
  #global-search kbd { display: none; }
}
@media (max-width: 530px) {
  #workspace-shell .shell-tools { gap: var(--space-1); }
  #global-search span, .shell-pop summary span { display: none; }
  .shell-context .crumb > span { display: none; }
  #workspace-shell .shell-control { min-height: 44px; min-width: 44px; }
  #editor.record-drawer { border-inline-start: 0; }
  #editor #expand-editor { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  #workspace-shell { transition: grid-template-columns var(--motion-moderate) var(--motion-ease); }
  #workspace-shell .button {
    transition: background-color var(--motion-fast) var(--motion-ease), border-color var(--motion-fast) var(--motion-ease),
      transform var(--motion-instant) var(--motion-ease);
  }
  #workspace-shell .button:enabled:active { transform: scale(.98); }
  #workspace-shell .route-arrival {
    animation: workspace-enter var(--motion-standard) var(--motion-enter) both;
    animation-delay: 0ms;
  }
  #workspace-shell .route-arrival.heading > div:first-child { animation: none; }
  #workspace-shell.workspace-entering #page { animation-duration: var(--motion-moderate); }
  #workspace-shell .calendar-entering { animation-duration: var(--motion-standard); }
  #editor[open] { animation: editor-in var(--motion-standard) var(--motion-enter); }
  #editor.record-drawer[open] { animation: drawer-in var(--motion-moderate) var(--motion-enter); }
  #editor[open]::backdrop { animation: overlay-in var(--motion-standard) var(--motion-ease); }
  .toast { transition: opacity var(--motion-fast) var(--motion-ease), transform var(--motion-fast) var(--motion-ease); transform: translateY(6px); }
  .toast.show { transform: none; }
}
@keyframes editor-in { from { opacity: 0; transform: scale(.98); } }
@keyframes drawer-in { from { opacity: .7; transform: translateX(26px); } }
@keyframes overlay-in { from { opacity: 0; } }
.editor-draft {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--space-2) 20px;
  font-size: .875rem;
  color: #3d536d;
  background: #eef4fd;
}
.workspace-skeleton { display: grid; gap: var(--space-3); min-height: 155px; }
.workspace-skeleton span { display: block; width: min(42%, 240px); height: 16px; border-radius: 4px; background: #e5ebf4; }
.workspace-skeleton span:first-child { width: min(66%, 330px); height: 28px; }
.workspace-skeleton span:last-child { width: 94px; height: 38px; }
.shell-brand-picker > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.shell-brand-picker select {
  min-height: var(--control-size);
  width: clamp(112px, 13vw, 176px);
  padding: 0 8px;
  color: var(--workspace-ink);
  background: var(--surface);
  border: 1px solid var(--workspace-line);
  border-radius: 7px;
  font-size: .875rem;
}
@media (max-width: 980px) { .shell-brand-picker { display: none; } }
@media (min-width: 861px) {
  #workspace-shell .table-scroll:has(tbody > tr:nth-child(9)) { max-height: min(680px, 72dvh); }
  #workspace-shell .table-scroll th { position: sticky; top: 0; z-index: 1; }
}
.quick-task-status {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: .875rem;
}
.quick-task-status label { display: grid; gap: var(--space-1); max-width: 100%; }
.quick-task-status select {
  min-height: 36px;
  max-width: 100%;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding-inline: var(--space-2);
}
.quick-task-status p { flex-basis: 100%; color: #912235; margin: 0; }
#workspace-shell .personal-work-grid { align-items: start; }
#workspace-shell .account { min-width: 0; }
#workspace-shell .account-copy { min-width: 0; max-width: 148px; }
#workspace-shell .account-copy > * { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

#workspace-shell.workspace-login {
  grid-template-columns: minmax(0, 1fr);
}
#workspace-shell.workspace-login :is(.sidebar, .topbar) {
  display: none;
}
#workspace-shell.workspace-login .content {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding-block: 32px;
}
#workspace-shell.workspace-login .content > section {
  width: min(100%, 490px);
  margin: 0;
}

.workspace-preferences {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 16px;
  min-inline-size: 0;
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.workspace-preferences legend { font-weight: 700; }
.workspace-preferences label { display: grid; gap: 4px; font-size: .875rem; }
.workspace-preferences label:last-child { display: flex; align-items: center; min-height: 36px; }
.workspace-preferences select { min-height: 36px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding-inline: 8px; }
#workspace-shell.workspace-compact :is(th,td) { padding-block: 6px; }
:root[data-workspace-reduced] :is(#workspace-shell, #command-palette, #editor, #toast),
:root[data-workspace-reduced] :is(#workspace-shell, #command-palette, #editor) * {
  animation-duration: .01ms !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}
:root[data-workspace-theme="dark"] :is(#workspace-shell, #editor, #command-palette) {
  color-scheme: dark;
  --surface: #182637;
  --workspace-ink: #e7eef8;
  --workspace-muted: #b2c1d4;
  --workspace-line: #42536a;
  --workspace-canvas: #101b29;
  --workspace-sidebar: #111d2d;
  --ink: var(--workspace-ink);
  --muted: var(--workspace-muted);
  --line: var(--workspace-line);
  --canvas: var(--workspace-canvas);
  --blue: #315da6;
  --blue-dark: #b6d3ff;
  background-color: var(--workspace-canvas);
  color: var(--ink);
}
:root[data-workspace-theme="dark"] #workspace-shell :is(.panel,.stat,.staff-card,.request-card,.brand-item,.post-outlet-card,.work-card,.content-card,.content-lane,.master-agenda-day,.day,.shell-control,.popover,.demo-note) {
  color: var(--ink);
  background-color: var(--surface);
  border-color: var(--line);
}
:root[data-workspace-theme="dark"] #workspace-shell :is(.task-secondary,.record-activity,.content-card p,.profile-panel > p,.report-note,.inbox-panel li p,.work-card-meta,.launch-kicker) {
  color: var(--muted);
}
:root[data-workspace-theme="dark"] :is(#workspace-shell,#editor,#command-palette) :is(input:not([type="checkbox"]),select,textarea,.button.subtle,.dialog-actions,.dialog-head,.close-button) {
  color: var(--ink);
  background-color: var(--surface);
  border-color: var(--line);
}
:root[data-workspace-theme="dark"] :is(#workspace-shell,#editor,#command-palette) .button.subtle:hover { background-color: #243650; }
:root[data-workspace-theme="dark"] :is(#workspace-shell,#editor) .button.primary:hover { background-color: #254c8c; color: white; }
:root[data-workspace-theme="dark"] #workspace-shell :is(th, .work-view) {
  color: var(--ink);
  background-color: #202f44;
}
:root[data-workspace-theme="dark"] #workspace-shell :is(.work-view button:not([aria-pressed="true"]),.content-card-open,.director-agenda-record,.file-link,.profile-display,.post-outlet-back) {
  color: var(--blue-dark);
}
:root[data-workspace-theme="dark"] #workspace-shell :is(.empty,.filters,.calendar-top,.day.empty-day,.content-artwork,.content-lane-empty,.report-panel) {
  color: var(--muted);
  background-color: var(--workspace-canvas);
}
:root[data-workspace-theme="dark"] #workspace-shell :is(.profile-panel,.reports-toolbar) { color: var(--ink); }
:root[data-workspace-theme="dark"] :is(#workspace-shell,#editor) :is(td,th,.feedback-list li) { border-color: var(--line); }
:root[data-workspace-theme="dark"] :is(#editor,#command-palette) .editor-draft {
  background: #243650;
  color: var(--ink);
}
:root[data-workspace-theme="dark"] #workspace-shell .demo-banner .workspace-preferences { color: #543101; }
