:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #0d0d0d;
  --panel-2: #151515;
  --line: #242424;
  --line-strong: #343434;
  --text: #f4f4f4;
  --muted: #8a8a8a;
  --soft: #c7c7c7;
  --good: #f7f7f7;
  --warn: #d8d8d8;
  --bad: #ffffff;
  --sidebar: #030303;
  --focus: #ffffff;
  --font-main: "Manrope", sans-serif;
  --brand-font: "Oxanium", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: #000;
}

.login-form {
  display: grid;
  gap: 10px;
  width: min(280px, calc(100vw - 48px));
}

.login-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #050505;
  color: var(--text);
  padding: 0 10px;
  text-align: center;
}

.login-form input:focus {
  border-color: var(--focus);
  outline: none;
}

.login-form p {
  min-height: 16px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 22px 18px;
}

.sidebar-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  margin-bottom: 12px;
}

.sidebar-actions .home-action {
  flex: 1 1 auto;
  width: auto;
}

.icon-button,
.project-form button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: #101010;
  color: var(--text);
  border-radius: 6px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-items: center;
  padding: 0;
}

.icon-button span {
  font-size: 18px;
  line-height: 1;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.updated-at {
  position: absolute;
  top: 42px;
  left: 84px;
  z-index: 2;
  overflow: hidden;
  max-width: 150px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #101010;
  color: var(--muted);
  opacity: 0;
  padding: 5px 7px;
  pointer-events: none;
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 120ms ease;
}

#refresh:hover + .updated-at,
#refresh:focus-visible + .updated-at {
  opacity: 1;
}

.icon-button:hover,
.project-form button:hover {
  border-color: #555;
  background: #171717;
}

.project-form {
  position: absolute;
  top: 68px;
  left: 18px;
  z-index: 5;
  display: grid;
  gap: 10px;
  width: 420px;
  max-width: calc(100vw - 36px);
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  background: #080808;
  border-radius: 8px;
  box-shadow: 0 18px 42px rgb(0 0 0 / 60%);
}

.project-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.project-form input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #060606;
  color: var(--text);
  padding: 0 10px;
}

.project-form input:focus {
  border-color: var(--focus);
  outline: none;
}

.form-note {
  min-height: 14px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.project-list {
  display: grid;
  gap: 6px;
}

.sidebar-settings,
.sidebar-logout {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #101010;
  color: var(--soft);
  font-size: 12px;
  font-weight: 600;
}

.sidebar-settings,
.sidebar-logout {
  margin-top: auto;
}

.sidebar-settings:not(.hidden) + .sidebar-logout {
  margin-top: 8px;
}

.sidebar-settings:hover,
.sidebar-logout:hover {
  border-color: #555;
  background: #171717;
  color: var(--text);
}

.project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--soft);
}

.project-item.no-edit {
  grid-template-columns: 1fr;
}

.project-link,
.project-edit {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--soft);
}

.project-link {
  padding: 11px 12px;
  text-align: left;
}

.project-edit {
  display: grid;
  min-height: 34px;
  place-items: center;
  padding: 0;
  color: var(--muted);
  opacity: 0.55;
}

.project-edit svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.project-item:hover .project-edit,
.project-item.active .project-edit,
.project-edit:focus-visible {
  opacity: 1;
}

.project-item:hover {
  border-color: #555;
  background: #171717;
}

.project-item.active {
  border-color: var(--line-strong);
  background: #111;
  color: var(--text);
}

.project-item.active .project-link,
.project-item.active .project-edit {
  color: var(--text);
}

