:root {
  color-scheme: light;
  --bg: #050506;
  --canvas: #f0eff6;
  --canvas-2: #f8f7fb;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-soft: #f3f2f7;
  --surface-hover: #faf9fd;
  --line: rgba(31, 32, 38, 0.08);
  --line-strong: rgba(31, 32, 38, 0.14);
  --text: #17171c;
  --muted: #85848e;
  --accent: #151518;
  --accent-strong: #000000;
  --lime: #e9ff63;
  --mint: #c8ead8;
  --aqua: #8adbd7;
  --blue: #5b70dd;
  --warning: #9c7000;
  --warning-soft: #fff8d8;
  --danger: #c94d42;
  --danger-soft: #fff0ee;
  --good-soft: #eaf8ef;
  --shadow: 0 24px 70px rgba(24, 25, 33, 0.1);
  --shadow-soft: 0 12px 32px rgba(24, 25, 33, 0.07);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(232, 239, 255, 0.28), transparent 24%),
    radial-gradient(circle at 78% 10%, rgba(229, 255, 99, 0.2), transparent 20%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
summary,
label {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1760px, calc(100vw - 42px));
  min-height: calc(100vh - 56px);
  margin: 28px auto;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(246, 245, 251, 0.92)),
    var(--canvas);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.32) inset,
    0 36px 100px rgba(0, 0, 0, 0.38);
  padding: 30px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 3vw, 52px);
  font-weight: 650;
  line-height: 1;
}

h2 {
  font-size: 18px;
  font-weight: 650;
}

.save-status {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 13px;
  font-weight: 560;
  padding: 0 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  max-width: 760px;
}

button,
.import-btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 680;
  padding: 9px 16px;
  box-shadow: var(--shadow-soft);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease,
    opacity 0.16s ease,
    box-shadow 0.16s ease;
}

button:hover,
.import-btn:hover {
  background: var(--accent-strong);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.14);
}

button:active,
.import-btn:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

button.ghost,
.import-btn {
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.64);
  color: var(--text);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 10px 26px rgba(24, 25, 33, 0.05);
}

button.ghost:hover,
.import-btn:hover {
  border-color: rgba(255, 255, 255, 0.9);
  background: var(--surface-solid);
  color: var(--text);
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 30px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(246, 245, 251, 0.94)),
    var(--canvas);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.34) inset,
    0 36px 100px rgba(0, 0, 0, 0.34);
  padding: 30px;
}

.auth-card h1 {
  font-size: 44px;
}

