* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f4f5f7;
  color: #1e1e1e;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1e293b;
  color: #fff;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  padding: 16px;
}

.picker {
  grid-column: 1;
  grid-row: 1 / span 2;
  background: #fff;
  border: 1px solid #d9dce1;
  border-radius: 8px;
  padding: 16px;
  height: fit-content;
}

.calc-area {
  grid-column: 2;
  grid-row: 1;
  min-height: 200px;
}
.calc-panel {
  background: #fff;
  border: 1px solid #d9dce1;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}
.calc-panel-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}
.calc-panel .hint {
  text-align: left;
  max-width: 480px;
  margin: 0 auto 16px;
  line-height: 1.6;
}
.calc-panel .btn {
  width: auto;
  padding: 10px 24px;
}

.history {
  grid-column: 2;
  grid-row: 2;
  background: #fff;
  border: 1px solid #d9dce1;
  border-radius: 8px;
  padding: 16px;
}

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
select, input, textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #c9ccd1;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.preview {
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  padding: 10px;
  border-radius: 6px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.btn {
  padding: 8px 14px;
  border: 1px solid #c9ccd1;
  background: #f0f1f3;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  margin-top: 4px;
}
.btn:hover { background: #e5e7eb; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.success { background: #059669; color: #fff; border-color: #059669; }
.btn.success:hover { background: #047857; }
.btn.ghost { background: transparent; color: inherit; border-color: transparent; width: auto; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.hint { font-size: 12px; color: #6b7280; min-height: 16px; margin: 4px 0 0; }

hr { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.history-head h2 { font-size: 15px; margin: 0; }
.history-head input { width: 220px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eee; }
th { color: #6b7280; font-weight: 600; font-size: 12px; }
tr:hover { background: #f9fafb; }
.row-link { color: #2563eb; cursor: pointer; background: none; border: none; padding: 0; font-size: 13px; }

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 8px; padding: 20px;
  width: min(600px, 92vw); max-height: 85vh; overflow: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-actions { display: flex; gap: 8px; margin-top: 10px; }
.modal-actions .btn { width: auto; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 6px;
  font-size: 13px; z-index: 100;
}
.toast.hidden { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .picker, .calc-area, .history { grid-column: 1; }
  .picker { grid-row: auto; }
  .calc-area { grid-row: auto; }
  .history { grid-row: auto; }
}
