* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f5f6f8;
  color: #1a1a1a;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  height: fit-content;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 8px;
}

.hint {
  color: #666;
  font-size: 0.9rem;
  margin: 0 0 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 12px 0 4px;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  flex: 1;
  padding: 12px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  min-height: 44px;
}

.btn.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn.secondary {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #2563eb;
}

.btn.icon-btn {
  flex: none;
  width: 44px;
  padding: 0;
  font-size: 1.2rem;
}

.btn.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

.status-msg {
  margin-top: 12px;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.status-msg.ok {
  color: #15803d;
}

.status-msg.error {
  color: #b91c1c;
}

#app-screen.screen {
  display: block;
  padding: 0;
  max-width: 100%;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.sync-banner {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 16px;
  font-size: 0.85rem;
  text-align: center;
}

.sync-banner.error {
  background: #fee2e2;
  color: #b91c1c;
}

#main-content {
  padding: 12px;
  max-width: 1000px;
  margin: 0 auto;
}

.tracking-controls {
  max-width: 100%;
  border-radius: 0;
  margin: 0 auto;
  width: 100%;
  box-shadow: none;
  border-bottom: 1px solid #e5e7eb;
}

.status-line {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #555;
  text-align: center;
}

.chart-section {
  margin-bottom: 12px;
  max-width: none;
  position: relative;
  height: 320px;
}

.entry-form-section {
  margin-bottom: 12px;
  max-width: none;
}

.entry-form-section h2 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.table-section {
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  overflow: hidden;
}

.rows-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.rows-table th,
.rows-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

.rows-table th {
  color: #666;
  font-size: 0.8rem;
  font-weight: 600;
}

.add-cell {
  border: none;
  background: #eef2ff;
  color: #2563eb;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.editable-cell {
  cursor: pointer;
  text-decoration: underline dotted;
}

.diff-green {
  color: #15803d;
  font-weight: 600;
}

.diff-amber {
  color: #b45309;
  font-weight: 600;
}

.diff-red {
  color: #b91c1c;
  font-weight: 600;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.modal-box p {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.modal-box input {
  margin-bottom: 4px;
}

.modal-box .button-row {
  margin-top: 16px;
}

@media (min-width: 900px) {
  #main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
}
