:root {
  --card: #ffffff;
  --ink: #1b1f2a;
  --muted: #5f6b85;
  --line: #dbe2f1;
  --row-alt: #f9fbff;
  --axis: #2d3853;
  --accent: #1d4ed8;
  --bar-tech: #1f7a8c;
  --bar-ops: #2e4057;
  --bar-log: #b85c38;
  --bar-combo: #6a4c93;
  --bar-risk: #8f2d56;
  --cell: 28px;
  --left-col: 520px;
  --row-h: 36px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f5f7fb 0%, #edf2fb 100%);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid #c8d2e7;
  border-radius: 8px;
  padding: 8px 9px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
}

input[readonly] {
  background: #f3f4f6;
  color: #334155;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  min-height: 38px;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: #e6ebf6;
  color: #24324c;
}

.btn-danger {
  background: #fee2e2;
  color: #8f1d1d;
}

.app-shell {
  width: min(1500px, 96vw);
  margin: 20px auto 34px;
  display: grid;
  gap: 14px;
}

.app-header {
  background: linear-gradient(100deg, #e5edfc 0%, #f8fbff 100%);
  border: 1px solid #ced8eb;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 8px 26px rgba(31, 45, 70, 0.08);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: 20px;
  margin-bottom: 5px;
}

.app-header p {
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-bar {
  background: #fff;
  border: 1px solid #d4deef;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.dot.ops { background: var(--bar-ops); }
.dot.tech { background: var(--bar-tech); }
.dot.combo { background: var(--bar-combo); }
.dot.log { background: var(--bar-log); }
.dot.crit { background: var(--bar-risk); }

.panel {
  background: var(--card);
  border: 1px solid #d4deef;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(31, 45, 70, 0.07);
  display: grid;
  gap: 12px;
}

.briefing-panel {
  gap: 14px;
}

.briefing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.brief-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.brief-card h3 {
  font-size: 14px;
  color: #253553;
}

.brief-card p {
  color: #334155;
  font-size: 13px;
  line-height: 1.4;
}

.compact-list {
  margin: 0;
  padding-left: 17px;
  display: grid;
  gap: 4px;
  color: #334155;
  font-size: 13px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #1e3a8a;
}

.phase-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.phase-card {
  border: 1px solid #d5deee;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.phase-card h4 {
  margin: 0;
  font-size: 14px;
  color: #1f2d49;
}

.phase-card p {
  margin: 0;
  font-size: 13px;
  color: #3a4b69;
  line-height: 1.4;
}

.owner-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.owner-card {
  border: 1px solid #d5deee;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.owner-card h4 {
  margin: 0;
  font-size: 14px;
  color: #1f2d49;
}

.owner-card p {
  margin: 0;
  font-size: 13px;
  color: #3a4b69;
  line-height: 1.4;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  background: #fff;
  border: 1px solid #d5deee;
  border-radius: 10px;
  padding: 10px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  margin-top: 2px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.main-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 12px;
}

.task-form,
.filters {
  display: grid;
  gap: 10px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.critical-wrap {
  grid-template-columns: 18px 1fr;
  align-items: center;
  display: grid;
  gap: 8px;
  min-height: 38px;
  padding-top: 18px;
}

.critical-wrap input {
  min-height: 16px;
}

.form-buttons {
  display: flex;
  gap: 8px;
}

.gantt-wrapper {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.board {
  display: grid;
  grid-template-columns: var(--left-col) 1fr;
  min-width: 100%;
  width: max-content;
  background: #fff;
}

.left-head,
.axis {
  height: 96px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f7faff;
}

.left-head {
  border-right: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: flex-end;
  gap: 14px;
  font-weight: 700;
}

.left-head span:nth-child(1) { width: 64px; }
.left-head span:nth-child(2) { width: 245px; }
.left-head span:nth-child(3) { width: 110px; }

.axis {
  display: grid;
}

.axis-cell {
  border-left: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--axis);
}

.axis-cell.week {
  background: #edf3ff;
  border-left-width: 2px;
  font-weight: 700;
}

.axis-label {
  display: inline-block;
  transform: rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
  font-size: 10px;
}

.left-row {
  height: var(--row-h);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 64px 245px 110px 80px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
}

.left-row:nth-child(even) {
  background: var(--row-alt);
}

.task-id {
  font-weight: 700;
  color: #31425f;
}

.left-task,
.left-owner {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  width: fit-content;
}

.state-pill.todo { background: #e5e7eb; color: #334155; }
.state-pill.in_progress { background: #fef3c7; color: #92400e; }
.state-pill.blocked { background: #fee2e2; color: #991b1b; }
.state-pill.done { background: #dcfce7; color: #166534; }

.timeline-rows {
  position: relative;
}

.timeline-row {
  position: relative;
  height: var(--row-h);
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(
    to right,
    transparent calc(var(--cell) - 1px),
    var(--line) calc(var(--cell) - 1px)
  );
  background-size: var(--cell) 100%;
}

.timeline-row:nth-child(even) {
  background-color: #fcfdff;
}

.bar {
  position: absolute;
  top: 7px;
  height: 22px;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  line-height: 22px;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(11, 18, 32, 0.25);
  font-weight: 700;
}

.bar.blocked {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.2) 8px,
    rgba(255, 255, 255, 0.05) 8px,
    rgba(255, 255, 255, 0.05) 16px
  );
}

.bar.done {
  opacity: 0.66;
}

.today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #dc2626;
  z-index: 15;
}

.today-label {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  z-index: 16;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px;
  text-align: left;
  font-size: 12px;
}

th {
  background: #f7faff;
  color: #364866;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable::after {
  content: " ↕";
  color: #94a3b8;
  font-weight: 700;
}

th.sortable[data-dir="asc"]::after {
  content: " ▲";
  color: #1d4ed8;
}

th.sortable[data-dir="desc"]::after {
  content: " ▼";
  color: #1d4ed8;
}

td input,
td select {
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.cell-checkbox {
  width: 16px;
  height: 16px;
}

.activity-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.activity-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 7px 9px;
  font-size: 12px;
}

.activity-time {
  color: var(--muted);
  font-size: 11px;
}

.empty {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
}

@media (max-width: 1180px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .briefing-grid,
  .phase-board,
  .owner-grid,
  .stats-grid,
  .two-col,
  .three-col,
  .header-actions {
    grid-template-columns: 1fr;
  }

  .header-actions {
    width: 100%;
    display: grid;
    gap: 8px;
  }

  .left-row {
    grid-template-columns: 58px 200px 96px 72px;
  }

  :root {
    --left-col: 440px;
    --cell: 24px;
  }
}

@media (max-width: 600px) {
  :root {
    --left-col: 390px;
    --cell: 22px;
  }

  .app-shell {
    width: 95vw;
    margin-top: 12px;
  }

  .app-header h1 {
    font-size: 17px;
  }

  .left-head,
  .axis {
    height: 86px;
  }

  .left-row {
    grid-template-columns: 50px 176px 84px 66px;
    font-size: 11px;
    gap: 6px;
    padding: 5px 7px;
  }

  table {
    min-width: 700px;
  }
}
