html,
body {
  margin: 0;
  min-height: 100%;
}

body:has(.shell) {
  min-width: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--cc-canvas, #f4f6f5);
  color: var(--cc-ink, #17211d);
}

.shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(196px, 224px) minmax(0, 1fr);
  gap: 0;
  padding: 0;
  background: var(--cc-canvas, #f4f6f5);
  transition: padding-right 160ms ease;
}

.sidebar {
  position: relative;
  top: auto;
  z-index: 10;
  display: flex;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 100dvh;
  align-self: start;
  flex-direction: column;
  gap: 0;
  padding: 0 10px 12px;
  border: 0;
  border-right: 1px solid #30413b;
  border-radius: 0;
  background: var(--cc-nav, #182722);
  color: #f6faf8;
  overflow: visible;
}

.brand {
  display: flex;
  min-height: 64px;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mark {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #28483e;
  box-shadow: none;
  color: #ffffff;
  font-weight: 700;
}

.brand > div:last-child,
.title,
.command,
.status {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  overflow: hidden;
  color: #f6faf8;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: #adbbb5;
  font-size: 10px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#primaryNav {
  display: block;
  min-height: 0;
  flex: 0 0 auto;
  margin: 10px 0 0;
  padding: 0;
  overflow: visible;
}

.cc-shell-nav {
  display: grid;
  align-content: start;
  gap: 14px;
}

.cc-shell-nav__group {
  display: grid;
  align-content: start;
  gap: 4px;
}

.cc-shell-nav__group-label {
  display: block;
  padding: 0 9px;
  color: #91a099;
  font-size: 10px;
  font-weight: 700;
  line-height: 20px;
}

.cc-shell-nav__links {
  display: grid;
  align-content: start;
  gap: 2px;
}

#primaryNav .cc-shell-nav__item {
  display: flex;
  width: 100%;
  height: 36px;
  min-width: 0;
  min-height: 36px;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 10px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #cad4cf;
  font-size: 13px;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-shell-nav__icon {
  display: block;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin: 0;
  color: currentColor;
  opacity: 0.82;
  vertical-align: middle;
}

.cc-shell-nav__label {
  display: block;
  min-width: 0;
  overflow: hidden;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#primaryNav .cc-shell-nav__item:hover {
  background: var(--cc-nav-hover, #243832);
  color: #ffffff;
}

#primaryNav .cc-shell-nav__item[aria-current="page"],
#primaryNav .cc-shell-nav__item.active {
  background: var(--cc-nav-active, #31584b);
  color: #ffffff;
  font-weight: 700;
}

#primaryNav .cc-shell-nav__item.nav-locked {
  background: transparent;
  color: #7f918b;
  cursor: not-allowed;
  opacity: 0.72;
}

.module-tabs-nav .cc-shell-tool-icon {
  width: 17px;
  height: 17px;
  pointer-events: none;
  vertical-align: middle;
}

.pin-button {
  min-height: 34px;
  flex: 0 0 auto;
  margin: 12px 0 0;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: transparent;
  color: #adbbb5;
  font-size: 11px;
  text-align: left;
}

.nav.pinned {
  display: grid;
  max-height: none;
  flex: 0 0 auto;
  gap: 4px;
  margin: 6px 0 0;
  padding-top: 8px;
  overflow: visible;
}

.nav.pinned a {
  display: flex;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 5px;
  color: #adbbb5;
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.nav.pinned a:hover,
.nav.pinned a:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.main {
  display: grid;
  min-width: 0;
  min-height: 100dvh;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 0;
  background: var(--cc-canvas, #f4f6f5);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: grid;
  min-width: 0;
  min-height: 62px;
  grid-template-columns: minmax(210px, 300px) minmax(280px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  border: 0;
  border-bottom: 1px solid var(--cc-line, #d9e0dc);
  border-radius: 0;
  background: var(--cc-surface, #ffffff);
  box-shadow: none;
}

.title h2 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title > span:not(.mobile-app-label) {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--cc-ink-soft, #52605a);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-app-label {
  display: none;
}

.command {
  display: flex;
  height: 36px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--cc-line-strong, #bac6c0);
  border-radius: 6px;
  background: var(--cc-surface-muted, #f8faf9);
}

.command span {
  flex: 0 0 auto;
  color: var(--cc-ink-soft, #52605a);
  font-size: 11px;
  white-space: nowrap;
}

.command input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--cc-ink, #17211d);
  font-size: 12px;
}

.status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  overflow: hidden;
  color: var(--cc-ink-soft, #52605a);
  font-size: 10px;
  white-space: nowrap;
}

#workspaceStatus {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-button,
.ai-fab {
  min-width: 34px;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 9px;
  border: 1px solid var(--cc-line, #d9e0dc);
  border-radius: 5px;
  background: var(--cc-surface, #ffffff);
  box-shadow: none;
  font-size: 11px;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 10px;
  padding: 12px 18px 18px;
  background: var(--cc-canvas, #f4f6f5);
  overflow: visible;
}

.module-tabs-shell,
.tabs,
.module-stage,
.command-panel {
  min-width: 0;
}

.module-tabs-shell {
  border-bottom: 1px solid var(--cc-line, #d9e0dc);
  border-radius: 0;
  background: var(--cc-surface, #ffffff);
}

.module-stage {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: visible;
}

body.ai-open .shell {
  padding-right: 380px;
}

@media (min-width: 1181px) {
  .module-stage:has(.finance-calendar-panel:not(.tab-panel-hidden)) {
    overflow: hidden;
  }
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: minmax(184px, 196px) minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: minmax(180px, 250px) minmax(220px, 1fr) auto;
    gap: 10px;
    padding-inline: 14px;
  }

  #workspaceStatus {
    max-width: 92px;
  }

  .workspace {
    padding-inline: 14px;
  }
}

@media (max-width: 760px) {
  body:has(.shell) {
    --cc-mobile-nav-height: 104px;
    padding-bottom: var(--cc-mobile-nav-height);
    overflow-x: hidden;
  }

  body.ai-open .shell {
    padding-right: 0;
  }

  .shell {
    display: block;
    min-height: calc(100dvh - var(--cc-mobile-nav-height));
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    inset: auto 0 0;
    display: block;
    width: 100%;
    height: var(--cc-mobile-nav-height);
    min-height: 0;
    padding: 0;
    border: 0;
    border-top: 1px solid var(--cc-line, #d9e0dc);
    border-radius: 0;
    background: var(--cc-surface, #ffffff);
    color: var(--cc-ink-soft, #52605a);
    overflow: hidden;
  }

  .brand,
  .pin-button,
  .nav.pinned,
  .cc-shell-nav__group-label {
    display: none;
  }

  #primaryNav {
    width: 100%;
    height: var(--cc-mobile-nav-height);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: hidden;
  }

  .cc-shell-nav {
    display: grid;
    width: 100%;
    min-width: 0;
    height: var(--cc-mobile-nav-height);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(2, 52px);
    gap: 0;
  }

  .cc-shell-nav__group,
  .cc-shell-nav__links {
    display: contents;
  }

  #primaryNav .cc-shell-nav__item {
    display: flex;
    width: 100%;
    height: 52px;
    min-width: 0;
    min-height: 52px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 3px 2px;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--cc-ink-soft, #52605a);
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #primaryNav .cc-shell-nav__icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    margin: 0;
  }

  #primaryNav .cc-shell-nav__label {
    display: block;
    max-width: 100%;
    line-height: 14px;
  }

  #primaryNav .cc-shell-nav__item:hover {
    background: var(--cc-surface-muted, #f8faf9);
    color: var(--cc-accent-strong, #0f573f);
  }

  #primaryNav .cc-shell-nav__item[aria-current="page"],
  #primaryNav .cc-shell-nav__item.active {
    background: var(--cc-accent-soft, #e5f1ec);
    box-shadow: inset 0 3px 0 var(--cc-accent, #176b50);
    color: var(--cc-accent-strong, #0f573f);
  }

  #primaryNav .cc-shell-nav__item.nav-locked {
    background: transparent;
    box-shadow: none;
    color: var(--cc-ink-faint, #7b8781);
  }

  .main {
    min-height: calc(100dvh - var(--cc-mobile-nav-height));
    grid-template-rows: auto auto;
    align-content: start;
  }

  .topbar {
    position: relative;
    display: grid;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    padding: 9px 10px 10px;
    border-radius: 0;
  }

  .mobile-app-label {
    display: block;
    margin-bottom: 1px;
    color: var(--cc-accent, #176b50);
    font-size: 10px;
    font-weight: 700;
  }

  .title h2 {
    font-size: 16px;
  }

  .title > span:not(.mobile-app-label) {
    display: none;
  }

  .command {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    height: 38px;
  }

  .command span {
    margin: 0;
  }

  .status {
    grid-column: 2;
    grid-row: 1;
    gap: 5px;
  }

  .status .dot,
  #workspaceStatus,
  #clock {
    display: none;
  }

  .status-button,
  .ai-fab {
    min-width: 36px;
    min-height: 34px;
    padding-inline: 7px;
  }

  .workspace {
    gap: 8px;
    padding: 8px 9px 14px;
    overflow: visible;
  }

  .module-tabs-shell {
    min-height: 40px;
  }

  .module-stage {
    min-width: 0;
    padding: 0;
  }
}

.action-feedback {
  min-width: 0;
  border-radius: 0;
}


.settings-pinned-order {
  min-width: 0;
}

.settings-pinned-list {
  min-width: 0;
}

.settings-pinned-row {
  display: grid;
  min-height: 56px;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding-inline: 4px;
  transition: background-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.settings-pinned-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.settings-pinned-copy small {
  overflow-wrap: anywhere;
}

.settings-pinned-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.settings-pin-reorder {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--cc-line, #d9e0dc);
  border-radius: 6px;
  background: var(--cc-surface, #ffffff);
  color: var(--cc-ink-soft, #52605a);
}

.settings-pin-reorder:hover:not(:disabled),
.settings-pin-reorder:focus-visible {
  border-color: var(--cc-accent, #176b50);
  background: var(--cc-accent-soft, #e5f1ec);
  color: var(--cc-accent-strong, #0f573f);
}

.settings-pin-reorder:focus-visible {
  outline: 2px solid var(--cc-accent, #176b50);
  outline-offset: 2px;
}

.settings-pin-reorder:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.settings-pin-reorder svg {
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.settings-pin-drag-handle {
  cursor: grab;
  touch-action: none;
}

.settings-pin-drag-handle:active {
  cursor: grabbing;
}

.settings-pin-sort-ghost {
  background: var(--cc-accent-soft, #e5f1ec);
  opacity: 0.45;
}

.settings-pin-sort-chosen {
  background: #f1f7f4;
  box-shadow: inset 3px 0 0 var(--cc-accent, #176b50);
}

.settings-pin-sort-drag {
  border-radius: 8px;
  background: var(--cc-surface, #ffffff);
  box-shadow: 0 8px 20px rgba(21, 50, 40, 0.14);
}

.settings-pinned-list[aria-busy="true"] .settings-pinned-row {
  opacity: 0.72;
}

.settings-pinned-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--cc-ink-faint, #7b8781);
  font-size: 12px;
  line-height: 20px;
}

@media (max-width: 760px) {
  .settings-pinned-row {
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: start;
    padding-block: 10px;
  }

  .settings-pin-reorder {
    width: 40px;
    height: 40px;
  }

  .settings-pinned-copy {
    min-height: 40px;
    align-content: center;
  }

  .settings-pinned-actions {
    display: grid;
    width: 100%;
    grid-column: 1 / -1;
    grid-template-columns: 40px 40px minmax(72px, 1fr);
    gap: 6px;
    padding-left: 48px;
  }

  .settings-pinned-actions .mini-action {
    min-height: 40px;
    justify-content: center;
  }
}