.project-link .name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.project-link .meta {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-link .token-missing {
  display: inline-block;
  margin-top: 8px;
  color: #111;
  background: #ddd;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
  text-transform: uppercase;
}

.content {
  min-width: 0;
  padding: 28px 32px 48px;
}

.topbar {
  display: grid;
  grid-template-columns: clamp(150px, 18vw, 330px) minmax(0, 1fr);
  align-items: end;
  gap: 20px;
}

.topbar:has(.topbar-metrics.hidden) {
  display: none;
}

.topbar:not(:has(.topbar-metrics.hidden)) {
  min-height: 112px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.topbar-side {
  display: flex;
  min-width: 0;
  justify-content: flex-end;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

.project-call-chart {
  display: grid;
  width: 100%;
}

.home-call-chart .chart-bars {
  height: 72px;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(18px, 1fr));
  gap: 6px;
  width: 100%;
  height: 72px;
  border: 0;
  background: transparent;
  padding: 0;
  align-items: end;
  cursor: pointer;
}

.chart-30d .chart-bars {
  grid-template-columns: repeat(30, minmax(4px, 1fr));
  gap: 2px;
}

.chart-bar {
  position: relative;
  display: grid;
  min-width: 0;
  height: 100%;
  grid-template-rows: 1fr 12px;
  align-items: end;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.chart-30d .chart-bar {
  font-size: 0;
}

.bar-fill {
  display: block;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--line-strong);
  border-radius: 3px 3px 0 0;
  background: #e8e8e8;
}

.bar-fill.zero {
  border-top: 0;
  height: 0 !important;
}

.chart-30d .bar-fill {
  border-radius: 2px 2px 0 0;
}

.bar-value {
  position: absolute;
  left: 50%;
  bottom: 17px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  transform: translateX(-50%);
}

.bar-value.inside {
  color: #050505;
}

.bar-value.outside {
  color: var(--text);
}

.chart-30d .bar-value {
  display: none;
}

.bar-label {
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.chart-30d .bar-label {
  display: none;
}

h2 {
  margin-bottom: 0;
  font-size: 14px;
}

.home-state {
  padding-top: 0;
}

.home-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 0;
}

.date-range-picker {
  position: relative;
  flex: 0 0 auto;
}

.date-range-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #101010;
  color: var(--text);
  padding: 0;
}

.date-range-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.date-range-button:hover,
.date-range-button.active {
  border-color: #555;
  background: #f2f2f2;
  color: #050505;
}

.date-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 244px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #050505;
  box-shadow: 0 18px 55px rgb(0 0 0 / 74%);
  padding: 12px;
}

.date-popover label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.date-popover label + label {
  margin-top: 10px;
}

.date-popover input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #0b0b0b;
  color: var(--text);
  padding: 0 9px;
  color-scheme: dark;
}

.date-popover-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.date-popover-actions button {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #101010;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.date-popover-actions button:hover {
  border-color: #555;
  background: #f2f2f2;
  color: #050505;
}

.range-buttons {
  display: flex;
  gap: 6px;
}

.range-button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #101010;
  color: var(--soft);
  padding: 0 11px;
  font-size: 12px;
}

.range-button.active,
.range-button:hover {
  border-color: #555;
  background: #f2f2f2;
  color: #050505;
}

.settings-panel {
  max-width: 620px;
}

.settings-list {
  display: grid;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--soft);
  font-size: 13px;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row input {
  width: 34px;
  height: 18px;
  accent-color: #f2f2f2;
}

.project-breakdown {
  display: grid;
}

.project-breakdown-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px 120px;
  gap: 16px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--soft);
  font-size: 12px;
}

.project-breakdown-row:last-child {
  border-bottom: 0;
}

.project-breakdown-row .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-breakdown-row .number {
  text-align: right;
}

.project-breakdown-row .error {
  color: var(--muted);
  text-align: right;
}

.project-view {
  padding-top: 18px;
}

.topbar-metrics {
  display: grid;
  grid-template-columns: repeat(var(--metric-count, 3), minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.metric {
  min-height: 62px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 11px 13px;
}

.metric .label {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.metric .value {
  overflow: hidden;
  margin-top: 7px;
  font-size: 21px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric .sub {
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.panel-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.panel-header span {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
}

td {
  color: var(--soft);
}

.call-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #151515;
  color: var(--text);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 36px 16px;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content {
    padding: 22px 18px 36px;
  }

  .topbar-side {
    min-width: 0;
    width: 100%;
  }

  .topbar-metrics {
    gap: 6px;
  }

  .topbar-metrics .metric {
    min-height: 58px;
    padding: 9px 9px;
  }

  .topbar-metrics .metric .value {
    font-size: 18px;
  }

  .topbar-metrics .metric .sub {
    font-size: 9px;
  }

  .chart-bars {
    grid-template-columns: repeat(7, minmax(10px, 1fr));
    gap: 4px;
  }

  .home-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .range-buttons,
  .range-button {
    width: 100%;
  }

  .date-range-button {
    width: 34px;
  }

  .date-popover {
    left: 0;
    right: auto;
  }

  .range-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
  }

  .project-breakdown-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .project-breakdown-row .number,
  .project-breakdown-row .error {
    text-align: left;
  }
}

@media (max-width: 520px) {
  .topbar-metrics {
    gap: 4px;
  }

  .topbar-metrics .metric {
    min-height: 56px;
    padding: 7px 6px;
  }

  .topbar-metrics .metric .label {
    font-size: 8px;
  }

  .topbar-metrics .metric .value {
    font-size: 14px;
  }

  .topbar-metrics .metric .sub {
    font-size: 8px;
  }

  .topbar {
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .topbar {
    grid-template-columns: 1fr;
    min-height: 64px;
  }
}