.auth-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.auth-field input {
  min-height: 50px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  outline: none;
  padding: 0 16px;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.auth-field input:focus {
  border-color: rgba(21, 21, 24, 0.28);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(21, 21, 24, 0.06);
}

.auth-error {
  min-height: 20px;
  margin: -2px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 680;
}

.app-shell.is-locked {
  display: none;
}

.import-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.import-btn input {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-grid article {
  position: relative;
  min-height: 124px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 20px 22px;
}

.summary-grid article::after {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(21, 21, 24, 0.055);
  content: "";
}

.summary-grid article:nth-child(1) {
  background: linear-gradient(150deg, #ffffff 0%, #eef0fb 100%);
}

.summary-grid article:nth-child(4),
.summary-grid article:nth-child(8) {
  background: linear-gradient(150deg, #ffffff 0%, var(--warning-soft) 100%);
}

.summary-grid article:nth-child(5) {
  background: linear-gradient(150deg, #ffffff 0%, var(--mint) 100%);
}

.summary-grid article:nth-child(7) {
  background: linear-gradient(150deg, #ffffff 0%, #edf9f7 100%);
}

.summary-grid span {
  display: block;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.3;
}

.summary-grid strong {
  position: relative;
  z-index: 1;
  display: block;
  max-width: calc(100% - 42px);
  overflow-wrap: normal;
  color: var(--text);
  font-size: clamp(28px, 2vw, 34px);
  font-weight: 640;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.projects-panel {
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 20px 22px 16px;
}

.controls-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(210px, 260px) minmax(170px, auto);
  gap: 12px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.38);
  padding: 14px 16px 16px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  outline: none;
  padding: 9px 15px;
  box-shadow: 0 8px 22px rgba(24, 25, 33, 0.045);
}

.field input::placeholder {
  color: #aaa8b1;
}

.field input:focus,
.field select:focus {
  border-color: rgba(21, 21, 24, 0.18);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(233, 255, 99, 0.35),
    0 10px 26px rgba(24, 25, 33, 0.07);
}

.column-menu {
  position: relative;
}

.column-menu summary {
  display: inline-flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  cursor: pointer;
  font-weight: 680;
  list-style: none;
  padding: 9px 15px;
  box-shadow: 0 8px 22px rgba(24, 25, 33, 0.045);
}

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

.column-menu[open] summary {
  border-color: rgba(21, 21, 24, 0.16);
  background: #fff;
}

.column-toggles {
  position: absolute;
  right: 0;
  z-index: 8;
  display: grid;
  width: 310px;
  max-height: 360px;
  overflow: auto;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 60px rgba(24, 25, 33, 0.16);
  padding: 8px;
}

.column-toggles label {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 9px;
  align-items: center;
  border-radius: 13px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 9px;
}

.column-toggles label:hover {
  background: var(--surface-soft);
}

.table-panel {
  overflow: hidden;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  background: rgba(255, 255, 255, 0.46);
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 390px);
}

table {
  width: 100%;
  min-width: 1760px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 54px;
  background: rgba(246, 245, 250, 0.94);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.15;
  text-align: left;
  white-space: normal;
  backdrop-filter: blur(12px);
}

td {
  height: 56px;
  background: rgba(255, 255, 255, 0.62);
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.94);
}

tbody tr:nth-child(even) td {
  background: rgba(250, 249, 253, 0.58);
}

tbody tr:nth-child(even):hover td {
  background: rgba(255, 255, 255, 0.96);
}

tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 3;
  border-top: 1px solid var(--line-strong);
  background: rgba(239, 244, 243, 0.96);
  font-weight: 760;
  backdrop-filter: blur(12px);
}

.project-col {
  width: 270px;
}

.action-col {
  width: 102px;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 270px;
  box-shadow: 1px 0 0 var(--line);
}

td.sticky-col {
  background: rgba(255, 255, 255, 0.92);
}

th.sticky-col {
  z-index: 6;
  background: rgba(246, 245, 250, 0.98);
}

tfoot .sticky-col {
  z-index: 5;
  background: rgba(239, 244, 243, 0.98);
}

td.project-name {
  min-width: 270px;
}

.sort-btn {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  padding: 9px 13px;
  text-align: left;
  white-space: normal;
}

.sort-btn:hover,
.sort-btn.active {
  background: rgba(233, 255, 99, 0.36);
  color: var(--text);
}

.sort-btn:active {
  transform: none;
}

input.cell-input,
select.cell-input,
.computed-cell {
  width: 100%;
  min-height: 55px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  padding: 9px 13px;
}

input.cell-input:focus,
select.cell-input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--lime);
}

input.cell-input.invalid {
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 2px var(--danger);
}

input.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.numeric-cell {
  min-width: 126px;
}

.status-cell {
  min-width: 112px;
  padding: 0 12px;
}

.status-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
  padding: 0 10px;
}

.status-badge.good {
  background: var(--good-soft);
  color: #29624a;
}

.status-badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.computed-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.computed-cell.negative {
  color: var(--danger);
  font-weight: 760;
}

.computed-cell.warning {
  color: var(--warning);
  font-weight: 760;
}

.warning-cell {
  background: rgba(255, 248, 216, 0.78);
}

.danger-cell {
  background: rgba(255, 240, 238, 0.82);
}

.row-risk .project-name {
  box-shadow:
    inset 4px 0 0 var(--lime),
    1px 0 0 var(--line);
}

.row-actions-cell {
  min-width: 102px;
  padding: 0 9px;
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.icon-btn {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
  color: var(--blue);
  font-size: 17px;
  padding: 0;
}

.icon-btn:hover {
  border-color: rgba(21, 21, 24, 0.08);
  background: #fff;
  color: var(--blue);
}

.icon-btn:active {
  transform: none;
}

.icon-btn.danger {
  color: var(--danger);
}

.icon-btn.danger:hover {
  border-color: rgba(201, 77, 66, 0.18);
  background: var(--danger-soft);
  color: var(--danger);
}

.muted-cell {
  color: var(--muted);
}

.empty-row td {
  height: 150px;
  color: var(--muted);
  font-weight: 650;
  text-align: center;
}

@media (max-width: 1320px) {
  .app-shell {
    width: min(100vw - 28px, 1760px);
    padding: 24px;
  }

  .page-header {
    gap: 18px;
  }

  .actions {
    max-width: 620px;
    gap: 8px;
  }

  button,
  .import-btn {
    min-height: 40px;
    padding: 8px 14px;
  }

  .summary-grid {
    gap: 12px;
  }

  .summary-grid article {
    min-height: 116px;
    padding: 18px;
  }

  .summary-grid strong {
    font-size: 28px;
  }

  table {
    min-width: 1580px;
  }

  .project-col,
  .sticky-col,
  td.project-name {
    min-width: 240px;
    width: 240px;
  }
}

@media (max-width: 1120px) {
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    max-width: none;
    justify-content: flex-start;
  }

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

  .summary-grid strong {
    font-size: 25px;
  }

  .controls-panel {
    grid-template-columns: minmax(260px, 1fr) minmax(190px, 240px) minmax(150px, auto);
  }

  .table-scroll {
    max-height: calc(100vh - 430px);
  }

  table {
    min-width: 1440px;
  }
}

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

  .summary-grid strong {
    font-size: 28px;
  }

  .controls-panel {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  table {
    min-width: 1320px;
  }
}

