@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700&display=swap');

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

:root {
  --bg: #fafaf7;
  --bg-warm: #f5f5f0;
  --bg-white: #ffffff;
  --border: #eeede8;
  --border-light: #f5f4f0;
  --text: #111111;
  --text-secondary: #6b6b6b;
  --text-muted: #ababab;
  --accent: #111111;

  --green: #1a7f37;
  --green-bg: #dafbe1;
  --green-pill: #dafbe1;
  --yellow: #9a6700;
  --yellow-bg: #fff8c5;
  --yellow-pill: #fff8c5;
  --red: #cf222e;
  --red-bg: #ffebe9;
  --red-pill: #ffebe9;
  --pink-bg: #fff0f0;
  --peach-bg: #fff8f0;
  --blue: #0969da;
  --blue-bg: #ddf4ff;
  --blue-pill: #ddf4ff;

  --sidebar-width: 240px;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 100px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.08);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

::selection { background: #e8e8e3; }

/* ═══════════ Login ═══════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--bg-white);
  border-radius: 24px;
  padding: 52px 48px;
  width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.login-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 36px;
}

/* ═══════════ Layout ═══════════ */
.app-layout { display: flex; min-height: 100vh; }

/* ═══════════ Sidebar ═══════════ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  padding: 32px 24px 28px;
}

.sidebar-brand h2 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.4px;
}

.sidebar-brand span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s var(--ease);
  margin-bottom: 1px;
}

.sidebar-nav a:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-nav a.active {
  background: var(--text);
  color: white;
}

.sidebar-nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
}

.sidebar-nav a:hover svg { opacity: 0.7; }
.sidebar-nav a.active svg { opacity: 0.9; }

.sidebar-nav .nav-section {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 24px 12px 6px;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer .user-name { font-weight: 600; font-size: 12px; }
.sidebar-footer .user-role { font-size: 11px; color: var(--text-muted); }

.sidebar-footer button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 0;
  font-family: inherit;
  transition: color 0.15s;
}

.sidebar-footer button:hover { color: var(--red); }

/* ═══════════ Main ═══════════ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: 40px 48px 0;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.8px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

.page-body {
  padding: 32px 48px 48px;
}

/* ═══════════ Pills ═══════════ */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.1px;
}

.pill-dark { background: var(--text); color: white; }
.pill-green { background: var(--green-pill); color: var(--green); }
.pill-red { background: var(--red-pill); color: var(--red); }
.pill-yellow { background: var(--yellow-pill); color: var(--yellow); }
.pill-blue { background: var(--blue-pill); color: var(--blue); }
.pill-gray { background: var(--bg-warm); color: var(--text-secondary); }

.pills-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 32px;
}

/* ═══════════ Cards ═══════════ */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.card-body { padding: 24px; }

/* Info cards */
.info-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: box-shadow 0.2s var(--ease);
}

.info-card:hover { box-shadow: var(--shadow); }

.info-card .info-card-label { font-size: 14px; font-weight: 500; }
.info-card .info-card-value { font-size: 13px; color: var(--text-muted); }

.info-card .info-card-icon {
  color: var(--text-muted);
  opacity: 0.25;
  transition: opacity 0.15s;
}
.info-card .info-card-icon:hover { opacity: 0.5; }

