/* app/static/app.css - 洗練された業務ツール用スタイル */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap');

:root {
  --navy: #002b4d;
  --navy-light: #003e6e;
  --navy-subtle: #f0f4f8;
  --gold: #c5a059;
  --gold-hover: #b38e47;
  --gold-light: rgba(197, 160, 89, 0.12);
  
  --bg-main: #f3f5f8;
  --card-bg: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e2e8f0;
  --border-dark: #cbd5e1;
  --danger: #b91c1c;
  --focus: #0b6dad;
  --surface-muted: #f8fafc;
  
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 43, 77, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 43, 77, 0.08), 0 2px 4px -1px rgba(0, 43, 77, 0.04);

  --font-sans: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 9px 13px;
  color: #fff;
  background: var(--navy);
  border: 2px solid var(--gold);
  border-radius: var(--radius-md);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-main);
  background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* ヘッダー */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  height: 58px;
  padding: 0 24px;
  background-color: var(--navy);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin-right: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--gold), var(--gold-hover));
  color: var(--navy);
  font-weight: 900;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.topbar nav {
  display: flex;
  min-width: 0;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: thin;
}

.topbar nav a {
  position: relative;
  padding: 8px 16px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  font-size: 13.5px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}

.topbar nav a:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
}

.topbar nav a.active {
  color: #ffffff;
  font-weight: 700;
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.topbar nav a.active::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 16px;
  right: 16px;
  height: 3px;
  background-color: var(--gold);
  border-radius: 2px 2px 0 0;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}

.notification-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 9px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  text-decoration: none;
}

.notification-link:hover,
.notification-link:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.notification-count {
  min-width: 20px;
  padding: 1px 5px;
  color: var(--navy);
  background: #fff;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  padding: 8px 10px;
  color: #fff;
  font-weight: 700;
  list-style: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-menu summary::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 9px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.user-menu summary:hover,
.user-menu summary:focus-visible,
.user-menu[open] summary {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  outline: none;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 6px;
  width: 260px;
  padding: 14px;
  color: var(--text-main);
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.user-menu-panel span,
.user-menu-panel small {
  color: var(--text-muted);
}

.user-menu-panel .account-link,
.user-menu-panel .link-button {
  display: block;
  width: 100%;
  padding: 7px 0;
  color: var(--navy-light);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

/* レイアウト・ボタン・カード */
.container { max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px; }

.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.page-heading h1 { margin: 0 0 4px; color: var(--navy); font-size: 22px; font-weight: 700; }
.page-heading h1 { overflow-wrap: anywhere; }
.page-heading p { margin: 0; color: var(--text-muted); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  background-color: #ffffff;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(180deg, var(--navy-light) 0%, var(--navy) 100%);
  border: 1px solid var(--navy);
  box-shadow: 0 2px 4px rgba(0, 43, 77, 0.2);
}

.btn-primary:hover {
  background: var(--navy);
  box-shadow: 0 4px 8px rgba(0, 43, 77, 0.3);
}

.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  background-color: var(--gold);
  border-radius: 2px;
}

.metric {
  position: relative;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric.accent-gold { border-top-color: var(--gold); }

.metric strong, .font-mono { font-family: var(--font-mono); }
.metric strong { color: var(--navy); font-size: 30px; font-weight: 700; line-height: 1.1; }

.metric strong.metric-text {
  font-family: var(--font-sans);
  font-size: 20px;
}

.dashboard-band {
  margin: 0 0 18px;
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--border-color);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 17px;
}

.phase3-metrics {
  margin-bottom: 0;
}

.weekly-status-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  margin-top: 10px;
  background: var(--border-color);
  border: 1px solid var(--border-color);
}

.weekly-status-list > div,
.notification-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 10px 12px;
  background: #fff;
}

.notification-tabs {
  margin-bottom: 12px;
}

.notification-list {
  padding: 0 14px;
}

.notification-row {
  border-bottom: 1px solid var(--border-color);
}

.notification-row:last-child {
  border-bottom: 0;
}

.notification-row.is-read {
  color: var(--text-muted);
  background: var(--surface-muted);
}

.notification-row small {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
}

/* テーブル */
.table-wrap {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  background-color: var(--navy);
  border-bottom: 1px solid var(--navy-light);
}

.sort-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 4px;
  color: #ffffff;
}

.sort-link:hover,
.sort-link.active {
  color: #ffffff;
}

.sort-indicator {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
}

