:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --panel: #ffffff;
  --panel-2: #f1f1f1;
  --text: #151515;
  --muted: #666666;
  --line: #dedede;
  --brand: #ed1b2e;
  --brand-2: #1e1719;
  --accent: #ed1b2e;
  --danger: #b00020;
  --warn: #b76400;
  --ok: #267a3e;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #111111;
  color: #f5fbf7;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  padding: 4px 6px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #58a06d, #d4a241);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #102018;
}

.logo {
  width: 145px;
  height: 74px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  padding: 0;
  flex: 0 0 auto;
}

.login-logo {
  width: min(410px, 100%);
  height: auto;
  display: block;
  object-fit: contain;
  margin: 0 auto 12px;
}

.login-wordmark {
  width: 100%;
  color: #050505;
  line-height: 1;
  margin: 0 0 18px;
  overflow: visible;
}

.login-wordmark div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.login-wordmark span {
  color: var(--brand);
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 54px;
  font-style: italic;
  font-weight: 900;
}

.login-wordmark strong {
  color: #050505;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 42px;
  font-style: italic;
  font-weight: 900;
}

.login-wordmark em {
  display: block;
  color: #050505;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 64px;
  font-style: italic;
  font-weight: 900;
  margin-top: 10px;
  white-space: nowrap;
}

.brand strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.brand span {
  color: #b8c9be;
  font-size: 12px;
}

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

.sidebar-back {
  width: 34px;
  height: 34px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  align-self: flex-start;
  margin: -8px 0 -2px 4px;
  padding: 0;
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.sidebar-back:hover,
.sidebar-back:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: #ffffff;
}

.nav button {
  color: #dbe8df;
  background: transparent;
  text-align: left;
  border-radius: 7px;
  padding: 11px 12px;
}

.nav button.active,
.nav button:hover {
  background: rgba(237, 27, 46, 0.2);
  color: #ffffff;
}

.session {
  margin-top: auto;
  color: #b8c9be;
  font-size: 13px;
  display: grid;
  gap: 10px;
}

.session button,
.secondary {
  color: #ffffff;
  background: var(--brand);
  border-radius: 7px;
  padding: 9px 12px;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.subtle {
  color: var(--muted);
  margin: 6px 0 0;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary,
.danger,
.ghost {
  min-height: 38px;
  border-radius: 7px;
  padding: 9px 13px;
  white-space: nowrap;
}

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

.primary:hover,
.session button:hover {
  background: #c81020;
}

.danger {
  color: #fff;
  background: var(--danger);
}

.ghost {
  color: var(--brand-2);
  background: transparent;
  border: 1px solid var(--line);
}

.grid {
  display: grid;
  gap: 16px;
}

.kpis {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  padding: 18px;
  color: var(--text);
  text-align: left;
  display: grid;
  gap: 12px;
}

.project-card:hover {
  border-color: var(--brand);
}

.project-summary {
  display: grid;
  gap: 16px;
}

.project-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px 22px;
}

.project-detail-grid > div {
  min-width: 0;
}

.project-detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.project-detail-grid .wide-detail {
  grid-column: 1 / -1;
}

.summary-progress {
  margin-top: 2px;
}

.risk-section {
  min-height: 0;
}

.project-card-main {
  color: inherit;
  background: transparent;
  text-align: left;
  display: grid;
  gap: 12px;
  padding: 0;
}

.project-delete {
  justify-self: start;
}

.project-card strong {
  display: block;
  font-size: 18px;
}

.project-card span {
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.section {
  padding: 18px;
}

.section h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
}

.filters {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(150px, 0.6fr));
  gap: 10px;
  margin-bottom: 14px;
}

.project-filters {
  margin-bottom: 0;
  grid-template-columns: minmax(220px, 1.4fr) minmax(120px, 0.5fr) minmax(150px, 0.6fr) minmax(150px, 0.6fr) auto;
  align-items: end;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
}

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

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

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

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

