:root {
  --bg: #f4f6f8;
  --panel: #fff;
  --text: #1a1a1a;
  --muted: #5c6670;
  --accent: #1a5fb4;
  --border: #d8dee4;
  --error: #c01c28;
  --notice-bg: #fff3cd;
  --notice-border: #ffc107;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

.panel {
  max-width: 360px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

input[type='text'],
input[type='password'] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

button[type='submit'],
.pager button {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

button[type='submit']:hover,
.pager button:hover:not(:disabled) {
  filter: brightness(1.05);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.error {
  color: var(--error);
  margin-top: 1rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.badge {
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  background: #e8f0fe;
  color: var(--accent);
  border-radius: 4px;
}

.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.95rem;
}

.notice {
  margin: 0;
  padding: 0.6rem 1rem;
  background: var(--notice-bg);
  border-bottom: 1px solid var(--notice-border);
  font-size: 0.9rem;
}

#main-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  height: 100%;
  padding: 0.5rem 0;
}

.sidebar h3 {
  margin: 1rem 1rem 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.92rem;
}

.sidebar button:hover {
  background: #eef2f6;
}

.sidebar button.active {
  background: #e3ecf8;
  color: var(--accent);
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 1rem;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.toolbar h2 {
  margin: 0;
  font-size: 1.2rem;
}

.checkbox-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.4rem;
  flex-shrink: 0;
}

.table-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.table-scroll-y {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  -webkit-overflow-scrolling: touch;
}

.table-wrap {
  overflow: visible;
  will-change: transform;
}

.table-hscroll {
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  background: #eef1f4;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  -webkit-overflow-scrolling: touch;
}

.table-hscroll.hidden {
  display: none;
}

.table-hscroll-inner {
  height: 1px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: auto;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  vertical-align: top;
  text-align: left;
  min-width: 10rem;
  max-width: 28rem;
  word-break: break-word;
}

th {
  background: #f0f3f6;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
  box-shadow: 0 1px 0 var(--border);
}

.ref-label {
  display: block;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.8rem;
}

.ref-guid {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-shrink: 0;
}

#page-info {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  #main-screen {
    height: 100vh;
  }

  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    flex: 1;
    min-height: 0;
  }
}
