* { box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --panel: #181b24;
  --border: #2a2f3d;
  --text: #e6e8ee;
  --muted: #8a91a3;
  --accent: #fbbf24;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app { height: 100%; display: flex; flex-direction: column; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.error { color: #f87171; }

/* --- gate --- */
.gate {
  max-width: 340px;
  margin: 18vh auto;
  text-align: center;
}
.gate h1 { font-size: 42px; margin: 0 0 4px; }
.gate-form { display: flex; gap: 8px; margin-top: 20px; }
.gate-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
}
.gate-form button {
  padding: 10px 18px;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: #111;
  font-weight: 600;
  cursor: pointer;
}

/* --- tabs --- */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.tabs .brand { font-weight: 700; margin-right: 12px; color: var(--accent); }
.tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text);
}
.tabs a:hover { background: var(--border); text-decoration: none; }
.tabs a.active { background: var(--accent); color: #111; font-weight: 600; }
.tabs .logout { margin-left: auto; color: var(--muted); font-size: 13px; }

/* --- pages --- */
.page {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}
section { margin-top: 28px; }
h2 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
h3 { margin: 14px 0 6px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.intro { margin: 6px 0 20px; }
.intro h1 { margin: 0 0 8px; font-size: 28px; }
.intro p { max-width: 640px; margin: 0; line-height: 1.5; }

.card .big { font-size: 26px; font-weight: 700; }
.card .label { color: var(--muted); }
.card .sub { font-size: 12px; margin-top: 4px; }

table.modes { border-collapse: collapse; width: 100%; }
table.modes th, table.modes td {
  text-align: right;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
table.modes th:first-child, table.modes td:first-child { text-align: left; }
table.modes th { color: var(--muted); font-weight: 600; }
table.modes .hrs { font-size: 11px; }
table.modes.slim { width: auto; min-width: 220px; }
table.modes tr.avg td { border-top: 2px solid var(--border); border-bottom: none; font-weight: 600; }
table.modes tr.avg .hrs { font-weight: 400; }
.note { font-size: 12px; max-width: 640px; }

/* --- on this day --- */
.otdbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0 4px; }
.otdbar .otdtitle { font-size: 22px; font-weight: 700; min-width: 150px; text-align: center; }
.otdbar button {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.otdbar button:hover { background: var(--border); }
.otdbar input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
}

.list { padding-left: 22px; }
.list li { margin: 4px 0; }
.list .stints { font-size: 12px; margin: 1px 0 6px; }
.list.cols { columns: 2; }
@media (max-width: 700px) { .list.cols { columns: 1; } }

/* --- search --- */
.page > input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 17px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 16px; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }
.hit { padding: 8px 10px; border-radius: 8px; }
.hit.link { cursor: pointer; }
.hit.link:hover { background: var(--panel); }
.minimap { height: 220px; border-radius: 10px; margin: 10px 0; }
.yearchip {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 7px;
  margin: 2px;
  font-size: 12px;
}
.visitlist { max-height: 320px; overflow-y: auto; font-variant-numeric: tabular-nums; }
.visitlist .link { cursor: pointer; }
.visitlist .link:hover { color: var(--accent); }

/* --- map --- */
body.has-map #app { overflow: hidden; }
.maplayout {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 300px;
  min-height: 0;
}
.mapbar {
  grid-column: 1 / -1;
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.mapbar select, .mapbar input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
}
#bigmap { min-height: 0; background: #222; }
.daypanel {
  overflow-y: auto;
  padding: 12px 14px;
  border-left: 1px solid var(--border);
  background: var(--panel);
}
.daypanel .dayitem { margin: 6px 0; font-size: 13px; }
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
@media (max-width: 800px) {
  .maplayout { grid-template-columns: 1fr; grid-template-rows: auto 1fr 200px; }
  .daypanel { border-left: 0; border-top: 1px solid var(--border); }
}