@media (max-width: 900px) {
  body {
    background:
      linear-gradient(180deg, #050506 0 78px, var(--canvas) 78px),
      var(--canvas);
  }

  .app-shell {
    width: calc(100vw - 12px);
    min-height: calc(100vh - 12px);
    margin: 6px auto;
    border-radius: 28px 28px 0 0;
    padding: 18px 14px 28px;
  }

  .page-header {
    gap: 14px;
    margin-bottom: 16px;
  }

  .actions {
    width: calc(100vw - 28px);
    overflow-x: auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 -2px;
    padding: 2px 2px 8px;
    scrollbar-width: none;
  }

  .actions::-webkit-scrollbar {
    display: none;
  }

  .actions > *,
  .import-btn {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 15px;
    white-space: nowrap;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }

  .summary-grid article {
    min-height: 112px;
    border-radius: 20px;
    padding: 16px;
  }

  .summary-grid article::after {
    right: 14px;
    bottom: 14px;
    width: 28px;
    height: 28px;
  }

  .summary-grid span {
    min-height: 28px;
    font-size: 12px;
  }

  .summary-grid strong {
    max-width: calc(100% - 28px);
    font-size: clamp(22px, 6.6vw, 28px);
  }

  .projects-panel {
    border-radius: 24px 24px 0 0;
  }

  .panel-head {
    padding: 18px 16px 14px;
  }

  .controls-panel {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .field input,
  .field select,
  .column-menu summary {
    min-height: 44px;
  }

  h1 {
    font-size: 38px;
  }

  .save-status {
    min-height: 32px;
    margin-top: 10px;
    font-size: 12px;
  }

  .table-scroll {
    max-height: 58vh;
  }

  table {
    min-width: 1240px;
  }

  .project-col,
  .sticky-col,
  td.project-name {
    min-width: 220px;
    width: 220px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: 18px 12px 28px;
  }

  .page-header {
    align-items: stretch;
  }

  .actions {
    width: 100%;
    overflow: visible;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
  }

  .actions > *,
  .import-btn {
    flex: 1 1 calc(33.333% - 8px);
    min-height: 38px;
    min-width: 108px;
    padding: 8px 14px;
    justify-content: center;
  }

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

  .summary-grid article {
    min-height: 104px;
    padding: 14px;
  }

  .summary-grid strong {
    font-size: clamp(20px, 6.1vw, 25px);
  }

  .controls-panel {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 34px;
  }

  .projects-panel {
    border-radius: 22px 22px 0 0;
  }

  .column-toggles {
    left: auto;
    right: 0;
    width: min(310px, calc(100vw - 24px));
  }

  .table-scroll {
    max-height: 56vh;
  }

  table {
    min-width: 1120px;
  }

  .project-col,
  .sticky-col,
  td.project-name {
    min-width: 190px;
    width: 190px;
  }

  th {
    height: 50px;
    font-size: 11px;
  }

  td {
    height: 52px;
  }

  .sort-btn,
  input.cell-input,
  select.cell-input,
  .computed-cell {
    min-height: 51px;
    padding: 8px 10px;
  }
}

@media (max-width: 380px) {
  .controls-panel {
    grid-template-columns: 1fr;
  }

  .summary-grid strong {
    font-size: 20px;
  }

  .summary-grid article {
    min-height: 98px;
    padding: 12px;
  }

  .actions > *,
  .import-btn {
    padding-inline: 12px;
  }
}

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

@media (min-width: 561px) and (max-width: 900px) {
  .actions {
    justify-content: flex-start;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    min-height: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .actions,
  .controls-panel,
  .save-status,
  .row-actions-cell,
  .action-col {
    display: none;
  }

  .summary-grid,
  .projects-panel {
    box-shadow: none;
  }

  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .table-scroll {
    max-height: none;
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 10px;
  }

  th,
  td,
  tfoot td,
  .sticky-col {
    position: static;
    box-shadow: none;
  }

  input.cell-input,
  select.cell-input,
  .computed-cell {
    min-height: 28px;
    padding: 4px;
  }
}
