:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-muted: #eef1ed;
  --ink: #17201c;
  --muted: #68736d;
  --line: #d8ded9;
  --line-strong: #bcc7bf;
  --green: #16764b;
  --green-soft: #e5f3eb;
  --cyan: #087e8b;
  --cyan-soft: #e3f3f4;
  --amber: #9b5c00;
  --amber-soft: #fff1d6;
  --red: #b42318;
  --red-soft: #fee9e7;
  --shadow: 0 1px 2px rgba(23, 32, 28, 0.06);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-block, .topbar-actions, .title-row, .section-heading,
.account-heading, .window-heading, .schedule-row, .schedule-controls {
  display: flex;
  align-items: center;
}

.brand-block { gap: 10px; min-width: 0; }
.brand-mark, .entry-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  border-radius: 6px;
  font-weight: 750;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 15px; line-height: 1.2; }
.brand-block p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.topbar-actions { gap: 10px; }

.source-pill, .status-chip, .best-badge, .plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.source-dot, .state-dot, .account-state-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--green);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-muted); }
.icon-button:disabled { opacity: 0.5; cursor: wait; }

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

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 12px 12px;
  border-right: 1px solid var(--line);
  background: #e9ece7;
}

.sidebar-label, .eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}
.sidebar-label { padding: 0 8px 8px; }

.entry-nav {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.entry-nav.active {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.entry-nav-copy { min-width: 0; }
.entry-nav-copy strong, .entry-nav-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-nav-copy strong { font-size: 13px; }
.entry-nav-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  padding: 12px 8px 2px;
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  min-width: 0;
  width: min(1180px, 100%);
  padding: 24px 28px 32px;
}

.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
}
.eyebrow { margin-bottom: 7px; }
.title-row { gap: 10px; flex-wrap: wrap; }
h2 { font-size: 27px; line-height: 1.15; }
.workspace-heading p { margin-top: 8px; color: var(--muted); font-size: 14px; }
.updated-block { text-align: right; flex: 0 0 auto; }
.updated-block span, .updated-block strong { display: block; }
.updated-block span { color: var(--muted); font-size: 11px; }
.updated-block strong { margin-top: 5px; font-size: 13px; }

.status-chip.running { background: var(--green-soft); border-color: #a9d5ba; color: var(--green); }
.status-chip.offline, .status-chip.error { background: var(--red-soft); border-color: #f2b8b2; color: var(--red); }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.metric-cell {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}
.metric-cell:last-child { border-right: 0; }
.metric-cell span, .metric-cell strong { display: block; }
.metric-cell span { color: var(--muted); font-size: 11px; }
.metric-cell strong {
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.section-block { margin-top: 24px; }
.section-heading { justify-content: space-between; margin-bottom: 10px; }
h3 { font-size: 15px; }
.section-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; }

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.account-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.account-card.unavailable { border-color: #efb9b4; }
.account-heading { justify-content: space-between; gap: 12px; }
.account-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.account-identity strong { display: block; font-size: 14px; }
.account-identity small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.account-badges { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.best-badge { min-height: 22px; padding: 2px 7px; color: var(--cyan); background: var(--cyan-soft); border-color: #afd5d8; }
.plan-badge { min-height: 22px; padding: 2px 7px; }

.window-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.window-panel { min-width: 0; }
.window-heading { justify-content: space-between; gap: 8px; }
.window-heading span { color: var(--muted); font-size: 11px; }
.window-heading strong { font-size: 18px; }
.quota-track { height: 8px; margin-top: 9px; border-radius: 4px; background: #e5e9e6; overflow: hidden; }
.quota-fill { height: 100%; border-radius: 4px; background: var(--green); transition: width 180ms ease; }
.quota-fill.medium { background: var(--amber); }
.quota-fill.low { background: var(--red); }
.window-meta { margin-top: 8px; color: var(--muted); font-size: 11px; min-height: 32px; }

.account-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.remote-only { display: none; }
.account-actions span { color: var(--muted); font-size: 11px; }
.command-button {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.command-button:hover { background: var(--surface-muted); }
.command-button:disabled { opacity: 0.45; cursor: not-allowed; }
.command-button.primary { background: var(--ink); border-color: var(--ink); color: white; }

.schedule-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}
.schedule-row { justify-content: space-between; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.schedule-row:last-child { border-bottom: 0; }
.schedule-copy { min-width: 150px; }
.schedule-copy strong, .schedule-copy small { display: block; }
.schedule-copy strong { font-size: 13px; }
.schedule-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.schedule-controls { gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.number-input, .unit-select {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: white;
  padding: 4px 7px;
}
.number-input { width: 64px; }
.unit-select { width: 82px; }
.repeat-label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.repeat-label input { width: 16px; height: 16px; accent-color: var(--green); }

.loading-row, .error-row { padding: 20px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 13px; }
.error-row { color: var(--red); background: var(--red-soft); border-color: #f2b8b2; }
.workspace-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--ink);
  color: white;
  box-shadow: 0 8px 24px rgba(23, 32, 28, 0.18);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); border-color: var(--red); }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .sidebar-label, .sidebar-footer { display: none; }
  .entry-nav { max-width: 100%; }
  .workspace { padding: 18px 14px 28px; }
  .workspace-heading { gap: 12px; }
  .updated-block { display: none; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-cell:nth-child(2) { border-right: 0; }
  .metric-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .account-grid { grid-template-columns: 1fr; }
  .schedule-row { align-items: flex-start; flex-direction: column; }
  .schedule-controls { justify-content: flex-start; width: 100%; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px; }
  .source-pill { display: none; }
  h2 { font-size: 24px; }
  .window-grid { grid-template-columns: 1fr; }
  .account-actions { align-items: flex-start; flex-direction: column; }
  .command-button { width: 100%; }
  .workspace-footer { flex-direction: column; gap: 5px; }
}
