:root {
  color-scheme: dark;
  --black: #000;
  --surface: #050505;
  --surface-raised: #090909;
  --border: #2b3038;
  --border-strong: #3a414b;
  --yellow: #fff500;
  --red: #ff2b2b;
  --white: #fff;
  --muted: #9298a1;
  --soft: #5f6670;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--black);
  color: var(--white);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, select { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(255, 245, 0, 0.5);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.topbar {
  width: min(1600px, calc(100% - 64px));
  margin: 0 auto;
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.brand-logo-wrap {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}

#brandLogo {
  display: block;
  width: 66px;
  height: 66px;
  filter:
    drop-shadow(1px 0 0 #fff)
    drop-shadow(-1px 0 0 #fff)
    drop-shadow(0 1px 0 #fff)
    drop-shadow(0 -1px 0 #fff);
}

.brand-divider {
  width: 1px;
  height: 56px;
  background: var(--border-strong);
}

.brand-title {
  color: var(--yellow);
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.95;
  font-weight: 950;
  letter-spacing: -0.045em;
}

.sync-area {
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: right;
}

.sync-label {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  letter-spacing: 0.03em;
}

.sync-time { color: var(--muted); margin-top: 5px; font-size: 0.9rem; }

.live-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--soft);
}

.live-dot.online {
  background: var(--yellow);
  box-shadow: 0 0 15px rgba(255, 245, 0, 0.8);
}

.live-dot.error {
  background: var(--red);
  box-shadow: 0 0 15px rgba(255, 43, 43, 0.7);
}

.refresh-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--white);
}

.refresh-button:hover:not(:disabled) { border-color: var(--yellow); color: var(--yellow); }
.refresh-button:disabled { opacity: 0.38; cursor: default; }
.refresh-button.loading svg { animation: spin 0.8s linear infinite; }
.refresh-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main {
  width: min(1600px, calc(100% - 64px));
  margin: 0 auto 64px;
}

.setup-panel {
  min-height: min(650px, calc(100vh - 190px));
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 245, 0, 0.08), transparent 34%),
    var(--surface);
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(320px, 1.3fr);
  align-items: center;
  padding: clamp(32px, 7vw, 110px);
  gap: clamp(36px, 8vw, 130px);
}

.setup-mark { color: var(--yellow); display: grid; place-items: center; }
.setup-mark svg { width: min(230px, 55vw); fill: currentColor; }
.eyebrow { color: var(--yellow); font-weight: 850; letter-spacing: 0.14em; }
.setup-content h1 { font-size: clamp(2.2rem, 5vw, 5rem); margin: 10px 0 18px; letter-spacing: -0.05em; }
.setup-description { max-width: 680px; color: #c8ccd2; line-height: 1.65; font-size: 1.05rem; }
.token-form { margin-top: 36px; }
.token-form label { display: block; margin-bottom: 10px; font-weight: 750; }
.token-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; }

input, select {
  color: var(--white);
  border: 1px solid var(--border-strong);
  background: var(--black);
  border-radius: 8px;
}