th {
  background: var(--panel-2);
  color: #252525;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:hover td {
  background: #fbfcfa;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-completed {
  background: #e1f3e6;
  color: #176a32;
}

.status-in-progress {
  background: #eeeeee;
  color: #111111;
}

.status-not-started {
  background: #f4f4f4;
  color: #555555;
}

.status-blocked,
.status-overdue {
  background: #f9dedc;
  color: #963b37;
}

.status-at-risk {
  background: #faedcf;
  color: #8a5c11;
}

.two-col {
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.report-actions {
  align-self: end;
}

.date-range-filter {
  display: grid;
  gap: 6px;
  color: #33423a;
  font-size: 13px;
  font-weight: 700;
}

.date-range-menu {
  position: relative;
}

.date-range-menu summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 10px 11px;
  min-height: 42px;
}

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

.date-range-menu summary::before {
  content: "▣ ";
  color: var(--muted);
}

.date-range-menu summary::after {
  content: "⌄";
  float: right;
  color: var(--muted);
}

.date-range-menu[open] summary::after {
  content: "⌃";
}

.date-range-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, 82vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  padding: 8px;
}

.date-option {
  display: grid;
  grid-template-columns: 0 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 7px;
  color: #33423a;
  font-weight: 600;
}

.date-option input {
  opacity: 0;
  width: 0;
  height: 0;
  padding: 0;
}

.date-option:has(input:checked) {
  background: #eef5fb;
  color: var(--brand);
}

.date-custom {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding: 12px 8px 6px;
  display: grid;
  gap: 8px;
}

.date-custom > span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.date-custom > div {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}

label {
  display: grid;
  gap: 6px;
  color: #33423a;
  font-size: 13px;
  font-weight: 700;
}

.label-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.help-tip {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--brand);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
  cursor: help;
  text-transform: none;
}

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

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 0, 0, 0.86), rgba(36, 0, 4, 0.82)),
    radial-gradient(circle at 25% 20%, rgba(237, 27, 46, 0.46), transparent 34%),
    linear-gradient(135deg, #151515 0%, #2b2b2b 52%, #ed1b2e 100%);
  background-size: cover;
}

.login-panel {
  width: min(440px, 100%);
  background: #ffffff;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

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

.login-panel form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

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

.row-actions button {
  padding: 7px 9px;
  border-radius: 6px;
  background: #edf2ed;
  color: var(--brand-2);
}

.row-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.draft-table td {
  vertical-align: top;
}

.table-input {
  width: 100%;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  font: inherit;
  background: #fff;
}

textarea.table-input {
  min-height: 68px;
  resize: vertical;
}

.link-button {
  padding: 0;
  color: var(--brand-2);
  background: transparent;
  font-weight: 800;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
}

.link-button:hover,
.link-button:focus {
  color: var(--brand);
  text-decoration-color: currentColor;
}

.notice {
  border-left: 4px solid var(--accent);
  padding: 12px;
  background: #fff8e9;
  color: #5b4218;
  border-radius: 6px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}

.modal {
  width: min(460px, 100%);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.modal h2 {
  margin: 0;
}

.app-modal {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 8px;
  border-top: 5px solid var(--brand);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  padding: 24px;
}

.app-modal h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.modal-message {
  color: var(--muted);
  line-height: 1.45;
}

.modal-input-label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  font-weight: 800;
}

.modal-input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  font: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.document-viewer-overlay {
  z-index: 40;
  padding: 14px;
}

.document-viewer {
  width: min(1280px, 100%);
  height: min(860px, calc(100vh - 28px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.document-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.document-viewer-head h2 {
  margin: 0;
  font-size: 18px;
}

.document-frame {
  min-height: 0;
  background: #f7f7f7;
}

.document-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.document-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #222222;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e1e7e2;
  overflow: hidden;
}

.bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

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

  .kpis,
  .two-col,
  .project-detail-grid,
  .filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }
}
