/* Lab Management Web Frontend */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f4f6f8; color: #333; }

/* Header */
header { background: #1e3a5f; color: #fff; padding: 12px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
header h1 { font-size: 18px; font-weight: 600; }
.auth-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.auth-bar input { padding: 6px 10px; border: 1px solid #4a7ab5; border-radius: 4px; background: #2d5a8e; color: #fff; width: 220px; font-size: 13px; }
.auth-bar input::placeholder { color: #aac4e0; }

/* Tabs */
.tab-bar { background: #16304d; padding: 0 24px; display: none; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.tab-bar button { background: none; border: none; color: #8ab; padding: 10px 18px; font-size: 14px; cursor: pointer; border-bottom: 3px solid transparent; transition: color .15s; }
.tab-bar button:hover { color: #fff; }
.tab-bar button.active { color: #fff; border-bottom-color: #4a9eff; font-weight: 600; }

/* Buttons */
.btn { padding: 6px 14px; border: none; border-radius: 4px; background: #4a9eff; color: #fff; cursor: pointer; font-size: 13px; transition: background .15s, opacity .2s; }
.btn:hover { background: #3a8eef; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-green { background: #27ae60; }
.btn-green:hover:not(:disabled) { background: #219a52; }
.btn-red { background: #c0392b; }
.btn-red:hover:not(:disabled) { background: #a93226; }
.btn-outline { background: #fff; color: #333; border: 1px solid #ccc; }
.btn-outline:hover:not(:disabled) { background: #f0f0f0; }
.auth-status { font-size: 12px; padding: 2px 8px; border-radius: 3px; }
.auth-ok { background: #27ae60; }
.auth-err { background: #c0392b; }

/* Layout */
main { max-width: 960px; margin: 24px auto; padding: 0 16px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { flex: 1; min-width: 160px; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.08); padding: 20px; margin-bottom: 16px; }

/* Toast */
.toast { position: fixed; top: 16px; right: 16px; z-index: 999; padding: 10px 20px; border-radius: 6px; color: #fff; font-size: 14px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.visible { opacity: 1; }
.toast-ok { background: #27ae60; }
.toast-err { background: #c0392b; }

/* Section title */
.section-title { font-size: 15px; font-weight: 600; color: #1e3a5f; margin-bottom: 10px; }

/* List items */
.item-row { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid #eee; cursor: pointer; transition: background .15s; gap: 6px; }
.item-row:hover { background: #f0f4f8; }
.item-row:last-child { border-bottom: none; }
.item-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.item-code { font-family: "Courier New", monospace; color: #1e3a5f; font-size: 13px; white-space: nowrap; }
.item-badge { font-size: 12px; padding: 2px 8px; border-radius: 3px; white-space: nowrap; }
.status-active { background: #d4edda; color: #155724; }
.status-inactive { background: #f8d7da; color: #721c24; }
.status-maintenance { background: #fff3cd; color: #856404; }
.status-decommissioned { background: #e2e3e5; color: #383d41; }
.badge-hazard { background: #ffeeba; color: #856404; }
.badge-storage { background: #e8f0fe; color: #1e3a5f; }
.list-count { font-size: 12px; color: #888; margin-bottom: 8px; padding-left: 2px; }

/* Detail views */
.detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-title { font-size: 20px; font-weight: 600; flex: 1; min-width: 0; }
.detail-grid { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; }
.detail-label { font-weight: 600; color: #666; }
.detail-hint { font-size: 13px; color: #888; margin-top: 12px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 140px 1fr; gap: 10px 12px; font-size: 14px; align-items: center; }
.form-grid label { font-weight: 600; color: #555; }
.form-grid input, .form-grid select, .form-grid textarea { padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; font-family: inherit; transition: border-color .2s; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: none; border-color: #4a9eff; box-shadow: 0 0 0 2px rgba(74,158,255,.15); }
.form-grid input.field-error, .form-grid select.field-error { border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192,57,43,.1); }
.form-grid textarea { resize: vertical; min-height: 50px; }
.form-grid .required::after { content: " *"; color: #c0392b; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 12px; }
.form-error { grid-column: 1 / -1; color: #c0392b; font-size: 13px; padding: 6px 0; display: none; }
.form-row-inline { display: flex; gap: 8px; }
.form-row-inline input { flex: 1; }
.form-row-inline select { width: 80px; }

/* Delete confirm */
.delete-confirm { display: none; padding: 14px; background: #fdf0ef; border: 1px solid #e8c4c0; border-radius: 6px; margin-top: 14px; }
.delete-confirm p { margin-bottom: 10px; color: #721c24; font-size: 14px; }

/* Messages */
.msg { text-align: center; padding: 32px 16px; color: #999; font-size: 14px; }
.msg-icon { font-size: 28px; margin-bottom: 6px; display: block; }
.err { color: #c0392b; }

/* Dashboard */
.kpi-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 18px 16px; text-align: center; cursor: pointer; transition: box-shadow .2s, transform .15s; }
.kpi-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.1); transform: translateY(-1px); }
.kpi-value { font-size: 32px; font-weight: 700; color: #1e3a5f; }
.kpi-label { font-size: 13px; color: #666; margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dist-row { display: flex; align-items: center; padding: 5px 0; font-size: 13px; border-bottom: 1px solid #f0f0f0; }
.dist-row:last-child { border-bottom: none; }
.dist-label { flex: 1; }
.dist-count { font-weight: 600; color: #1e3a5f; min-width: 40px; text-align: right; }
.dist-bar { height: 6px; border-radius: 3px; background: #4a9eff; margin-left: 8px; transition: width .3s; }

/* Responsive */
@media (max-width: 768px) {
    .tab-bar { padding: 0 12px; }
    .tab-bar button { padding: 10px 12px; font-size: 13px; }
}
@media (max-width: 600px) {
    header { padding: 10px 12px; gap: 10px; }
    header h1 { font-size: 16px; }
    .auth-bar input { width: 150px; }
    main { padding: 0 10px; margin-top: 16px; }
    .card { padding: 14px; }
    .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .form-grid label { margin-top: 4px; }
    .dash-grid { grid-template-columns: 1fr; }
    .detail-header { gap: 6px; }
    .detail-title { font-size: 17px; }
    .kpi-card { padding: 14px 10px; }
    .kpi-value { font-size: 26px; }
}
