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

:root {
  --bg:      #f5f6f8;
  --surface: #ffffff;
  --border:  #dde1e7;
  --accent:  #1a56db;
  --accent-h:#1344b8;
  --danger:  #e02424;
  --ok:      #057a55;
  --warn:    #b45309;
  --text:    #111827;
  --muted:   #6b7280;
  --radius:  6px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* Nav */
nav {
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 52px;
}
nav .brand { font-weight: 700; font-size: 1.05rem; margin-right: auto; }
nav a { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.9rem; padding: 4px 0; border-bottom: 2px solid transparent; }
nav a:hover { color: #fff; }
nav a.active { color: #fff; border-bottom-color: #fff; }

main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 { font-size: 1.4rem; margin-bottom: 1.5rem; }

/* Scan row */
.scan-row {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.scan-row label { font-weight: 600; white-space: nowrap; }
.scan-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 1rem;
  font-family: monospace;
}
.scan-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }
#scan_status { font-size: 0.85rem; white-space: nowrap; }
#scan_status.ok   { color: var(--ok); }
#scan_status.warn { color: var(--warn); }

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.95rem;
}
.field input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

button {
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
}
button[type="submit"], #save_btn {
  background: var(--accent);
  color: #fff;
}
button[type="submit"]:hover, #save_btn:hover { background: var(--accent-h); }
button[type="button"], #clear_btn {
  background: var(--border);
  color: var(--text);
}
button[type="button"]:hover, #clear_btn:hover { background: #c8cdd5; }

/* Toast */
.toast {
  margin-top: 1rem;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
}
.toast.hidden { display: none; }
.toast.ok    { background: #d1fae5; color: var(--ok); }
.toast.error { background: #fde8e8; color: var(--danger); }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filter-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 0.9rem;
}
.filter-bar label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.filter-bar label input[type="date"] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 0.9rem;
}
#filter_btn  { background: var(--accent); color: #fff; }
#filter_btn:hover { background: var(--accent-h); }
#export_btn  { background: #e3f1d5; color: #2d6a0e; }
#export_btn:hover { background: #c9e8b5; }

/* Summary */
.summary {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* Table */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9rem;
}
thead { background: #f0f2f5; }
th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
.mono { font-family: monospace; font-size: 0.85rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }

.del-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 400;
}
.del-btn:hover { background: #fde8e8; }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .scan-row { flex-wrap: wrap; }
}
