:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --text: #172033;
  --muted: #697386;
  --border: #dbe3ee;
  --accent: #147a8c;
  --accent-strong: #0f6574;
  --accent-soft: #e3f4f6;
  --success: #1d8a5f;
  --warning: #b56a14;
  --danger: #b63b3b;
  --shadow: 0 14px 36px rgba(28, 44, 68, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  color: #31415c;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #0f1f2f;
  color: #e6eef7;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 24px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #aab8ca;
  font-size: 12px;
}

.brand-mark,
.nav-glyph {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  font-weight: 700;
}

.brand-mark {
  width: 38px;
  height: 38px;
  color: #0f1f2f;
  background: #77d1d8;
  box-shadow: inset 0 -8px 20px rgba(20, 122, 140, 0.26);
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  color: #c7d3e0;
  border-radius: 8px;
}

.side-link:hover,
.side-link.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-glyph {
  width: 24px;
  height: 24px;
  color: #7fd0db;
  background: rgba(127, 208, 219, 0.12);
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.2;
}

.topbar-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.account-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
}

.avatar-fallback {
  display: inline-grid;
  place-items: center;
  color: #0f1f2f;
  background: #c9edf0;
  font-weight: 700;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.icon-button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.dashboard-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-heading,
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2,
.detail-header h2,
.timeline-section h3 {
  margin: 0;
}

.panel-heading h2,
.detail-header h2 {
  font-size: 18px;
  line-height: 1.25;
}

.panel-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.inline-create {
  position: relative;
}

.inline-create summary {
  list-style: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.inline-create summary::-webkit-details-marker {
  display: none;
}

.compact-form,
.admin-form,
.detail-form {
  display: grid;
  gap: 12px;
}

.compact-form {
  position: absolute;
  right: 0;
  z-index: 5;
  width: min(560px, calc(100vw - 48px));
  margin-top: 10px;
  padding: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.span-2 {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 122, 140, 0.14);
}

.primary-button,
.secondary-button,
.danger-button,
.table-button {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.table-button {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--border);
}

.secondary-button:hover,
.table-button:hover {
  color: var(--accent);
  border-color: #a8dce2;
}

.danger-button {
  color: var(--danger);
  background: #fff2f2;
  border-color: #f0c4c4;
}

.danger-button:hover {
  background: #ffe6e6;
}

.full-width {
  display: grid;
  place-items: center;
  width: 100%;
}

.nav-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.nav-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.nav-card:hover {
  border-color: #a8dce2;
  box-shadow: 0 8px 18px rgba(20, 122, 140, 0.08);
}

.nav-card strong,
.nav-card small {
  display: block;
}

.nav-card small {
  max-width: 100%;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.link-icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.owner-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 6px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 6px;
  font-size: 11px;
}

.task-create {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(140px, 1fr) minmax(160px, 1fr) 120px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  max-width: 100%;
}

.kanban-column {
  flex: 1 0 190px;
  min-width: 190px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.kanban-column header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.kanban-column header span:last-child {
  margin-left: auto;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.status-todo {
  color: #315073;
  background: #dce9f7;
}

.status-progress {
  color: #8a4d08;
  background: #ffedd0;
}

.status-done {
  color: #0f6847;
  background: #d9f3e8;
}

.status-archived {
  color: #697386;
  background: #e8edf3;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-card {
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.task-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 122, 140, 0.1);
}

.task-card h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.task-card time,
.task-url {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.label-row span {
  padding: 2px 6px;
  color: #31415c;
  background: #edf2f7;
  border-radius: 6px;
  font-size: 11px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.quick-actions button {
  min-height: 25px;
  padding: 3px 6px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
}

.quick-actions button:hover {
  color: var(--accent);
  border-color: #a8dce2;
}

.detail-panel {
  position: sticky;
  top: 22px;
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 16px;
}

.detail-header h2 {
  margin-top: 8px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.timeline-section h3 {
  font-size: 15px;
}

.comment-form {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
}

.comment-form button {
  justify-self: end;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  padding-left: 12px;
  border-left: 3px solid #c8d8e8;
}

.timeline-item strong,
.timeline-item time,
.timeline-item p {
  display: block;
}

.timeline-item time {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-item p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.empty,
.empty-detail {
  color: var(--muted);
}

.empty-detail {
  display: grid;
  place-items: center;
  min-height: 340px;
  text-align: center;
}

.empty-detail h2 {
  margin: 0;
  color: var(--text);
}

.small {
  margin: 10px 0;
  font-size: 12px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f1f2f 0%, #164455 45%, #f6f8fb 45%);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  width: min(860px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-copy h1 {
  margin: 18px 0 8px;
  font-size: 32px;
  line-height: 1.15;
}

.login-copy p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.login-actions {
  display: grid;
  align-content: center;
  gap: 12px;
}

.alert {
  padding: 10px 12px;
  color: #8b2d2d;
  background: #fff1f1;
  border: 1px solid #f2c6c6;
  border-radius: 8px;
  font-size: 13px;
}

.alert-muted {
  color: #5a6575;
  background: #f5f7fa;
  border-color: var(--border);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr 2fr 0.7fr 88px 112px 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.delete-row {
  margin: -4px 0 10px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  white-space: nowrap;
}

.check-label input {
  width: 16px;
  min-height: 16px;
}

@media (max-width: 1380px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }

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

@media (max-width: 1040px) {
  .task-create {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-create button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .side-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .side-link {
    justify-content: center;
    min-width: 0;
    font-size: 12px;
  }

  .workspace {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .account {
    width: 100%;
    justify-content: space-between;
  }

  .panel-heading,
  .detail-header {
    flex-direction: column;
  }

  .compact-form,
  .admin-form,
  .detail-form,
  .task-create {
    position: static;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .kanban {
    width: 100%;
  }

  .kanban-column {
    flex-basis: 78vw;
  }

  .login-shell {
    background: var(--bg);
  }

  .login-panel {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .login-copy h1 {
    font-size: 28px;
  }
}
