:root {
  --mapup-cyan: #00aeef;
  --mapup-blue: #0056b3;
  --mapup-dark: #031a2a;
  --ink: #1a2733;
  --muted: #667685;
  --line: #e2e8ee;
  --bg: #f5f7fa;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.viewer-body {
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--mapup-dark);
  color: var(--white);
  flex: 0 0 auto;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--mapup-cyan);
}

.divider {
  color: var(--muted);
}

.doc-title {
  font-weight: 500;
  color: #cfe8f5;
}

.user-email {
  font-size: 13px;
  color: #cfe8f5;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-secondary {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--mapup-cyan);
  color: var(--mapup-cyan);
}

/* Viewer */
.viewer-main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.frame-wrap {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.doc-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--white);
}

.error-box {
  margin: 24px auto;
  max-width: 640px;
  padding: 16px 20px;
  background: #fff4f4;
  border: 1px solid #f3c2c2;
  border-radius: 8px;
  color: #a12a2a;
}

/* Landing */
.landing-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px;
}

.landing-main h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.muted {
  color: var(--muted);
}

.doc-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 12px;
}

.doc-list a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.doc-list a:hover {
  border-color: var(--mapup-cyan);
  box-shadow: 0 2px 10px rgba(0, 174, 239, 0.12);
}

.doc-name {
  font-weight: 600;
}

.doc-path {
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Dashboard */
.dash-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.dash-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.dash-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
}
.dash-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-range {
  padding: 6px 10px;
  font-size: 13px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.dash-range:focus {
  outline: none;
  border-color: var(--mapup-cyan);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.12);
}
.small {
  font-size: 12px;
}
.dash-search {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
}
.dash-search-input {
  flex: 1 1 auto;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.dash-search-input:focus {
  border-color: var(--mapup-cyan);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.12);
}
#search-count {
  white-space: nowrap;
}

.user-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 16px;
}
.user-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.user-stats {
  text-align: right;
  display: flex;
  flex-direction: column;
}
.user-stats > span:first-child {
  font-weight: 700;
  color: var(--mapup-blue);
}
.user-bar {
  height: 6px;
  background: #eef2f6;
  border-radius: 3px;
  margin: 10px 0 4px;
  overflow: hidden;
}
.user-bar > span {
  display: block;
  height: 100%;
  background: var(--mapup-cyan);
}
details.doc {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}
details.doc summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
details.doc .doc-name {
  font-weight: 600;
}
.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #eef2f6;
  color: var(--muted);
}
.tag.ok { background: #e6f6ec; color: #1a7f42; }
.tag.q { background: #e7f2fb; color: var(--mapup-blue); }
table.sections {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
}
table.sections td {
  padding: 5px 6px;
  font-size: 13px;
  border-bottom: 1px solid #f1f4f7;
  vertical-align: middle;
}
table.sections td.num {
  text-align: right;
  white-space: nowrap;
  color: var(--ink);
  width: 64px;
}
td.bar-cell { width: 50%; }
td.bar-cell .bar {
  display: inline-block;
  height: 8px;
  background: var(--mapup-cyan);
  border-radius: 4px;
  min-width: 2px;
}
