:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --panel: #ffffff;
  --soft: #f5f8fc;
  --brand: #0f5e8c;
  --good: #167044;
  --warn: #b45f06;
  --bad: #b42318;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: #eef3f8;
}

.home-shell .eyebrow,
.login-card .eyebrow { margin: 0 0 3px; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; }
button, .item-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.primary, .item-link { background: var(--brand); color: #fff; border-color: var(--brand); }
.home-shell { max-width: 1280px; margin: 0 auto; padding: 24px; }
.login-panel { display: grid; place-items: center; min-height: 60vh; padding: 24px; }
.login-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 24px rgba(23, 32, 51, .06);
}
.login-card { width: min(420px, 100%); }
.field { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); font-size: 14px; }
input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: inherit; }
.muted, .hint { color: var(--muted); }
#feedback { margin: 16px auto 0; max-width: 1100px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#feedback.error { border-color: #f3b4ae; color: var(--bad); }

.home-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.metric strong { display: block; font-size: 28px; margin-bottom: 4px; }
.training-banner {
  margin-bottom: 18px;
  padding: 14px 16px;
  color: #184532;
  background: #e9f6ef;
  border: 1px solid #b8dcc8;
  border-left: 5px solid var(--good);
  border-radius: 8px;
}
.training-banner p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.home-main { display: grid; gap: 16px; min-width: 0; }
.home-side { min-width: 0; }
.item-list { display: grid; gap: 10px; }
.work-item { display: grid; gap: 9px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--brand); border-radius: 8px; padding: 14px; }
.work-item.urgent, .work-item.high { border-left-color: var(--bad); }
.work-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.work-top h3 { margin-bottom: 4px; font-size: 17px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--ink); }
.badge.good { color: var(--good); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.project-overview { overflow: hidden; }
.project-table, .source-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.project-table th:nth-child(1), .project-table td:nth-child(1) { width: 30%; }
.project-table th:nth-child(2), .project-table td:nth-child(2) { width: 31%; }
.project-table th:nth-child(3), .project-table td:nth-child(3) { width: 27%; }
.project-table th:nth-child(4), .project-table td:nth-child(4) { width: 12%; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 8px; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
td { overflow-wrap: anywhere; }
.source-warnings { margin-top: 0; }
.source-table th { width: 48%; }
.source-table th, .source-table td { padding: 9px 0; }
.empty { color: var(--muted); background: var(--soft); border-radius: 8px; padding: 16px; }
.follow-guide { margin: 0 0 18px; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.follow-guide summary, .follow-controls summary, .follow-history summary { cursor: pointer; font-weight: 600; padding: 5px 0; }
.follow-flow { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 18px; padding: 12px 0 0 18px; }
.follow-flow span { display: block; color: var(--muted); margin-top: 5px; font-size: 13px; }
.follow-summary { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.follow-blocker, .follow-pending { padding: 10px 12px; background: #fff6e8; border-left: 3px solid #bf8019; margin: 0; border-radius: 4px; overflow-wrap: anywhere; }
.follow-controls { padding-top: 2px; }
.follow-controls form { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0; }
.follow-controls select, .follow-controls textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; font: inherit; color: var(--ink); background: white; }
.follow-controls .hint { font-size: 12px; }
.follow-check { display: flex; gap: 8px; align-items: center; padding: 8px 0 14px; }
.follow-check input { width: 17px; height: 17px; }
.follow-history { font-size: 13px; color: var(--muted); }
.follow-history ol { max-height: 260px; overflow-y: auto; padding-left: 20px; }
.follow-history li { margin: 8px 0; overflow-wrap: anywhere; }
.follow-feedback.error { color: var(--bad); }
@media(max-width:900px) { .follow-flow { grid-template-columns: 1fr; gap: 12px; } }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
  .home-side { display: grid; grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .home-head { display: grid; justify-items: start; }
  .metrics, .grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .home-shell { padding: 18px 14px 48px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-table, .project-table thead, .project-table tbody, .project-table tr, .project-table th, .project-table td { display: block; width: 100%; }
  .project-table thead { display: none; }
  .project-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .project-table tr:last-child { border-bottom: 0; }
  .project-table td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; border-bottom: 0; padding: 5px 0; }
  .project-table td::before { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
  .project-table td:nth-child(1)::before { content: "Project"; }
  .project-table td:nth-child(2)::before { content: "Company stage"; }
  .project-table td:nth-child(3)::before { content: "Schedule"; }
  .project-table td:nth-child(4)::before { content: "Finance"; }
}

@media (max-width: 520px) {
  .metrics { grid-template-columns: 1fr; }
  .project-table td { grid-template-columns: 1fr; gap: 3px; }
}
