:root {
  --md-bg: #f3f6fc;
  --md-surface: #ffffff;
  --md-surface-2: #edf2ff;
  --md-text: #1b1d23;
  --md-muted: #5f636e;
  --md-primary: #1967d2;
  --md-primary-dark: #174ea6;
  --md-outline: #d2d8e5;
  --md-shadow: 0 8px 24px rgba(25, 103, 210, 0.12);
  --md-radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  color: var(--md-text);
  background:
    radial-gradient(circle at top left, #e5eeff 0%, transparent 40%),
    radial-gradient(circle at bottom right, #e8f0ff 0%, transparent 45%),
    var(--md-bg);
}

.container {
  width: min(1320px, 100% - 2rem);
  margin: 1.5rem auto;
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: 22px;
  padding: 1.2rem;
  box-shadow: var(--md-shadow);
}

.hero {
  padding: 0.6rem 0.2rem 0.8rem;
}

.team-label {
  margin: 0;
  color: var(--md-primary-dark);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.hero h1 {
  margin: 0.25rem 0 0;
  font-size: 1.7rem;
  color: #0f274f;
}

.hero p {
  margin: 0.35rem 0 0;
  color: var(--md-muted);
}

.tabs {
  display: inline-flex;
  gap: 0.35rem;
  margin-top: 0.9rem;
  padding: 0.25rem;
  background: #e9effe;
  border-radius: 999px;
}

.tab {
  border: 0;
  background: transparent;
  color: #1d4d9e;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab:hover {
  background: #dce7ff;
  color: #133f85;
}

.tab.active {
  background: #fff;
  box-shadow: 0 2px 8px rgba(16, 80, 170, 0.18);
  color: #0f3f86;
}

.tab.active:hover {
  background: #fff;
  color: #0f3f86;
}

.panel {
  display: none;
  margin-top: 1rem;
}

.panel.active {
  display: block;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0.9rem 0;
  padding: 0.7rem;
  background: var(--md-surface-2);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius);
}

.controls-top {
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.tools-panel {
  margin-top: 0.75rem;
}

.tools-panel > summary {
  cursor: pointer;
  color: #214b92;
  font-weight: 600;
  padding: 0.2rem 0.1rem;
}

.scrum-rotation {
  align-items: center;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  padding-top: 0.8rem;
  padding-bottom: 0.7rem;
  background: linear-gradient(180deg, #eef3ff 0%, #e8efff 100%);
}

.rotation-head {
  display: grid;
  gap: 0.2rem;
  grid-column: 1 / -1;
}

.rotation-label {
  display: block;
  color: #254b90;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}

.rotation-help {
  display: block;
  color: #4e6798;
  font-size: 0.8rem;
  line-height: 1.35;
}

#scrumRotationInput {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
  border: 1px solid #bcc7dd;
  background: #fff;
  border-radius: 12px;
  color: #1a1f2b;
  padding: 0.58rem 0.65rem;
  font: inherit;
  resize: vertical;
  min-height: 60px;
}

#scrumRotationInput:focus {
  outline: 2px solid #bad0f7;
  border-color: #6e95df;
}

.rotation-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: flex-end;
}

.rotation-shift {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px auto;
  gap: 0.55rem;
  align-items: center;
}

.rotation-shift input {
  width: 100%;
}

.fill-from-block {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid #cbd8f3;
  border-radius: 12px;
  background: #f6f9ff;
}

.fill-from-label {
  color: #214b92;
  font-weight: 600;
  font-size: 0.88rem;
}

.fill-from-help {
  color: #4f6492;
  font-size: 0.77rem;
}

.fill-from-controls {
  display: grid;
  grid-template-columns: 170px auto;
  gap: 0.55rem;
  align-items: center;
  justify-content: end;
  width: fit-content;
  margin-left: auto;
}

.fill-from-controls input {
  width: 170px;
}

.year-filter {
  display: inline-grid;
  grid-template-columns: auto minmax(114px, auto);
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.2rem 0.28rem 0.2rem 0.5rem;
  background: #fff;
  border: 1px solid #c8d5ee;
  border-radius: 12px;
  font-size: 0.9rem;
  color: #254b90;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 8px rgba(30, 86, 168, 0.05);
}

.year-filter > span {
  display: flex;
  align-items: center;
  height: auto;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #3f5f99;
}

.year-filter select,
button,
.button-link,
.import-label,
.task-add-btn,
.jira-edit-btn,
input,
select {
  font: inherit;
}

.year-filter select,
input,
select {
  border: 1px solid #bcc7dd;
  background: #fff;
  border-radius: 10px;
  color: #1a1f2b;
  padding: 0.42rem 0.55rem;
}

.year-filter select {
  min-width: 116px;
  height: 34px;
  margin: 0;
  padding-right: 2rem;
  font-size: 0.96rem;
  font-weight: 500;
  border-radius: 9px;
  border-color: #9fb8e4;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #2d64ab 50%),
    linear-gradient(135deg, #2d64ab 50%, transparent 50%),
    linear-gradient(#f7faff, #eef4ff);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px),
    0 0;
  background-size: 5px 5px, 5px 5px, 100% 100%;
  background-repeat: no-repeat;
}

.controls-top .button-link {
  margin-left: auto;
}

button,
.button-link,
.import-label,
.task-add-btn,
.jira-edit-btn {
  border: 1px solid var(--md-primary);
  background: var(--md-primary);
  color: #fff;
  padding: 0.48rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

button:hover,
.button-link:hover,
.import-label:hover,
.task-add-btn:hover,
.jira-edit-btn:hover {
  background: var(--md-primary-dark);
  border-color: var(--md-primary-dark);
}

button:disabled,
.task-add-btn:disabled,
.jira-edit-btn:disabled {
  background: #eef1f7 !important;
  border-color: #cad4e4 !important;
  color: #8793a8 !important;
  cursor: not-allowed;
}

#importScrumInput {
  position: absolute;
  left: -9999px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius);
  background: #fff;
}

.scrum-wrap {
  max-height: 66vh;
}

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

th,
td {
  border-bottom: 1px solid #e4e9f4;
  padding: 0.62rem 0.58rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f2f6ff;
  color: #1b3f84;
  font-weight: 700;
  line-height: 1.2;
  vertical-align: middle;
  position: sticky;
  top: 0;
  z-index: 1;
}

td input,
td select {
  width: 100%;
}

.locked-date {
  background: #f3f6fd;
  color: #1f3f77;
  border-color: #c7d3ea;
  opacity: 1;
}

.support-row td {
  background: #fff;
  border-top: 3px solid #cfdbf7;
}

.week-cell {
  min-width: 170px;
  background: #fff !important;
}

.tasks-wrap {
  display: grid;
  gap: 0.55rem;
  min-width: 560px;
}

.tasks-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.count-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid #c5d4f3;
  border-radius: 999px;
  background: #edf3ff;
  color: #294f92;
  font-size: 0.82rem;
}

.task-card {
  border: 1px solid #d7e0f0;
  border-left-width: 6px;
  border-radius: 12px;
  padding: 0.5rem;
  background: #f9fbff;
}

.task-grid {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: minmax(240px, 1fr) 150px auto;
  align-items: center;
}

.task-add-btn {
  justify-self: start;
}

.task-delete-btn {
  border: 1px solid #c83a3a;
  background: #fff;
  color: #c83a3a;
}

.task-delete-btn:hover {
  background: #c83a3a;
  color: #fff;
}

.jira-field {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.jira-field.jira-linked {
  width: fit-content;
}

.jira-field input {
  width: 100%;
}

.jira-link {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  border: 1px solid #adc6f2;
  background: #eef4ff;
  color: #2456a8;
  text-decoration: underline;
  font-weight: 600;
  padding: 0 0.55rem;
  border-radius: 8px;
}

.jira-edit-btn {
  background: #fff;
  color: #2456a8;
  border-color: #2456a8;
  padding: 0.28rem 0.45rem;
}

.jira-edit-btn:hover {
  background: #dfeafc;
  color: #0e3f8a;
  border-color: #0e3f8a;
}

.jira-popover {
  position: fixed;
  z-index: 999;
  width: min(360px, calc(100vw - 1rem));
  background: #fff;
  border: 1px solid #c4d6f8;
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(19, 54, 120, 0.22);
  padding: 0.7rem;
}

.jira-popover.hidden {
  display: none;
}

.import-success-popup {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 64, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.import-success-popup.hidden {
  display: none;
}

.import-success-card {
  width: min(420px, calc(100vw - 1.5rem));
  background: #fff;
  border: 1px solid #c8d6f5;
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(19, 54, 120, 0.22);
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.5rem;
}

.import-success-card strong {
  color: #1b4e95;
}

.import-success-card span {
  color: #304f84;
}

.import-success-card button {
  justify-self: end;
}

.jira-popover label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: #294f92;
  margin-bottom: 0.35rem;
}

.jira-popover input {
  width: 100%;
  margin-bottom: 0.55rem;
}

.jira-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.secondary-btn {
  border: 1px solid #9bb7e9;
  background: #f5f8ff;
  color: #274a8b;
}

.secondary-btn:hover {
  background: #eaf1ff;
  color: #173a7d;
  border-color: #173a7d;
}

.toggle-btn.is-active {
  background: var(--md-primary);
  border-color: var(--md-primary);
  color: #fff;
}

.toggle-btn:disabled {
  background: #eef1f7;
  border-color: #cad4e4;
  color: #8793a8;
  cursor: not-allowed;
}

.current-week-row td {
  background: linear-gradient(180deg, #e9f2ff 0%, #dceaff 100%) !important;
  border-top: 2px solid #2f75b5 !important;
  border-bottom: 2px solid #2f75b5 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(20, 63, 122, 0.2);
}

.current-week-row td:first-child {
  border-left: 5px solid #2f75b5 !important;
}

.current-week-row td:last-child {
  border-right: 2px solid #2f75b5 !important;
}

.current-week-row .locked-date {
  font-weight: 700;
  color: #143f7a;
  border-color: #2f75b5;
  background: #f2f7ff;
}

.status-assigned { border-left-color: #b4c6e7; }
.status-investigating { border-left-color: #ffc000; }
.status-requestingclientapproval { border-left-color: #aeaaaa; }
.status-movedasdefectenhancement { border-left-color: #ff0000; }
.status-notanissue { border-left-color: #92d050; }
.status-handover { border-left-color: #ffff00; }
.status-installation { border-left-color: #f4b084; }
.status-performanceissues { border-left-color: #e7e6e6; }
.status-onholdblocked { border-left-color: #00b0f0; }
.status-codereview { border-left-color: #7030a0; }
.status-solved { border-left-color: #92d050; }
.status-enhancement { border-left-color: #ff0000; }

.jira-link.status-assigned { border-color: #b4c6e7; color: #324b75; background: #edf2fb; }
.jira-link.status-investigating { border-color: #ffc000; color: #6f5300; background: #fff6db; }
.jira-link.status-requestingclientapproval { border-color: #aeaaaa; color: #4f4a4a; background: #f2f1f1; }
.jira-link.status-movedasdefectenhancement { border-color: #ff0000; color: #8f0000; background: #ffe8e8; }
.jira-link.status-notanissue { border-color: #92d050; color: #335d12; background: #edf8e0; }
.jira-link.status-handover { border-color: #ffff00; color: #746d00; background: #fffdda; }
.jira-link.status-installation { border-color: #f4b084; color: #7b4e33; background: #fff1e8; }
.jira-link.status-performanceissues { border-color: #e7e6e6; color: #545454; background: #f7f7f7; }
.jira-link.status-onholdblocked { border-color: #00b0f0; color: #005f81; background: #e1f6ff; }
.jira-link.status-codereview { border-color: #7030a0; color: #4a206a; background: #f2e9fa; }
.jira-link.status-solved { border-color: #92d050; color: #335d12; background: #edf8e0; }
.jira-link.status-enhancement { border-color: #ff0000; color: #8f0000; background: #ffe8e8; }

.status {
  min-height: 1.2rem;
  margin-top: 0.8rem;
  color: #2a4f86;
  font-weight: 500;
}

@media (max-width: 900px) {
  .controls-top {
    justify-content: flex-start;
  }
  .controls-top .button-link {
    margin-left: 0;
  }
  .year-filter {
    width: 100%;
    grid-template-columns: auto 1fr;
  }
  .year-filter select {
    min-width: 0;
    width: 100%;
  }
  #scrumRotationInput {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }
  .rotation-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .rotation-shift {
    grid-template-columns: 1fr;
  }
  .fill-from-controls {
    grid-template-columns: 1fr;
    justify-content: stretch;
    width: 100%;
    margin-left: 0;
  }
  .fill-from-controls input {
    width: 100%;
  }
  .task-grid {
    grid-template-columns: 1fr;
  }
}