.sort-link.active .sort-indicator {
  color: var(--gold);
}

.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-color); font-size: 13px; }
.data-table tbody tr:hover td { background-color: var(--gold-light); }

/* Existing Jinja template compatibility */
a {
  color: var(--navy-light);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.brand a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: 32px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.brand a::before {
  content: "相";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), var(--gold-hover));
  border-radius: var(--radius-sm);
}

.actions,
.badges,
.form-actions,
.todo-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.system-user-action {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 12px;
}

.inline-form {
  display: inline;
}

.link-button {
  padding: 0;
  color: rgba(255, 255, 255, .78);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.account-link {
  color: rgba(255, 255, 255, .82);
  font-size: 12px;
}

.btn-small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.icon-button {
  width: 30px;
  height: 30px;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.metric.money strong,
.finance-metrics strong,
.status-grid strong,
.data-table td:first-child,
.timeline-item time,
code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.grid-2,
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  padding: 10px 18px;
  color: var(--text-muted);
  font-weight: 700;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}

.tab.active {
  color: var(--navy);
  border-color: var(--gold);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.list-stack {
  display: flex;
  flex-direction: column;
}

.candidate-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(7rem, 0.22fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-main);
  padding: 0.7rem 0.5rem;
  text-align: left;
  cursor: pointer;
}

.candidate-row:hover,
.candidate-row:focus-visible {
  background: #f7f3e9;
}

.candidate-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warning-text {
  color: #7a3e00;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 4px;
  color: var(--text-main);
  border-top: 1px solid var(--border-color);
}

.list-row:first-child {
  border-top: 0;
}

.list-row small,
.todo-main small,
.resource-row small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
}

.filter-panel {
  display: grid;
  grid-template-columns: 2fr repeat(5, minmax(120px, 1fr)) auto auto;
  gap: 8px;
  padding: 14px;
  margin-bottom: 10px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.organization-scope-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 8px 12px;
  margin: -12px 0 16px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-md);
}

.organization-breadcrumb ol {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.organization-breadcrumb li {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.organization-breadcrumb li + li::before {
  content: ">";
  margin-right: 6px;
  color: var(--border-dark);
}

.organization-breadcrumb li[aria-current="location"] {
  color: var(--navy);
}

.organization-scope-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.organization-scope-form label,
.organization-scope-fixed {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.organization-scope-form select {
  max-width: 320px;
  min-height: 32px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 16px;
}

.quick-filters a,
.status,
.priority,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border-radius: var(--radius-pill);
}

.quick-filters a {
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--border-color);
}

.organization-preview,
.organization-create {
  margin-bottom: 16px;
}

.organization-tree {
  border-top: 3px solid var(--gold);
}

.organization-branch {
  border-left: 3px solid #dbe3e9;
  margin-left: 22px;
  padding-left: 18px;
}

.organization-unit {
  background: #fff;
  border-bottom: 1px solid #dbe3e9;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(240px, 1fr) minmax(380px, 1.5fr) auto;
  padding: 12px 14px;
}

.organization-team {
  margin-left: 22px;
}

.organization-unit header,
.organization-edit,
.organization-move {
  align-items: center;
  display: flex;
  gap: 8px;
}

.organization-unit code,
.organization-unit .mono,
.organization-preview .mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.organization-edit input:nth-of-type(2) {
  min-width: 160px;
}

.organization-edit input[type="number"] {
  width: 74px;
}

.metric-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  margin-bottom: 12px;
}

.metric-row > div {
  border-left: 3px solid var(--gold);
  padding: 6px 10px;
}

.metric-row small,
.metric-row strong {
  display: block;
}

