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

body {
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  font-size: 14px;
  background: #f5f5f5;
  color: #333;
}

/* 非表示 */
.hidden {
  display: none;
}

/* ログイン画面 */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h2 {
  text-align: center;
  font-size: 18px;
  margin-bottom: 4px;
}

.login-box input {
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.login-box input:focus {
  outline: none;
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.login-error {
  color: #d9534f;
  font-size: 13px;
  min-height: 18px;
}

/* Toolbar */
#toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #ddd;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-group label {
  cursor: pointer;
  font-size: 13px;
}

.btn {
  display: inline-block;
  padding: 6px 14px;
  font-size: 13px;
  background: #4a90d9;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}

.btn:hover {
  background: #357abd;
}

.btn:disabled {
  background: #b0b0b0;
  cursor: not-allowed;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
}

.btn-secondary {
  background: #6c757d;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-danger {
  background: #d9534f;
}

.btn-danger:hover {
  background: #c9302c;
}

select, input[type="text"] {
  padding: 5px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

select:disabled {
  background: #eee;
}

/* Status bar */
#status-bar {
  padding: 4px 16px;
  font-size: 12px;
  color: #666;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  min-height: 22px;
}

/* Column panel */
#column-panel {
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #ddd;
}

#column-panel.hidden {
  display: none;
}

.column-add-form {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.column-input {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 160px;
}

.column-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.column-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #f0f4f8;
  border: 1px solid #d0d8e8;
  border-radius: 4px;
  font-size: 13px;
}

.column-empty {
  color: #999;
  font-size: 13px;
}

/* ドラッグ＆ドロップ並び替え */
.column-list-sortable {
  flex-direction: column;
  gap: 4px;
}

.column-item-draggable {
  cursor: grab;
  transition: background 0.15s, box-shadow 0.15s;
}

.column-item-draggable:active {
  cursor: grabbing;
}

.column-grip {
  color: #aaa;
  font-size: 14px;
  margin-right: 4px;
  user-select: none;
}

.column-label {
  flex: 1;
}

.column-dragging {
  opacity: 0.4;
}

.column-drag-over {
  border-color: #4a90d9;
  box-shadow: 0 -2px 0 0 #4a90d9;
}

/* Filter panel */
#filter-panel {
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn-filter-add {
  background: #5cb85c;
  font-size: 13px;
}

.btn-filter-add:hover {
  background: #4cae4c;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #e8f0fe;
  border: 1px solid #b8d0f0;
  border-radius: 16px;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
}

.filter-tag-text {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-tag-remove {
  background: none;
  border: none;
  color: #888;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.filter-tag-remove:hover {
  color: #d9534f;
}

.filter-clear-all {
  margin-left: 4px;
}

/* Filter dialog */
.filter-dialog {
  min-width: 420px;
}

.filter-input-area label {
  display: block;
  font-size: 13px;
  margin-top: 6px;
  margin-bottom: 2px;
}

.filter-multi-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  font-family: inherit;
}

/* Suggest combobox */
.suggest-wrapper {
  position: relative;
}

.suggest-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 1100;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.suggest-item {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.suggest-item:hover {
  background: #e8f0fe;
}

/* Table */
#table-container {
  padding: 12px 16px;
  color: #555;
}

.table-scroll-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
  border: 1px solid #ddd;
  border-radius: 4px;
}

table {
  border-collapse: collapse;
  background: #fff;
  table-layout: fixed;
}

thead th {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #4a90d9;
  color: #fff;
  font-weight: 600;
  padding: 8px 14px 8px 10px;
  text-align: left;
  white-space: nowrap;
  border: 1px solid #3a7bc8;
  user-select: none;
}

.th-label {
  pointer-events: none;
}

/* リサイズハンドル */
.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
}

.resize-handle:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 行削除ボタン列 */
.th-delete,
.td-delete {
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  text-align: center;
  padding: 2px !important;
}

.btn-row-delete {
  background: none;
  border: none;
  color: #ccc;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}

.btn-row-delete:hover {
  color: #fff;
  background: #d9534f;
}

tbody td {
  padding: 6px 10px;
  border: 1px solid #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

tbody tr:hover {
  background: #eef4ff;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
}

.pagination-info {
  color: #666;
}

.pagination-buttons {
  display: flex;
  gap: 4px;
}

.pagination-buttons .btn {
  min-width: 32px;
}

/* Dialog */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  min-width: 400px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.dialog h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
}

.dialog-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-top: 4px;
}

.dialog-col-list {
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.dialog-col-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.dialog-col-row input[type="checkbox"] {
  flex-shrink: 0;
}

.dialog-col-row span {
  font-size: 13px;
  white-space: nowrap;
}

.dialog-display-input {
  flex: 1;
  padding: 3px 6px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.dialog-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}
