:root {
  --bg: #c8c8c8;
  --panel: #f2f2f2;
  --panel-muted: #e5e5e5;
  --ink: #111111;
  --muted: #404040;
  --line: #6a6a6a;
  --line-soft: #8a8a8a;
  --brand: #173b63;
  --brand-ink: #ffffff;
  --focus: #0f5ea8;
  --shadow: rgba(0, 0, 0, 0.18);
  --font-main: Verdana, Geneva, Tahoma, sans-serif;
  --font-head: "Trebuchet MS", Verdana, Geneva, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  color: var(--ink);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, #d3d3d3 0%, #bdbdbd 100%);
  background-repeat: no-repeat;
  background-size: 100% 100vh;
  background-attachment: fixed;
  line-height: 1.4;
}

a {
  color: #003f7f;
}

a:hover {
  color: #001f47;
}

.site-shell {
  max-width: 1100px;
  margin: 1rem auto;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--shadow);
}

.site-nav {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #d9d9d9 0%, #c6c6c6 100%);
  padding: 0.65rem 0.75rem;
}

.site-brand {
  margin: 0 0 0.6rem;
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.site-brand a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.site-brand a:hover {
  border-bottom-color: var(--ink);
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.site-nav li {
  margin: 0;
}

.site-nav a,
.nav-user-trigger {
  display: inline-block;
  border: 1px solid var(--line);
  background: #efefef;
  padding: 0.25rem 0.6rem;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.88rem;
}

.site-nav a:hover,
.nav-user-trigger:hover {
  background: #ffffff;
}

.nav-user-menu {
  margin-left: auto;
  position: relative;
}

.nav-user-menu details {
  margin: 0;
}

.nav-user-menu summary {
  list-style: none;
  cursor: pointer;
}

.nav-user-menu summary::-webkit-details-marker {
  display: none;
}

.nav-user-trigger::after {
  content: " \25BE";
  font-size: 0.72rem;
}

.nav-user-dropdown {
  position: absolute;
  right: 0;
  margin-top: 0.2rem;
  min-width: 130px;
  background: #efefef;
  border: 1px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow);
  padding: 0.35rem;
  z-index: 30;
}

.nav-user-dropdown a {
  display: block;
}

.content {
  padding: 1rem;
}

.content > header {
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 0.9rem;
  padding-bottom: 0.55rem;
}

.primary-link {
  display: inline-block;
  border: 1px solid #0d2948;
  background: var(--brand);
  color: var(--brand-ink);
  text-decoration: none;
  font-weight: 700;
  padding: 0.32rem 0.65rem;
}

.primary-link:hover {
  color: var(--brand-ink);
  background: #204c7b;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}

p,
ul,
ol,
form {
  margin-top: 0;
  margin-bottom: 0.9rem;
}

ul,
ol {
  padding-left: 1.2rem;
}

small {
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--line-soft);
}

fieldset {
  border: 1px solid var(--line);
  padding: 0.8rem;
  margin: 0 0 0.9rem;
  background: var(--panel-muted);
}

legend {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0 0.3rem;
}

label {
  font-weight: 700;
  font-size: 0.84rem;
  margin-bottom: 0.2rem;
  display: inline-block;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 0.36rem 0.42rem;
  font: inherit;
  margin-top: 0.15rem;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

button,
input[type="submit"] {
  border: 1px solid #545454;
  background: linear-gradient(180deg, #f0f0f0 0%, #d5d5d5 100%);
  color: var(--ink);
  padding: 0.33rem 0.65rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
  background: linear-gradient(180deg, #ffffff 0%, #dddddd 100%);
}

button:active,
input[type="submit"]:active {
  transform: translateY(1px);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid var(--line);
}

th,
td {
  border: 1px solid var(--line-soft);
  padding: 0.45rem 0.55rem;
  text-align: left;
}

th {
  background: #e2e2e2;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stacked-form > p {
  margin-bottom: 0.8rem;
}

.form-panel {
  border: 1px solid var(--line);
  background: #e8e8e8;
  padding: 0.7rem;
}

.inline-filters {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.inline-filters .filter-group {
  display: flex;
  flex-direction: column;
  min-width: 145px;
}

.inline-filters label {
  margin-bottom: 0.15rem;
}

.inline-filters select,
.inline-filters input[type="text"],
.inline-filters input[type="number"] {
  width: auto;
  min-width: 145px;
  max-width: none;
  margin-top: 0;
}

.inline-filters button {
  white-space: nowrap;
  flex: 0 0 auto;
}

.suggestion-list,
.task-list-cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.suggestion-card,
.task-list-card {
  border: 1px solid var(--line);
  background: #f5f5f5;
  padding: 0.65rem 0.75rem;
}

.suggestion-head {
  margin-bottom: 0.35rem;
}

.suggestion-meta,
.task-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  font-size: 0.88rem;
  color: #353535;
}

.suggestion-description,
.suggestion-reason {
  margin: 0.45rem 0 0;
  font-size: 0.9rem;
}

.suggestion-actions {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.45rem;
}

.suggestion-actions form {
  margin: 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.checkbox-row label {
  margin: 0;
  font-weight: 600;
}

.field-error {
  display: block;
  margin-top: 0.3rem;
  color: #6b1f1f;
  background: #f5dcdc;
  border: 1px solid #af5d5d;
  padding: 0.25rem 0.45rem;
  font-size: 0.85rem;
}

/* Auth pages */
.auth-page .site-shell {
  max-width: 600px;
}

.auth-card {
  max-width: 460px;
  margin: 0;
  padding: 0.9rem;
  border: 1px solid var(--line);
  background: #efefef;
}

.auth-alt-link {
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
}

/* Messaging */
.conversation-list,
.message-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.9rem;
}

.message-search {
  position: relative;
  margin-bottom: 1rem;
}

.message-search input {
  width: 100%;
}

.message-search-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #4f4f4f;
}

.message-search-results {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  border: 1px solid #b9b9b9;
  background: #f2f2f2;
  max-height: 16rem;
  overflow-y: auto;
}

.message-search-result-item + .message-search-result-item {
  border-top: 1px solid #c9c9c9;
}

.message-search-result-link {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.5rem 0.6rem;
  text-decoration: none;
  color: #101820;
}

.message-search-result-link:hover,
.message-search-result-link:focus {
  background: #e2e8ef;
}

.message-search-identity {
  min-width: 0;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.message-search-name {
  font-weight: 700;
}

.message-search-handle {
  color: #425163;
  font-size: 0.86rem;
}

.message-search-email {
  color: #425163;
  font-size: 0.84rem;
  text-align: right;
}

.message-search-empty {
  padding: 0.5rem 0.6rem;
  color: #4f4f4f;
}

.conversation-item,
.message-item {
  padding: 0.35rem 0;
  margin: 0;
}

.message-item {
  position: relative;
  padding-right: 8.2rem;
}

.conversation-item + .conversation-item,
.message-item + .message-item {
  border-top: 1px solid #b9b9b9;
}

.conversation-link {
  display: inline-block;
  font-weight: 700;
  text-decoration: none;
}

.conversation-link:hover {
  text-decoration: underline;
}

.message-author {
  margin: 0 0 0.2rem;
  font-weight: 700;
  font-size: 0.82rem;
  color: #243242;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-body {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.35;
  color: #101820;
}

.message-preview {
  margin-top: 0.3rem;
}

.message-meta {
  margin: 0.28rem 0 0;
  font-size: 0.74rem;
  color: #5d6670;
}

.message-item .message-meta {
  position: absolute;
  right: 0;
  top: 0.4rem;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
}

.message-item:hover .message-meta,
.message-item:focus-within .message-meta {
  opacity: 1;
  visibility: visible;
}

.message-item.is-own {
  background: transparent;
  padding-left: 0.35rem;
  border-left: 3px solid #567692;
}

.message-empty {
  border: 1px dashed var(--line-soft);
  background: #ececec;
  color: #505050;
  padding: 0.55rem 0.65rem;
}

.content details:not(.tree-node) {
  border: 1px solid var(--line);
  background: #e6e6e6;
  margin-bottom: 0.85rem;
}

.content details:not(.tree-node) > summary {
  background: #d7d7d7;
  font-weight: 700;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  margin: 0;
}

.content details:not(.tree-node)[open] > summary {
  border-bottom: 1px solid var(--line-soft);
}

.content details:not(.tree-node) > form,
.content details:not(.tree-node) > div {
  margin: 0;
  padding: 0.65rem 0.75rem;
  background: #f2f2f2;
}

/* Task detail */
.task-detail-layout {
  display: grid;
  gap: 0.9rem;
}

.task-section {
  margin-bottom: 0.3rem;
}

.task-section h3 {
  margin-bottom: 0.45rem;
}

.task-meta-list {
  margin: 0;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.32rem 0.7rem;
}

.task-meta-list dt {
  margin: 0;
  font-weight: 700;
  color: #2d2d2d;
}

.task-meta-list dd {
  margin: 0;
}

.task-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-history-list li {
  padding: 0.45rem 0;
}

.task-history-list li + li {
  border-top: 1px solid #b9b9b9;
}

.task-history-transition {
  display: block;
  font-weight: 700;
}

.task-history-meta {
  display: block;
  margin-top: 0.1rem;
  color: #4f4f4f;
  font-size: 0.82rem;
}

.task-history-note {
  display: block;
  margin-top: 0.2rem;
  color: #2b2b2b;
}

/* Detail page layout */
.page-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.page-sidebar {
  background: #ededed;
  border: 1px solid var(--line);
  padding: 0.7rem;
  position: sticky;
  top: 0.75rem;
}

.page-main {
  min-width: 0;
}

.scope-tabs {
  display: inline-flex;
  gap: 0.4rem;
  margin: 0.5rem 0 1.15rem;
}

.scope-tab {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 0.28rem 0.65rem;
  text-decoration: none;
  color: var(--ink);
  background: #efefef;
  font-weight: 700;
  font-size: 0.85rem;
}

.scope-tab.is-active {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: #0d2948;
}

/* Sidebar tree */
.tree-list {
  list-style: square;
  margin: 0.35rem 0 0;
  padding: 0 0 0 1rem;
}

.tree-list li {
  margin: 0.25rem 0;
}

.tree-node > summary {
  margin-bottom: 0;
}

.tree-list a,
.tree-node > summary a {
  text-decoration: underline;
  color: #003f7f;
}

.is-current {
  font-weight: 700;
}

/* Kanban board */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-top: 1rem;
}

.kanban-col {
  background: #ebebeb;
  border: 1px solid var(--line);
  padding: 0.55rem;
  min-height: 200px;
}

.kanban-col-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.kanban-task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kanban-task {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  padding: 0.38rem 0.5rem;
  font-size: 0.85rem;
  border-left: 4px solid #cccccc;
}

.kanban-task.priority-low {
  border-left-color: #9db89d;
}

.kanban-task.priority-medium {
  border-left-color: #b3a86b;
}

.kanban-task.priority-high {
  border-left-color: #c39a67;
}

.kanban-task.priority-urgent {
  border-left-color: #c88080;
}

.kanban-task a {
  color: inherit;
  text-decoration: none;
}

.kanban-task a:hover {
  text-decoration: underline;
}

.kanban-empty {
  font-size: 0.8rem;
  color: #666666;
  margin: 0;
}

.page-shell section {
  margin-bottom: 1.8rem;
}

.page-shell details summary {
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.flash {
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  background-color: #ededed;
}

.flash-success {
  background-color: #dff0dc;
  border-color: #628a5f;
  color: #1d3a1b;
}

.flash-warning {
  background-color: #f6eed1;
  border-color: #9c8344;
  color: #4e3c10;
}

.flash-error {
  background-color: #f3d9d9;
  border-color: #965656;
  color: #4d1d1d;
}

.flash-info {
  background-color: #dde9f7;
  border-color: #5877a0;
  color: #1f3654;
}

.notification-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1200;
  width: min(360px, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.notification-toast {
  position: relative;
  background: #1c2f44;
  color: #f0f2f4;
  border: 1px solid #48617d;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
  padding: 0.65rem 2rem 0.7rem 0.75rem;
  transform: translateY(-8px);
  opacity: 0;
  animation: notification-toast-enter 180ms ease forwards;
  pointer-events: auto;
}

.notification-toast.is-leaving {
  animation: notification-toast-exit 180ms ease forwards;
}

.notification-toast-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #c8d8ea;
  margin-bottom: 0.2rem;
}

.notification-toast-body {
  font-size: 0.88rem;
  line-height: 1.25;
}

.notification-toast-close {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  border: 1px solid transparent;
  background: transparent;
  color: #d9e2ec;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}

.notification-toast-close:hover {
  border-color: #8aa4bf;
  background: rgba(255, 255, 255, 0.08);
}

@keyframes notification-toast-enter {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes notification-toast-exit {
  to {
    transform: translateY(-6px);
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .site-shell {
    margin: 0;
    border-left: 0;
    border-right: 0;
  }

  .page-shell {
    grid-template-columns: 1fr;
  }

  .page-sidebar {
    position: static;
  }

  .kanban {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .content {
    padding: 0.7rem;
  }

  .site-nav {
    padding: 0.6rem;
  }

  .site-nav a,
  .nav-user-trigger {
    font-size: 0.82rem;
    padding: 0.24rem 0.5rem;
  }

  .nav-user-menu {
    margin-left: 0;
  }

  .nav-user-dropdown {
    right: auto;
    left: 0;
  }

  .kanban {
    grid-template-columns: 1fr;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    max-width: 100%;
  }
}