@media (max-width: 980px) {
  .organization-unit {
    grid-template-columns: 1fr;
  }

  .metric-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.pagination {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin: 12px 0;
}

.pagination-summary {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.pagination-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pagination .disabled {
  opacity: 0.45;
  pointer-events: none;
}

.status,
.priority,
.badge {
  color: var(--navy);
  background: var(--navy-subtle);
}

.status-working,
.badge-primary {
  color: #fff;
  background: var(--navy-light);
}

.status-completed {
  color: #fff;
  background: #166534;
}

.status-cancelled,
.priority-high,
.badge-danger {
  color: #fff;
  background: #b91c1c;
}

.priority-medium,
.badge-warning {
  color: #513500;
  background: rgba(197, 160, 89, .26);
}

.form-card,
.login-card,
.next-action-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.container-narrow {
  display: grid;
  width: 100%;
  max-width: none;
  min-height: 100vh;
  place-items: center;
  padding: 48px 24px;
}

.login-shell {
  width: 100%;
  max-width: 440px;
  min-width: 0;
}

.login-card {
  position: relative;
  width: 100%;
  padding: 32px;
  border-top: 3px solid var(--gold);
  box-shadow: var(--shadow-md);
}

.login-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.login-brand-mark {
  display: inline-flex;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: var(--navy);
  background: var(--gold);
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 900;
}

.login-product-label {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.login-heading h1 {
  margin: 0;
  color: var(--navy);
  font-size: 22px;
  font-weight: 700;
}

.login-description {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-form {
  gap: 8px;
}

.login-form input,
.login-submit {
  width: 100%;
  height: 44px;
}

.login-form input {
  margin-bottom: 8px;
  padding: 0 12px;
}

.login-submit {
  margin-top: 8px;
}

.form-card section {
  padding: 18px 0;
  border-top: 1px solid var(--border-color);
}

.form-card section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.form-grid label,
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #334155;
  font-weight: 700;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.stack-form input,
.stack-form select,
.filter-panel input,
.filter-panel select,
.mini-form input,
.mini-form select {
  min-width: 0;
  padding: 9px 10px;
  color: var(--text-main);
  background: #fff;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  outline: none;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.stack-form input:focus,
.filter-panel input:focus,
.filter-panel select:focus,
.mini-form input:focus,
.mini-form select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, .16);
}

.check-label {
  flex-direction: row !important;
  align-items: center !important;
  gap: 7px !important;
}

.check-label input {
  width: auto !important;
}

.field-note,
.muted {
  color: var(--text-muted);
}

.required,
.text-danger {
  color: #b91c1c !important;
  font-weight: 700;
}

.next-action-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border-left: 4px solid var(--gold);
}

.eyebrow {
  color: var(--gold-hover);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.info-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 9px 12px;
  margin: 0;
}

.info-grid dt {
  color: var(--text-muted);
  font-weight: 700;
}

.info-grid dd {
  margin: 0;
}

.text-block {
  padding-top: 14px;
  margin-top: 16px;
  border-top: 1px solid var(--border-color);
}

.mini-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr)) auto;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
}

.mini-form label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  color: #334155;
  font-weight: 700;
}

.resource-form {
  grid-template-columns: 1fr 140px 2fr 1fr auto auto;
}

