:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-synthesis: none;
  --green-950: #064e3b;
  --green-800: #087f5b;
  --green-700: #0b8f68;
  --green-100: #d9f4e8;
  --green-50: #edf9f3;
  --ink: #17211d;
  --muted: #66736d;
  --line: #dfe7e2;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --danger: #c92a2a;
  --shadow: 0 24px 70px rgba(22, 52, 41, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 300px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(135, 220, 177, 0.24), transparent 32rem),
    var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

.material-icon {
  display: block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(11, 143, 104, 0.28);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  width: 22px;
  height: 22px;
  padding: 2px;
}

.brand-mark i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.brand-mark-large {
  grid-template-columns: repeat(2, 20px);
  grid-template-rows: repeat(2, 20px);
  width: 52px;
  height: 52px;
  padding: 4px;
  color: var(--green-800);
}

.brand-mark-large i {
  width: 17px;
  height: 17px;
}

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.login-card {
  position: relative;
  width: min(100%, 440px);
  padding: 42px;
  overflow: hidden;
  border: 1px solid rgba(223, 231, 226, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-card::after {
  position: absolute;
  right: -58px;
  top: -58px;
  width: 170px;
  height: 170px;
  border: 34px solid var(--green-50);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.login-card > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 24px 0 6px;
  color: var(--green-800);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0;
  max-width: 310px;
  font-size: clamp(31px, 7vw, 42px);
  line-height: 1.03;
  letter-spacing: -0.04em;
}

.login-lead {
  margin: 18px 0 28px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.login-form label,
.control > span {
  display: block;
  margin: 0 0 7px;
  color: #435049;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.token-field {
  position: relative;
}

.token-field input {
  width: 100%;
  min-height: 52px;
  padding: 0 88px 0 15px;
  border: 1px solid #cdd8d2;
  border-radius: 13px;
  color: var(--ink);
  background: #fbfdfc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.token-field input:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 4px rgba(11, 143, 104, 0.11);
}

.token-toggle {
  position: absolute;
  top: 7px;
  right: 7px;
  height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  color: var(--green-800);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.token-toggle:hover {
  background: var(--green-50);
}

.form-error {
  margin: 9px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border-radius: 13px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  margin-top: 18px;
  padding: 0 17px;
  border: 0;
  color: #fff;
  background: var(--green-800);
  box-shadow: 0 9px 22px rgba(8, 127, 91, 0.2);
}

.primary-button:hover {
  background: var(--green-950);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button-arrow {
  margin-left: auto;
  font-size: 20px;
  font-weight: 400;
}

.security-note {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: #7b8781;
  font-size: 12px;
  line-height: 1.5;
}

.dashboard-view {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 10px max(24px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(221, 230, 225, 0.9);
  background: rgba(255, 255, 255, 0.91);
  backdrop-filter: blur(16px);
}

.app-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--green-800);
  text-decoration: none;
}

.app-brand > span + span {
  margin-left: 11px;
}

.app-brand-title {
  min-width: 0;
}

.app-brand strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  position: relative;
  display: flex;
  align-items: center;
}

.header-actions > * + * {
  margin-left: 9px;
}

.header-button,
.account-button,
.square-button,
.current-period-button,
.refresh-button {
  min-height: 40px;
  border: 1px solid var(--line);
  color: #3c4943;
  background: #fff;
}

.header-button,
.refresh-button {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
}

.header-button > * + *,
.refresh-button > * + * {
  margin-left: 7px;
}

.account-button {
  display: flex;
  align-items: center;
  padding: 4px 10px 4px 5px;
  border-radius: 22px;
}

.account-chevron {
  width: 18px;
  height: 18px;
}

.account-button > * + * {
  margin-left: 8px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  color: var(--green-950);
  background: var(--green-100);
  font-size: 11px;
  font-weight: 800;
}

.account-name {
  max-width: 180px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 40;
  width: min(280px, calc(100vw - 32px));
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(32, 55, 46, 0.16);
}

.account-menu-name {
  padding: 8px 9px 11px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu button {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 9px;
  color: var(--danger);
  background: #fff5f5;
  font-weight: 700;
  text-align: left;
}

.dashboard-toolbar {
  display: flex;
  align-items: flex-end;
  max-width: 1600px;
  margin: 0 auto;
  padding: 22px 28px 14px;
}

.dashboard-toolbar > * + * {
  margin-left: 14px;
}

.control select {
  width: 100%;
  height: 42px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  font-weight: 650;
}

.dashboard-picker {
  flex: 1 1 420px;
  min-width: 220px;
}

.period-controls {
  display: flex;
  align-items: flex-end;
}

.period-controls > * + * {
  margin-left: 8px;
}

.period-picker {
  width: 126px;
}

.period-navigation {
  display: flex;
  align-items: center;
}

.period-navigation > * + * {
  margin-left: -1px;
}

.square-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  padding: 0;
}

.square-button:first-child {
  border-radius: 11px 0 0 11px;
}

.square-button:last-child {
  border-radius: 0 11px 11px 0;
}

.current-period-button {
  min-width: 132px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.refresh-button {
  color: var(--green-800);
}

.header-button:hover,
.account-button:hover,
.square-button:hover,
.current-period-button:hover,
.refresh-button:hover {
  border-color: #b8c9c0;
  background: var(--green-50);
}

.status-bar {
  display: flex;
  align-items: center;
  max-width: 1600px;
  min-height: 26px;
  margin: 0 auto;
  padding: 0 29px 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-bar > * + * {
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.connection-status {
  display: inline-flex;
  align-items: center;
}

.connection-status i {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #20a66a;
  box-shadow: 0 0 0 4px rgba(32, 166, 106, 0.1);
}

.connection-status.offline i {
  background: #e67700;
  box-shadow: 0 0 0 4px rgba(230, 119, 0, 0.1);
}

.dashboard-main {
  position: relative;
  max-width: 1600px;
  min-height: calc(100vh - 150px);
  min-height: calc(100dvh - 150px);
  margin: 0 auto;
  padding: 0 22px max(22px, env(safe-area-inset-bottom));
}

.dashboard-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 176px);
  height: calc(100dvh - 176px);
  min-height: 430px;
  border: 0;
  border-radius: 18px;
  background: #eef2f0;
}

.loading-state {
  padding: 6px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.skeleton-grid > * + * {
  margin-left: 14px;
}

.skeleton {
  height: 290px;
  border-radius: 18px;
  background: linear-gradient(100deg, #e5ebe7 20%, #f5f8f6 38%, #e5ebe7 56%);
  background-size: 220% 100%;
  animation: shimmer 1.35s infinite linear;
}

.skeleton-wide {
  height: 150px;
}

@keyframes shimmer {
  to { background-position-x: -220%; }
}

.message-state {
  display: grid;
  place-items: center;
  min-height: 430px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  text-align: center;
}

.message-state > * {
  margin: 0;
}

.message-state > * + * {
  margin-top: 10px;
}

.message-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--green-800);
  background: var(--green-50);
  font-size: 27px;
  font-weight: 800;
}

.message-state h2 {
  font-size: 21px;
}

.message-state p {
  max-width: 440px;
  color: var(--muted);
  line-height: 1.5;
}

.error-state .message-icon {
  color: var(--danger);
  background: #fff0f0;
}

.secondary-button {
  margin-top: 18px !important;
  padding: 0 18px;
  border: 1px solid #bdd0c6;
  color: var(--green-800);
  background: #fff;
}

.install-dialog {
  width: min(420px, calc(100% - 30px));
  padding: 0;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}

.install-dialog::backdrop {
  background: rgba(8, 30, 22, 0.48);
  backdrop-filter: blur(4px);
}

.install-dialog form {
  position: relative;
  padding: 34px;
}

.install-dialog h2 {
  margin: 20px 0 10px;
  font-size: 26px;
}

.install-dialog p,
.install-dialog ol {
  color: var(--muted);
  line-height: 1.55;
}

.install-dialog ol {
  padding-left: 22px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #52615a;
  background: #f1f5f3;
  font-size: 23px;
}

noscript {
  display: block;
  padding: 20px;
  color: var(--danger);
  text-align: center;
}

@media (max-width: 900px) {
  .dashboard-toolbar {
    flex-wrap: wrap;
  }

  .dashboard-picker {
    flex-basis: calc(100% - 166px);
  }

  .period-controls {
    order: 3;
    width: 100%;
    margin: 14px 0 0 !important;
  }

  .period-navigation {
    flex: 1;
  }

  .current-period-button {
    flex: 1;
  }
}

@media (max-width: 620px) {
  .login-card {
    padding: 32px 24px;
    border-radius: 22px;
  }

  .app-header {
    min-height: 52px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: 6px;
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .app-brand {
    flex: 1 1 auto;
    overflow: hidden;
  }

  .app-brand > span + span {
    margin-left: 8px;
  }

  .app-brand strong {
    font-size: 14px;
  }

  .account-name,
  .header-button span {
    display: none;
  }

  .header-actions {
    flex: 0 0 auto;
  }

  .header-actions > * + * {
    margin-left: 6px;
  }

  .header-button {
    width: 40px;
    padding: 0;
    justify-content: center;
    font-size: 20px;
  }

  .account-button {
    padding-right: 7px;
  }

  .dashboard-toolbar {
    align-items: flex-end;
    padding: 15px 14px 10px;
  }

  .dashboard-picker {
    flex-basis: 100%;
    min-width: 0;
  }

  .dashboard-toolbar > .refresh-button {
    position: absolute;
    right: 14px;
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  .refresh-button span:last-child {
    display: none;
  }

  .period-controls {
    padding-right: 52px;
  }

  .period-picker {
    width: 112px;
  }

  .status-bar {
    padding: 0 15px 8px;
    overflow: hidden;
    white-space: nowrap;
  }

  .status-bar > * + * {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dashboard-main {
    min-height: calc(100vh - 198px);
    min-height: calc(100dvh - 198px);
    padding: 0 0 max(8px, env(safe-area-inset-bottom));
  }

  .dashboard-frame {
    height: calc(100vh - 204px);
    height: calc(100dvh - 204px);
    min-height: 390px;
    border-radius: 0;
  }

  .loading-state {
    padding: 8px 12px;
  }

  .skeleton-grid {
    display: block;
  }

  .skeleton-grid > * + * {
    margin: 12px 0 0;
  }

  .message-state {
    min-height: 390px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
