:root {
  --primary: #1a5cff;
  --primary-dark: #0f3fc9;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e1e5ee;
  --text: #1f2430;
  --text-muted: #6b7280;
  --danger: #e5484d;
  --radius: 10px;

  --status-대기: #9ca3af;
  --status-출고중: #1a5cff;
  --status-회수예정: #f59e0b;
  --status-수리중: #e5484d;
  --status-회수완료: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system,
    BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(20, 30, 60, 0.08);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef1f8; color: var(--text); }
.btn-secondary:hover { background: #e2e6f2; }
.btn-danger { background: #fdeceb; color: var(--danger); }
.btn-danger:hover { background: #fbdbd9; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.error-box {
  background: #fdeceb;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.error-box.show { display: block; }

.info-box {
  background: #eaf0ff;
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.info-box.show { display: block; }

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* App shell */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar .brand span { color: var(--primary); }

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.toolbar input, .toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}

.toolbar .spacer { flex: 1; }

.summary-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 110px;
}

.summary-card .num { font-size: 22px; font-weight: 700; }
.summary-card .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1080px; }

thead th {
  text-align: left;
  padding: 10px 12px;
  background: #f8f9fc;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

thead th[data-sort] {
  cursor: pointer;
  user-select: none;
}
thead th[data-sort]:hover {
  color: var(--text);
}
thead th.sorted {
  color: var(--primary);
}
.sort-indicator {
  display: inline-block;
  width: 10px;
  margin-left: 2px;
  font-size: 10px;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr .row-actions { cursor: default; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 4px 10px; font-size: 12px; }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 40, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { margin-top: 0; font-size: 18px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.form-grid .full { grid-column: 1 / -1; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
}

.history-list {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 16px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
}

.history-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.history-item-time { color: var(--text-muted); font-size: 12px; }

.history-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.history-badge.created { background: #16a34a; }
.history-badge.updated { background: var(--primary); }
.history-badge.deleted { background: var(--danger); }

.history-item-move {
  font-weight: 600;
  margin-bottom: 6px;
}

.history-item-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  color: var(--text-muted);
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 0;
  font-size: 13px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--primary);
  background: #f5f8ff;
  outline: none;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eaf0ff;
  color: var(--primary);
}

.dropzone.uploading {
  cursor: wait;
  opacity: 0.7;
}

.attachment-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
  background: #f8f9fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.attachment-preview a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview button {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 12px;
}

.field label.required::after {
  content: " *";
  color: var(--danger);
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .container { padding: 14px; }
}