.todo-list {
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.todo-row {
  display: grid;
  grid-template-columns: minmax(250px, 2fr) minmax(180px, 1fr) auto;
  gap: 15px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.todo-row:first-child {
  border-top: 0;
}

.todo-row.done {
  opacity: .72;
  background: #f8fafc;
}

.todo-row.done strong {
  text-decoration: line-through;
}

.todo-meta {
  display: flex;
  gap: 14px;
  color: var(--text-muted);
}

.add-panel {
  padding: 14px;
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.resource-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 2px;
  border-top: 1px solid var(--border-color);
}

.resource-row:first-child {
  border-top: 0;
}

.resource-row code {
  display: block;
  margin-top: 5px;
  color: #475569;
  word-break: break-all;
}

.finance-metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}

.finance-metrics > div,
.status-grid a {
  padding: 11px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.finance-metrics span,
.finance-metrics small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.finance-metrics strong {
  display: block;
  margin: 4px 0;
  color: var(--navy);
  font-size: 17px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.status-grid a {
  display: flex;
  justify-content: space-between;
  color: var(--text-main);
}

.overdue-list {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.overdue-list h3 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 14px;
}

.timeline {
  margin-top: 15px;
}

.dashboard-timeline {
  margin-top: 0;
}

.recent-activity-table-wrap,
.alert-case-table-wrap {
  overflow-x: auto;
}

.recent-activity-table,
.alert-case-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.recent-activity-table th,
.recent-activity-table td,
.alert-case-table th,
.alert-case-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  text-align: left;
  vertical-align: middle;
}

.recent-activity-table th,
.alert-case-table th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  background: #f8fafc;
}

.recent-activity-table th:nth-child(1),
.recent-activity-table td:nth-child(1) {
  width: 150px;
}

.recent-activity-table th:nth-child(2),
.recent-activity-table td:nth-child(2) {
  width: 27%;
}

.recent-activity-table th:nth-child(3),
.recent-activity-table td:nth-child(3) {
  width: 140px;
}

.recent-activity-table th:nth-child(5),
.recent-activity-table td:nth-child(5) {
  width: 110px;
}

.alert-case-table th:nth-child(1),
.alert-case-table td:nth-child(1) {
  width: calc(100% - 332px);
}

.alert-case-table th:nth-child(2),
.alert-case-table td:nth-child(2) {
  width: 112px;
}

.alert-case-table th:nth-child(3),
.alert-case-table td:nth-child(3) {
  width: 100px;
}

.alert-case-table th:nth-child(4),
.alert-case-table td:nth-child(4) {
  width: 120px;
}

.recent-activity-table .nowrap,
.recent-activity-table .recent-case,
.recent-activity-table .recent-message,
.alert-case-table .nowrap,
.alert-case-table .alert-case-title,
.alert-case-table .alert-badges {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-case-table .alert-badges {
  display: block;
}

.alert-case-table .badge {
  min-height: 20px;
  padding: 2px 7px;
  font-size: 10.5px;
}

.recent-activity-table .mono,
.alert-case-table .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.timeline-item {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border-color);
}

.timeline-item p {
  margin: 6px 0 0;
}

.activity-message {
  white-space: pre-wrap;
}

.meet-import-form {
  margin-top: 8px;
}

.timeline-item time,
.empty {
  color: var(--text-muted);
}

.empty {
  padding: 20px;
  text-align: center;
}

.alert {
  padding: 11px 13px;
  margin-bottom: 15px;
  border-radius: var(--radius-lg);
}

.alert-danger {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.alert-success {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.prewrap {
  white-space: pre-wrap;
}

.import-card {
  max-width: 760px;
}

@media (max-width: 1050px) {
  .metric-grid,
  .metric-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-2,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    grid-template-columns: 1fr 1fr;
  }

  .finance-metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .resource-form,
  .mini-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 701px) and (max-width: 900px) {
  .topbar {
    height: auto;
    min-height: 58px;
    padding: 8px 24px;
    flex-wrap: wrap;
    gap: 6px 12px;
  }

  .topbar nav {
    display: flex;
    order: 3;
    flex: 1 0 100%;
    gap: 3px;
    padding-bottom: 2px;
    overflow-x: auto;
  }

  .topbar nav a {
    flex: 0 0 auto;
    padding: 7px 12px;
  }

  .topbar nav a.active::after {
    bottom: -4px;
  }

  .brand {
    flex: 1 1 150px;
    min-width: 0;
  }

  .brand a {
    margin-right: 0;
  }

  .userbox {
    flex: 0 1 auto;
    min-width: 0;
  }
}

@media (max-width: 700px) {
  .topbar {
    height: auto;
    min-height: 58px;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .topbar nav {
    display: flex;
    order: 3;
    flex: 1 0 100%;
    gap: 3px;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .topbar nav a {
    flex: 0 0 auto;
    padding: 7px 11px;
  }

  .topbar nav a.active::after {
    bottom: -4px;
  }

  .brand {
    flex: 1 1 150px;
    min-width: 0;
  }

  .brand a {
    margin-right: 0;
  }

  .userbox {
    flex: 0 1 auto;
    min-width: 0;
  }

  .user-menu summary {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-menu-panel {
    width: min(260px, calc(100vw - 28px));
  }

  .container {
    padding: 20px 12px 36px;
  }

  .container-narrow {
    min-height: 100vh;
    padding: 28px 16px;
  }

  .login-card {
    padding: 24px;
  }

  .page-heading {
    flex-direction: column;
  }

  .page-heading > .actions {
    width: 100%;
  }

  .metric-grid,
  .metric-grid-5 {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid,
  .form-grid.compact,
  .todo-row,
  .mini-form,
  .resource-form,
  .filter-panel {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .finance-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .userbox span {
    display: none;
  }

  .organization-scope-bar,
  .organization-scope-form {
    align-items: stretch;
    flex-direction: column;
  }

  .organization-scope-form select {
    max-width: none;
    width: 100%;
  }

  .info-grid {
    grid-template-columns: 110px 1fr;
  }

  .card,
  .form-card,
  .next-action-card {
    padding: 14px;
  }

  .pagination {
    align-items: flex-start;
  }

  .pagination-summary,
  .pagination-actions {
    flex: 1 1 100%;
    width: 100%;
  }

  .pagination-actions .btn {
    flex: 1 1 calc(50% - 8px);
  }

  .next-action-card {
    align-items: stretch;
    flex-direction: column;
  }

  .next-action-card .btn {
    align-self: flex-start;
  }

  .quick-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-filters a {
    justify-content: center;
  }

  .list-row,
  .resource-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Case list readability: compact, single-line table rows */
.table-wrap {
  border-radius: var(--radius-md);
}

.case-table {
  min-width: 0;
  table-layout: fixed;
}

.case-table th,
.case-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-table th {
  padding: 9px 10px;
  font-size: 11px;
}

.case-table td {
  padding: 8px 10px;
  height: 42px;
  font-size: 12.5px;
  line-height: 1.35;
}

.case-table td strong {
  font-weight: 700;
}

.case-table small {
  display: inline;
  margin: 0 0 0 4px;
}

.case-table .badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.case-table .badge,
.case-table .status,
.case-table .priority {
  min-height: 20px;
  padding: 2px 7px;
  font-size: 10.5px;
}

.case-table th:nth-child(1),
.case-table td:nth-child(1) {
  width: 86px;
}

.case-table th:nth-child(2),
.case-table td:nth-child(2) {
  width: 300px;
}

.case-table th:nth-child(3),
.case-table td:nth-child(3) {
  width: 130px;
}

.case-table th:nth-child(4),
.case-table td:nth-child(4) {
  width: 150px;
}

.case-table th:nth-child(5),
.case-table td:nth-child(5) {
  width: 92px;
}

.case-table th:nth-child(6),
.case-table td:nth-child(6) {
  width: 82px;
}

.case-table th:nth-child(7),
.case-table td:nth-child(7) {
  width: 130px;
}

.case-table th:nth-child(8),
.case-table td:nth-child(8) {
  width: 260px;
}

.case-table th:nth-child(9),
.case-table td:nth-child(9),
.case-table th:nth-child(10),
.case-table td:nth-child(10) {
  width: 106px;
}

.case-table th:nth-child(11),
.case-table td:nth-child(11) {
  width: 160px;
}

/* Phase 2 case list: compact server-rendered controls and nine-column table. */
.filter-disclosure {
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.filter-disclosure > summary {
  padding: 10px 14px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.case-filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border-color);
  border-radius: 0;
  box-shadow: none;
}

.case-filter-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.filter-chips a {
  padding: 4px 8px;
  color: var(--navy);
  font-size: 11px;
  font-weight: 700;
  background: var(--navy-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.case-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.case-table th:nth-child(1), .case-table td:nth-child(1) { width: 8%; }
.case-table th:nth-child(2), .case-table td:nth-child(2) { width: 19%; }
.case-table th:nth-child(3), .case-table td:nth-child(3) { width: 10%; }
.case-table th:nth-child(4), .case-table td:nth-child(4) { width: 14%; }
.case-table th:nth-child(5), .case-table td:nth-child(5) { width: 8%; }
.case-table th:nth-child(6), .case-table td:nth-child(6) { width: 7%; }
.case-table th:nth-child(7), .case-table td:nth-child(7) { width: 12%; }
.case-table th:nth-child(8), .case-table td:nth-child(8) { width: 9%; }
.case-table th:nth-child(9), .case-table td:nth-child(9) { width: 13%; }

.sort-form {
  margin: 0;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 0;
  color: #fff;
  font: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.sort-button:hover,
.sort-button:focus-visible,
.sort-button.active span {
  color: var(--gold);
}

.case-title,
.case-actions {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
}

.case-actions a {
  flex: 0 0 auto;
}

.case-detail-heading {
  align-items: flex-start;
}

.case-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.case-summary strong {
  color: var(--text-main);
}

.case-detail-tabs {
  overflow-x: auto;
  scrollbar-width: thin;
}

.case-detail-tabs .tab {
  flex: 0 0 auto;
  white-space: nowrap;
}

.case-tab-panel > .card + .card {
  margin-top: 18px;
}

.readonly-field {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text-main);
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.field-error {
  display: block;
  margin-top: 3px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 980px) {
  .case-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .case-table th:nth-child(3), .case-table td:nth-child(3),
  .case-table th:nth-child(4), .case-table td:nth-child(4),
  .case-table th:nth-child(6), .case-table td:nth-child(6) {
    display: none;
  }

  .people-table,
  .users-table {
    min-width: 760px;
  }
}

.people-table,
.users-table {
  min-width: 0;
  table-layout: fixed;
}

.people-table th,
.people-table td,
.users-table th,
.users-table td {
  padding: 9px 10px;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.people-table th:nth-child(1),
.people-table td:nth-child(1) {
  width: 17%;
}

.people-table th:nth-child(2),
.people-table td:nth-child(2) {
  width: 58px;
  text-align: center;
}

.people-table th:nth-child(3),
.people-table td:nth-child(3),
.people-table th:nth-child(4),
.people-table td:nth-child(4) {
  width: 18%;
}

.people-table th:nth-child(5),
.people-table td:nth-child(5) {
  width: 22%;
}

.people-table th:nth-child(6),
.people-table td:nth-child(6) {
  width: 90px;
}

.people-table th:nth-child(7),
.people-table td:nth-child(7) {
  width: 64px;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 18%;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2),
.users-table th:nth-child(3),
.users-table td:nth-child(3) {
  width: 16%;
}

.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  width: 28%;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  width: 72px;
}

.users-table th:nth-child(6),
.users-table td:nth-child(6),
.users-table th:nth-child(7),
.users-table td:nth-child(7) {
  width: 72px;
}

.filter-panel {
  box-shadow: none;
}

.quick-filters a {
  padding: 5px 9px;
  font-size: 11.5px;
}

.nowrap,
.mono {
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.resource-row > :first-child,
.list-row > :first-child {
  min-width: 0;
}

.resource-row code {
  overflow-wrap: anywhere;
}

body :focus-visible {
  outline: 3px solid var(--focus) !important;
  outline-offset: 2px !important;
}

.topbar :focus-visible,
.skip-link:focus-visible,
.data-table th :focus-visible {
  outline-color: #f6cf7b !important;
}

@media (max-width: 700px) {
  .case-table {
    min-width: 660px;
  }
}

@media (max-width: 420px) {
  .metric-grid,
  .metric-grid-5,
  .finance-metrics {
    grid-template-columns: 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .info-grid dt {
    padding-bottom: 0;
  }
}

/* Phase 4 AI support surfaces */
.ai-metric-grid {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.ai-metric-grid .metric strong {
  font-size: 24px;
}

.ai-job-table {
  min-width: 980px;
  table-layout: fixed;
}

.ai-job-table th:nth-child(1) { width: 18%; }
.ai-job-table th:nth-child(2) { width: 17%; }
.ai-job-table th:nth-child(3) { width: 15%; }
.ai-job-table th:nth-child(4) { width: 14%; }
.ai-job-table th:nth-child(5) { width: 24%; }
.ai-job-table th:nth-child(6) { width: 12%; }

.ai-job-table td {
  vertical-align: top;
  overflow-wrap: anywhere;
}

.ai-job-table td small,
.ai-job-table td span {
  display: block;
  margin-top: 4px;
}

.meeting-ai-workspace {
  margin-bottom: 16px;
}

.meeting-ai-list {
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.meeting-ai-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.meeting-ai-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.meeting-ai-heading,
.meeting-ai-heading > div,
.meeting-action-candidate {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meeting-ai-heading {
  justify-content: space-between;
  margin-bottom: 12px;
}

.meeting-ai-heading small {
  color: var(--muted);
}

.meeting-source {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.meeting-source summary {
  padding: 10px 12px;
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
}

.meeting-source pre {
  max-height: 280px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.7;
}

.meeting-proposal,
.meeting-confirmed,
.meeting-confirm-form {
  margin-top: 12px;
  padding: 14px 0 0 14px;
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--gold);
}

.meeting-confirmed {
  border-left-color: var(--navy);
}

.section-label {
  margin-bottom: 8px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

.compact-info-grid {
  margin-top: 10px;
}

.meeting-candidates {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.meeting-candidates legend {
  padding: 0 6px;
  color: var(--navy);
  font-weight: 700;
}

.meeting-candidates > label {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 2fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.meeting-action-candidate {
  display: grid;
  grid-template-columns: 120px minmax(180px, 2fr) minmax(150px, 1fr) 150px;
  margin-bottom: 8px;
}

.meeting-confirm-form > small,
.ai-upload-form > small {
  color: var(--muted);
}

@media (max-width: 1050px) {
  .ai-metric-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 700px) {
  .ai-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meeting-ai-heading,
  .meeting-ai-heading > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .meeting-candidates > label,
  .meeting-action-candidate {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .ai-metric-grid {
    grid-template-columns: 1fr;
  }
}
