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

:root {
  --bg: #f8f9fa;
  --surface: #fff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #f59e0b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Layout */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 18px; font-weight: 700; }
header nav { display: flex; gap: 12px; }
header nav a {
  text-decoration: none;
  color: var(--primary);
  font-weight: 500;
  font-size: 14px;
}

main { max-width: 720px; margin: 0 auto; padding: 16px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* Forms */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  margin-top: 16px;
}
input, select, textarea, button {
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom */
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; min-height: 60px; }

button, .btn {
  display: inline-block;
  width: auto;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: var(--surface); color: var(--primary); border: 1px solid var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* Tags / badges */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}
.tag-standard { background: #dbeafe; color: #1e40af; }
.tag-attention { background: #fef3c7; color: #92400e; }
.tag-high { background: #fee2e2; color: #991b1b; }

/* Item list */
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.item-row:last-child { border-bottom: none; }
.item-row .color-bar {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}
.item-row .info { flex: 1; min-width: 0; }
.item-row .info .name { font-weight: 600; font-size: 15px; }
.item-row .info .meta { font-size: 13px; color: var(--muted); }
.item-row .rfl-id { font-family: monospace; font-size: 13px; color: var(--muted); }

/* Search */
.search-bar {
  position: relative;
  margin-bottom: 16px;
}
.search-bar input {
  padding-left: 40px;
  font-size: 17px;
}
.search-bar .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
}

/* Detail page */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.detail-header .color-bar {
  width: 6px;
  height: 48px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}
.detail-header h1 { font-size: 22px; }
.detail-header .rfl-id { font-family: monospace; font-size: 15px; color: var(--muted); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-top: 12px;
}
.detail-grid .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.detail-grid .value { font-size: 15px; }

/* Actions bar */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Audit log */
.audit-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.audit-entry:last-child { border-bottom: none; }
.audit-entry .who { font-weight: 600; }
.audit-entry .when { color: var(--muted); }
.audit-entry .action { margin: 2px 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* Form sections */
.form-section {
  margin-bottom: 24px;
}
.form-section + .form-section {
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Empty state */
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty .icon { font-size: 40px; margin-bottom: 8px; }

/* Utilities */
.flex { display: flex; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.text-muted { color: var(--muted); font-size: 13px; }
.text-sm { font-size: 13px; }
.font-mono { font-family: "SF Mono", "Fira Code", monospace; }