input::placeholder { color: #777e87; }
.token-row input { min-width: 0; padding: 15px 16px; }

.primary-button {
  border: 1px solid var(--yellow);
  background: var(--yellow);
  color: var(--black);
  padding: 0 24px;
  border-radius: 8px;
  font-weight: 950;
  letter-spacing: 0.04em;
}

.primary-button:hover { background: #fff94d; }
.primary-button:disabled { opacity: 0.6; cursor: wait; }
.form-message { min-height: 24px; margin: 12px 0 0; color: var(--muted); }
.form-message.error { color: var(--red); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card, .panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
}

.kpi-card {
  min-height: 158px;
  padding: 22px 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.kpi-card h2 { margin: 3px 0 0; font-size: clamp(1rem, 1.6vw, 1.45rem); }
.kpi-number { display: block; color: var(--yellow); font-size: clamp(3.25rem, 5vw, 5rem); font-weight: 950; line-height: 0.95; letter-spacing: -0.05em; }
.kpi-number.red { color: var(--red); text-shadow: 0 0 18px rgba(255, 43, 43, 0.34); }
.kpi-note { margin: 5px 0 0; color: var(--muted); font-size: 0.78rem; }
.kpi-icon { width: 56px; flex: 0 0 auto; fill: none; stroke: #717780; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mini-ring { width: 64px; height: 64px; border-radius: 50%; position: relative; background: conic-gradient(var(--yellow) 0 0%, #3b3f46 0); }
.mini-ring::after { content: ""; position: absolute; inset: 9px; background: var(--surface); border-radius: 50%; }

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(360px, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.panel { padding: 24px 26px; }
.panel h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.65rem); letter-spacing: -0.025em; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 22px; color: #d5d8dd; font-size: 0.88rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 9px; }
.legend-line { width: 38px; height: 3px; display: inline-block; background: var(--yellow); }
.legend-line.expected { height: 2px; background: repeating-linear-gradient(90deg, #fff 0 8px, transparent 8px 14px); }
.trend-chart { min-height: 250px; margin-top: 12px; }
.trend-chart svg { width: 100%; height: 250px; overflow: visible; }
.grid-line { stroke: #252a31; stroke-width: 1; stroke-dasharray: 4 5; }
.axis-label { fill: #a5abb3; font-size: 12px; }
.actual-path { fill: none; stroke: var(--yellow); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.expected-path { fill: none; stroke: #fff; stroke-width: 2; stroke-dasharray: 7 7; stroke-linecap: round; opacity: 0.9; }
.actual-point { fill: var(--yellow); }
.expected-point { fill: #fff; }
.chart-empty { min-height: 250px; display: grid; place-items: center; color: var(--muted); text-align: center; }

.status-panel { min-height: 326px; }
.status-layout { display: grid; grid-template-columns: minmax(150px, 0.85fr) minmax(185px, 1.15fr); align-items: center; gap: 28px; height: calc(100% - 34px); }
.donut { width: min(190px, 100%); aspect-ratio: 1; margin: 0 auto; border-radius: 50%; position: relative; background: conic-gradient(var(--yellow) 0 0%, var(--red) 0 0%, #adb1b8 0 100%); }
.donut::after { content: ""; position: absolute; inset: 34px; border-radius: 50%; background: var(--surface); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; z-index: 1; }
.donut-center strong { font-size: 2.8rem; line-height: 0.95; }
.donut-center span { color: var(--muted); }
.status-legend { display: grid; gap: 20px; }
.status-legend div { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 12px; }
.status-legend strong { font-size: 1.05rem; }
.legend-dot { width: 14px; height: 14px; border-radius: 50%; }
.legend-dot.yellow { background: var(--yellow); box-shadow: 0 0 10px rgba(255, 245, 0, 0.28); }
.legend-dot.red { background: var(--red); box-shadow: 0 0 10px rgba(255, 43, 43, 0.32); }
.legend-dot.gray { background: #adb1b8; }

.workload-panel { margin-top: 16px; }
.workload-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }
.legend-block { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-block.on-time, .workload-segment.on-time { background: var(--yellow); }
.legend-block.overdue, .workload-segment.overdue { background: var(--red); }
.legend-block.no-date, .workload-segment.no-date { background: #adb1b8; }
.workload-chart { display: grid; gap: 14px; margin-top: 24px; }
.workload-row { display: grid; grid-template-columns: minmax(130px, 220px) minmax(180px, 1fr) 42px; align-items: center; gap: 16px; }
.workload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; }
.workload-track { height: 20px; display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: #111318; }
.workload-segment { display: block; min-width: 3px; height: 100%; transition: width 180ms ease; }
.workload-total { color: #fff; text-align: right; font-size: 1.05rem; }
.workload-empty { min-height: 90px; display: grid; place-items: center; color: var(--muted); text-align: center; }

.clients-panel { margin-top: 16px; }
.clients-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 18px; }
.filters { display: flex; gap: 12px; }
.search-field { position: relative; min-width: 290px; }
.search-field svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; fill: none; stroke: #fff; stroke-width: 1.8; }
.search-field input { width: 100%; padding: 13px 14px 13px 44px; }
.filters select { min-width: 240px; padding: 13px 42px 13px 14px; }
.portfolio-list { display: grid; gap: 10px; }
.portfolio { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.portfolio-button { width: 100%; min-height: 58px; padding: 0 20px; border: 0; background: var(--black); color: var(--white); display: flex; align-items: center; gap: 16px; text-align: left; font-weight: 850; font-size: 1.08rem; }
.portfolio-button:hover { background: #080808; }
.portfolio.open .portfolio-button { color: var(--yellow); border-bottom: 1px solid var(--border); }
.chevron { width: 12px; height: 12px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 160ms ease; }
.portfolio.open .chevron { transform: rotate(45deg) translate(-2px, -2px); }
.project-list { display: none; }
.portfolio.open .project-list { display: block; }
.project-row { min-height: 58px; display: grid; grid-template-columns: minmax(240px, 1.7fr) minmax(150px, 0.8fr) minmax(150px, 0.6fr); align-items: center; gap: 20px; padding: 10px 34px 10px 62px; border-bottom: 1px solid #20242a; }
.project-row:last-child { border-bottom: 0; }
.project-link { color: var(--white); text-decoration: none; font-weight: 650; }
.project-link:hover { color: var(--yellow); text-decoration: underline; text-underline-offset: 4px; }
.project-owner { color: #c0c4cb; }
.responsible { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.responsible > span:last-child { overflow-wrap: anywhere; }
.responsible-avatar { position: relative; display: inline-grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: #292b20; color: var(--yellow); font-size: 12px; font-weight: 750; }
.responsible-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.status-badge { justify-self: end; min-width: 142px; padding: 7px 12px; border: 2px solid var(--yellow); border-radius: 8px; color: var(--yellow); text-align: center; font-size: 0.8rem; font-weight: 900; letter-spacing: 0.03em; }
.status-badge.overdue { border-color: var(--red); color: var(--red); box-shadow: 0 0 15px rgba(255, 43, 43, 0.36); }
.empty-state { padding: 54px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 9px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 24px); background: #17191d; border: 1px solid var(--border-strong); color: #fff; padding: 12px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: 180ms ease; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--red); }
.period-toolbar { display:flex; gap:16px; flex-wrap:wrap; align-items:end; margin-bottom:12px; }
.period-toolbar label { display:grid; gap:7px; color:#c0c4cb; font-size:14px; }
.period-toolbar input, .period-toolbar select, .period-toolbar button, .filter-menu summary { min-height:44px; padding:10px 14px; font:inherit; border-radius:8px; }
.period-toolbar input { color-scheme:dark; }
.period-toolbar button, .filter-menu summary { background:#111; border:1px solid #41454a; color:white; cursor:pointer; }
.filter-menu { position:relative; }
.filter-menu summary { color:var(--yellow); }
.filter-menu[open] summary { border-color:var(--yellow); }
.filter-popover { position:absolute; z-index:5; top:calc(100% + 8px); left:0; width:280px; max-width:80vw; padding:18px; background:#141414; border:1px solid #41454a; border-radius:10px; display:grid; gap:16px; box-shadow:0 12px 35px #000a; }
.filter-popover select { width:100%; }
.period-note { color:#a5abb3; font-size:14px; line-height:1.5; margin:0 0 20px; }
.period-note.error { color:var(--red); }
.project-detail { border-bottom: 1px solid var(--border); }
.project-detail:last-child { border-bottom: 0; }
.project-detail summary { cursor: pointer; list-style: none; }
.project-detail summary::-webkit-details-marker { display: none; }
.project-detail summary .project-link::before { content: "▸ "; color: var(--yellow); }
.project-detail[open] summary .project-link::before { content: "▾ "; }
.project-detail summary:focus-visible { outline: 2px solid var(--yellow); outline-offset: -3px; }
.task-list { padding: 12px 24px 16px 80px; background: #0b0b0b; }
.task-project-link { display: inline-block; color: var(--yellow); margin: 6px 0 12px; font-size: 14px; }
.task-row { display: grid; grid-template-columns: minmax(160px, 1.7fr) minmax(100px, .8fr) minmax(110px, .6fr) 150px; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--border); font-size: 14px; }
.task-name { color: white; text-decoration: none; overflow-wrap: anywhere; }
a.task-name:hover { color: var(--yellow); text-decoration: underline; }
.task-date { color: #c0c4cb; }
.status-badge.neutral { border-color: #707780; color: #c0c4cb; }
.status-badge.completed { border-color: #00d68f; color: #00d68f; background: rgba(0, 214, 143, .08); box-shadow: 0 0 12px rgba(0, 214, 143, .25); }
@media (max-width: 1000px) {
  .task-list { padding: 12px 18px; }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .task-row .project-owner { grid-column: 1; grid-row: 2; }
  .task-row .task-date { grid-column: 1; grid-row: 3; }
  .task-row .status-badge { grid-column: 2; grid-row: 1 / span 3; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1150px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-grid { grid-template-columns: 1fr; }
  .status-layout { grid-template-columns: 220px 1fr; max-width: 620px; margin: 24px auto 0; }
}

@media (max-width: 760px) {
  .workload-header { align-items: flex-start; flex-direction: column; }
  .workload-row { grid-template-columns: minmax(100px, 36%) 1fr 32px; gap: 10px; }
  .workload-name { font-size: 0.82rem; }
  .workload-track { height: 16px; }
  .topbar, main { width: min(100% - 28px, 1600px); }
  .topbar { min-height: 106px; }
  .brand { gap: 12px; }
  .brand-logo-wrap { width: 58px; height: 58px; }
  #brandLogo { width: 50px; height: 50px; }
  .brand-divider { height: 42px; }
  .brand-title { font-size: clamp(1.4rem, 7vw, 2.2rem); }
  .sync-copy { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 132px; }
  .charts-grid { margin-top: 12px; }
  .panel { padding: 20px 16px; }
  .panel-header, .clients-toolbar { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; flex-direction: column; }
  .search-field, .filters select { width: 100%; min-width: 0; }
  .status-layout { grid-template-columns: 1fr; }
  .status-legend { width: min(320px, 100%); margin: 0 auto; }
  .project-row { grid-template-columns: 1fr auto; padding: 16px 18px; gap: 8px 16px; }
  .project-owner { grid-column: 1; grid-row: 2; }
  .status-badge { grid-column: 2; grid-row: 1 / span 2; min-width: 120px; }
  .setup-panel { grid-template-columns: 1fr; padding: 28px 20px; }
  .setup-mark { display: none; }
  .token-row { grid-template-columns: 1fr; }
  .primary-button { min-height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
