* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #e8e8e8;
  color: #000;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #c0c0c0;
  flex-shrink: 0;
  z-index: 20;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 480px;
}

.search-bar input {
  flex: 1;
  height: 28px;
  padding: 0 8px;
  border: 1px solid #a0a0a0;
  border-radius: 2px;
  font-size: 13px;
  outline: none;
}

.search-bar input:focus {
  border-color: #217346;
}

.search-bar button {
  width: 28px;
  height: 28px;
  border: 1px solid #a0a0a0;
  background: #f0f0f0;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.search-bar button:hover {
  background: #e0e0e0;
}

.search-count {
  font-size: 12px;
  color: #666;
  min-width: 48px;
  white-space: nowrap;
}

.save-status {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 2px;
  margin-left: auto;
  white-space: nowrap;
}

.save-status.saved { color: #217346; background: #e2efda; }
.save-status.saving { color: #1a5276; background: #d6eaf8; }
.save-status.error { color: #c0392b; background: #fadbd8; }

.grid-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

colgroup .col-rownum { width: 48px; }
colgroup .col-desc { width: auto; }
colgroup .col-time { width: 160px; }

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th {
  height: 24px;
  padding: 0 6px;
  background: #f0f0f0;
  border: 1px solid #c0c0c0;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #333;
}

thead th.col-rownum-h {
  width: 48px;
}

tbody tr.row-sentinel {
  background: #fffde7;
}

tbody tr.row-match td {
  background: #fff3cd !important;
}

tbody tr.row-active td {
  background: #cce5ff !important;
  outline: 2px solid #217346;
  outline-offset: -2px;
}

td {
  height: 24px;
  padding: 0;
  border: 1px solid #d4d4d4;
  vertical-align: middle;
}

.cell-rownum {
  background: #f0f0f0;
  text-align: center;
  font-size: 11px;
  color: #666;
  cursor: default;
  user-select: none;
  border-right: 1px solid #a0a0a0;
}

.cell-rownum.has-data {
  cursor: context-menu;
}

.cell-rownum.sentinel {
  color: #999;
  font-style: italic;
}

.cell-desc input,
.cell-time span {
  display: block;
  width: 100%;
  height: 23px;
  line-height: 23px;
  padding: 0 4px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-family: inherit;
}

.cell-desc input:focus {
  box-shadow: inset 0 0 0 2px #217346;
  background: #fff;
}

.cell-time {
  background: #fafafa;
}

.cell-time span {
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ctx-menu {
  position: fixed;
  z-index: 100;
  background: #fff;
  border: 1px solid #a0a0a0;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.15);
  min-width: 120px;
  padding: 4px 0;
}

.ctx-menu.hidden {
  display: none;
}

.ctx-menu button {
  display: block;
  width: 100%;
  padding: 6px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.ctx-menu button:hover {
  background: #e8f0fe;
}

.ctx-menu button[data-action="delete"] {
  color: #c0392b;
}
