/* KeyFabrics - Bare functional CSS */
* { box-sizing: border-box; margin: 0; }
body { font-family: system-ui, sans-serif; color: #111; line-height: 1.5; font-size: 14px; }
h2 { font-size: 1.2rem; margin-bottom: 8px; }
h3 { font-size: 1rem; margin-bottom: 6px; }
a { color: #06c; cursor: pointer; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid #ccc; margin: 16px 0; }
p { margin-bottom: 6px; }

nav { background: #222; color: #fff; padding: 6px 12px; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 13px; position: sticky; top: 0; z-index: 100; }
nav .brand { font-weight: 700; margin-right: 10px; }
nav a { color: #ccc; text-decoration: none; padding: 6px 8px; }
nav a:hover, nav a.active { color: #fff; text-decoration: underline; }
nav .spacer { flex: 1; }
nav .user-info { color: #888; font-size: 12px; }
nav .logout-btn { color: #aaa; background: none; border: 1px solid #555; padding: 3px 10px; font-size: 12px; cursor: pointer; margin-left: 8px; }

.page { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }

fieldset { border: 1px solid #ccc; padding: 12px; margin-bottom: 12px; }
legend { font-weight: 600; font-size: 13px; }
label { display: block; margin-bottom: 8px; font-size: 13px; }
label input, label select, label textarea { display: block; margin-top: 2px; }
input, select, textarea { padding: 5px 8px; font-size: 13px; border: 1px solid #aaa; width: 100%; max-width: 360px; }
input[type="checkbox"], input[type="file"] { width: auto; max-width: none; }
textarea { min-height: 50px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.form-hint { font-size: 11px; color: #888; }

button, .btn { padding: 5px 14px; font-size: 13px; cursor: pointer; border: 1px solid #999; background: #f5f5f5; }
button[type="submit"] { background: #333; color: #fff; border-color: #333; }
button:disabled { opacity: 0.5; cursor: wait; }
.btn-sm { padding: 2px 8px; font-size: 12px; }
.btn-primary { background: #333; color: #fff; border-color: #333; }
.btn-secondary { background: #eee; }
.btn-success { background: #060; color: #fff; border-color: #060; }
.btn-danger { background: #900; color: #fff; border-color: #900; }

table { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: 8px; }
th, td { text-align: left; padding: 5px 8px; border: 1px solid #ddd; vertical-align: top; }
th { background: #f0f0f0; font-size: 12px; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fafafa; }

.status { font-size: 12px; font-weight: 600; }
.tag { display: inline-block; background: #eee; border: 1px solid #ddd; padding: 0 5px; font-size: 11px; margin: 1px; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.metric-card { border: 1px solid #ddd; padding: 10px; }
.metric-card .value { font-size: 1.6rem; font-weight: 700; }
.metric-card .label { font-size: 12px; color: #666; text-transform: capitalize; }

.search-bar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.search-bar input { max-width: 240px; }
.search-bar select { max-width: 160px; }

.card { border: 1px solid #ddd; padding: 10px; margin-bottom: 8px; }
.card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 4px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }

.thumb { width: 40px; height: 40px; object-fit: cover; border: 1px solid #ddd; vertical-align: middle; }
.thumb-lg { width: 64px; height: 48px; }

.empty { padding: 24px; text-align: center; color: #888; }
.hidden { display: none; }
.text-muted { color: #888; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid #ccc; border-top-color: #333; border-radius: 50%; animation: spin 0.5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Lightbox */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9999; display: flex; align-items: center; justify-content: center; cursor: pointer; }
#lightbox .lb-img { max-width: 90vw; max-height: 90vh; object-fit: contain; cursor: default; }
#lightbox .lb-close { position: absolute; top: 12px; right: 20px; color: #fff; font-size: 32px; cursor: pointer; line-height: 1; }
#lightbox .lb-prev, #lightbox .lb-next { position: absolute; top: 50%; color: #fff; font-size: 48px; cursor: pointer; user-select: none; line-height: 1; margin-top: -24px; }
#lightbox .lb-prev { left: 16px; }
#lightbox .lb-next { right: 16px; }
#lightbox .lb-counter { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #aaa; font-size: 13px; }

@media (max-width: 600px) {
  nav { font-size: 12px; }
  .page { padding: 10px; }
  .form-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