.info-card.card-pink { background: var(--pink-bg); border-color: #fecdd3; }
.info-card.card-peach { background: var(--peach-bg); border-color: #fed7aa; }
.info-card.card-green { background: var(--green-bg); border-color: #bbf7d0; }
.info-card.card-blue { background: var(--blue-bg); border-color: #bfdbfe; }

.info-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 1100px) {
  .info-cards-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════ Summary Cards ═══════════ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.summary-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.summary-card .label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.summary-card .value {
  font-size: 28px;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: -1px;
  line-height: 1;
}

.summary-card .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.summary-card.green .value { color: var(--green); }
.summary-card.yellow .value { color: var(--yellow); }
.summary-card.red .value { color: var(--red); }

/* ═══════════ Asset Grid ═══════════ */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.asset-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.asset-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #ddd;
}

.asset-card .asset-card-icon {
  width: 64px;
  height: 64px;
  background: var(--bg);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset-card .asset-card-icon svg {
  width: 28px;
  height: 28px;
  opacity: 0.4;
}

.asset-card .asset-card-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.asset-card .asset-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -8px;
}

.asset-card .asset-card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.asset-card .asset-card-tags .tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.tag-active { background: var(--green-pill); color: var(--green); }
.tag-out_of_service { background: var(--red-pill); color: var(--red); }
.tag-decommissioned { background: var(--bg-warm); color: var(--text-muted); }
.tag-pending_disposal { background: var(--yellow-pill); color: var(--yellow); }

/* Equipment icons */
.equip-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.equip-icon svg { width: 22px; height: 22px; }

.equip-icon.cat-anesthesia { background: #f3e8ff; color: #7c3aed; }
.equip-icon.cat-surgical { background: #fef9c3; color: #a16207; }
.equip-icon.cat-imaging { background: #e0f2fe; color: #0369a1; }
.equip-icon.cat-infusion { background: #fce7f3; color: #be185d; }
.equip-icon.cat-monitoring { background: #ddf4ff; color: #0969da; }
.equip-icon.cat-sterilization { background: #d1fae5; color: #059669; }
.equip-icon.cat-endoscopy { background: #fef3c7; color: #d97706; }
.equip-icon.cat-other { background: var(--bg-warm); color: var(--text-muted); }

/* ═══════════ Grids ═══════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

@media (max-width: 1200px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ═══════════ Tables ═══════════ */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

table tbody tr { transition: background 0.1s; }
table tbody tr:hover { background: var(--bg); }
table tbody tr:last-child td { border-bottom: none; }
table tbody tr.clickable { cursor: pointer; }

/* ═══════════ Badges ═══════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: var(--green-pill); color: var(--green); }
.badge-yellow { background: var(--yellow-pill); color: var(--yellow); }
.badge-red { background: var(--red-pill); color: var(--red); }
.badge-gray { background: var(--bg-warm); color: var(--text-secondary); }
.badge-blue { background: var(--blue-pill); color: var(--blue); }

/* ═══════════ Forms ═══════════ */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-white);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ═══════════ Buttons ═══════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text);
  transition: all 0.15s var(--ease);
  text-decoration: none;
}

.btn:hover { background: var(--bg); }

.btn-primary {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.btn-primary:hover { background: #333; border-color: #333; }

.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-danger:hover { background: #a40e26; border-color: #a40e26; }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-group { display: flex; gap: 8px; }

/* ═══════════ Filters ═══════════ */
.filters-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters-bar input,
.filters-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-white);
  transition: border-color 0.15s;
}

.filters-bar input:focus,
.filters-bar select:focus {
  outline: none;
  border-color: var(--text);
}

.filters-bar input[type="search"] { width: 260px; }

/* View toggle */
.view-toggle {
  display: flex;
  background: var(--bg-warm);
  border-radius: 8px;
  padding: 2px;
}

.view-toggle button {
  padding: 5px 12px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: all 0.15s;
}

.view-toggle button.active {
  background: var(--bg-white);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* ═══════════ Alerts ═══════════ */
.alert-item {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 14px;
  transition: background 0.1s;
}

.alert-item:hover { background: var(--bg); }
.alert-item:last-child { border-bottom: none; }
.alert-item.unread { background: var(--bg-warm); }

.alert-item .alert-severity {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.alert-item .alert-severity.critical { background: var(--red); }
.alert-item .alert-severity.warning { background: var(--yellow); }
.alert-item .alert-severity.info { background: var(--blue); }

.alert-item .alert-content { flex: 1; }
.alert-item .alert-title { font-weight: 500; font-size: 13px; }
.alert-item .alert-desc { font-size: 13px; color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }
.alert-item .alert-meta { font-size: 12px; color: var(--text-muted); margin-top: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.alert-item .alert-actions { display: flex; gap: 6px; align-items: flex-start; }

/* ═══════════ Details ═══════════ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}

.detail-item .detail-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.detail-item .detail-value {
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
}

/* ═══════════ Lifecycle bar ═══════════ */
.lifecycle-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.lifecycle-bar .fill { height: 100%; border-radius: 3px; transition: width 0.6s var(--ease); }
.lifecycle-bar .fill.green { background: var(--green); }
.lifecycle-bar .fill.yellow { background: var(--yellow); }
.lifecycle-bar .fill.red { background: var(--red); }

/* ═══════════ Cost bar ═══════════ */
.cost-bar { display: flex; align-items: center; gap: 10px; margin: 10px 0; }

.cost-bar .bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.cost-bar .bar-fill {
  height: 100%;
  background: var(--text);
  border-radius: 3px;
  transition: width 0.6s var(--ease);
}

.cost-bar .bar-label {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  min-width: 70px;
  text-align: right;
}

/* ═══════════ Modal ═══════════ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s var(--ease);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-white);
  border-radius: 20px;
  width: 560px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 24px 28px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.modal-header .close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.modal-header .close-btn:hover { color: var(--text); }

.modal-body { padding: 0 28px 28px; }

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ═══════════ Tabs ═══════════ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ═══════════ Empty state ═══════════ */
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-muted); }
.empty-state p { font-size: 14px; margin-top: 8px; }

.status-compliant { color: var(--green); }
.status-due-soon { color: var(--yellow); }
.status-overdue { color: var(--red); }

/* ═══════════ Toast ═══════════ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: toastIn 0.25s var(--ease);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════ Charts ═══════════ */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 0 4px; }

.bar-chart .bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar-chart .bar {
  width: 100%;
  max-width: 40px;
  background: var(--text);
  border-radius: 4px 4px 0 0;
  transition: height 0.6s var(--ease);
  min-height: 2px;
  opacity: 0.8;
}

.bar-chart .bar-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
  white-space: nowrap;
}

.bar-chart .bar-value {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ═══════════ Back link ═══════════ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 24px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--text); }

/* ═══════════ Hero ═══════════ */
.hero-heading {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1.15;
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
  margin-bottom: 14px;
}

/* ═══════════ Utility ═══════════ */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-28 { margin-bottom: 28px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.hidden { display: none !important; }
.scroll-list { max-height: 400px; overflow-y: auto; }

/* ═══════════ Scrollbar ═══════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════ Focus ═══════════ */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
