/* Fluent-style CSS for the EAMS shell: Microsoft 365 / ServiceNow inspired
   layout with left app bar, command bar, cards, tables, charts and forms. */

:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e1e6ee;
  --text: #1b2330;
  --muted: #5b6b82;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --ok: #0a7c42;
  --warn: #b45309;
  --bad: #b91c1c;
  --sidebar: #0b1220;
  --sidebar-w: 236px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .05);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .3em 0; }
small, .muted { color: var(--muted); }

/* ---------------- layout ---------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--sidebar); color: #cfd8e6;
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 14px; color: #fff; font-weight: 600; font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: .8rem; font-weight: 700;
}
.brand small { display: block; color: #8fa1bb; font-weight: 400; font-size: .68rem; }
.nav { padding: 10px 10px 20px; flex: 1; }
.nav .section {
  font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: #7487a3; margin: 14px 8px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: #cfd8e6; padding: 8px 10px; border-radius: 8px;
  font-size: .92rem; margin: 1px 0;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .ico { width: 20px; text-align: center; opacity: .9; }
.nav a .pill {
  margin-left: auto; background: rgba(255,255,255,.16); border-radius: 10px;
  font-size: .7rem; padding: 1px 8px;
}
.nav a.active .pill { background: rgba(255,255,255,.28); }
.me {
  border-top: 1px solid rgba(255,255,255,.08); padding: 12px 14px;
  display: flex; gap: 10px; align-items: center;
}
.me .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #2563eb;
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .8rem;
}
.me .who { line-height: 1.2; }
.me .who b { color: #fff; font-size: .85rem; display: block; }
.me .who span { color: #8fa1bb; font-size: .72rem; }
.me form { margin-left: auto; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 26px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.searchform { flex: 1; max-width: 560px; }
.searchform input {
  width: 100%; padding: 9px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: .92rem;
}
.searchform input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.topbar .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.bell { position: relative; font-size: 1.15rem; color: var(--muted); text-decoration: none; }
.bell .dot {
  position: absolute; top: -4px; right: -6px; background: var(--bad);
  color: #fff; font-size: .62rem; border-radius: 9px; padding: 1px 5px;
}
.content { padding: 24px 26px 46px; max-width: 1500px; width: 100%; }

/* ---------------- components ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card h2 { margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1200px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.stat { display: flex; gap: 14px; align-items: center; }
.stat .ic {
  width: 44px; height: 44px; border-radius: 10px; flex: 0 0 44px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; background: #eaf1ff; color: var(--accent);
}
.stat.warn .ic { background: #fef3c7; color: var(--warn); }
.stat.bad .ic { background: #fee2e2; color: var(--bad); }
.stat.ok .ic { background: #dcfce7; color: var(--ok); }
.stat .num { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .82rem; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px; margin-bottom: 8px;
}
.stats-grid .card:hover { border-color: var(--accent); }
.doc-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 10px; }
.doc-thumb {
  width: 86px; height: 86px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); background: #f3f4f6;
}
.doc-thumb:hover { border-color: var(--accent); }

/* ---- dashboard credit-card tiles ---- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.tile {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-height: 118px;
  text-decoration: none; color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease,
              border-color .12s ease;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(30, 60, 120, .12);
}
.tile-ic {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; background: #eaf1ff; color: var(--accent);
}
.tile.ok .tile-ic { background: #dcfce7; }
.tile.warn .tile-ic { background: #fef3c7; }
.tile.bad .tile-ic { background: #fee2e2; }
.tile-num { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.tile-lbl { color: var(--muted); font-size: .82rem; }

/* ---- register row thumbnails & doc pills ---- */
.cell-asset { display: flex; align-items: center; gap: 10px; }
.row-thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); background: #f3f4f6; flex: 0 0 44px;
}
.row-thumb.empty {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #b6bfd0;
}
.doc-pill {
  display: inline-block; min-width: 34px; text-align: center;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 9px; font-size: .8rem; text-decoration: none;
  background: #f8fafc; color: var(--text);
}
.doc-pill:hover { border-color: var(--accent); color: var(--accent); }
.doc-pill.none{ border-style: dashed; color: #b6bfd0; }

/* ---- custom roles: permission matrix ---- */
.perm-matrix td{padding:4px 8px;text-align:center}
.perm-matrix td:first-child{text-align:left}
.perm-matrix .perm-group{background:var(--bg-soft, #f4f5f7);font-weight:600;
  text-align:left;padding:6px 8px}
.perm-matrix code{font-size:12px}

/* ---- asset detail hero photo ---- */
.hero-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.hero-photo.empty {
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  border-style: dashed;
  background: var(--bg);
  color: var(--muted);
}

.hero-photo.empty span { font-size: 24px; line-height: 1; }
.hero-photo.empty small { font-size: 10px; }
.hero-photo.empty:hover { border-color: var(--primary); color: var(--primary); }
.qr-frame {
  display: inline-block;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.secret-block {
  display: block;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: .12em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  user-select: all;
}

@media (max-width: 700px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .row-thumb { width: 36px; height: 36px; flex-basis: 36px; }
}

.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 8px 14px; border-radius: 8px;
  font-size: .9rem; cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4fd7; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.small { padding: 4px 10px; font-size: .8rem; }
.btn.approve { color: var(--ok); border-color: #bbf7d0; }
.btn.reject { color: var(--bad); border-color: #fecaca; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: .76rem;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 9px 10px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.tbl td { padding: 10px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.tbl tr:hover td { background: #f7f9fc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .74rem; font-weight: 600; background: #eef2f7; color: #44506a;
}
.badge.assigned, .badge.approved, .badge.completed, .badge.active { background: #dcfce7; color: var(--ok); }
.badge.in_repair, .badge.in_progress, .badge.scheduled, .badge.pending { background: #fef3c7; color: var(--warn); }
.badge.disposed, .badge.lost, .badge.rejected, .badge.cancelled, .badge.overdue { background: #fee2e2; color: var(--bad); }
.badge.in_inventory, .badge.returned, .badge.resolved, .badge.closed { background: #e0f2fe; color: #0369a1; }
.badge.critical { background: #fee2e2; color: var(--bad); }
.badge.high { background: #ffedd5; color: #c2410c; }
.badge.medium { background: #fef3c7; color: var(--warn); }
.badge.low { background: #e0f2fe; color: #0369a1; }
.badge.new { background: #ede9fe; color: #6d28d9; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.chart { width: 100%; height: auto; }
.donut-wrap { display: flex; gap: 16px; align-items: center; }
.donut-wrap svg { flex: 0 0 180px; max-width: 180px; }
.donut-total { font-size: 1.6rem; font-weight: 700; fill: var(--text); }
.donut-sub { font-size: .7rem; fill: var(--muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: .84rem; }
.donut-legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.donut-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-label { font-size: 11px; fill: var(--muted); }
.bar-value { font-size: 10.5px; fill: var(--text); font-weight: 600; }
.axis { font-size: 10px; fill: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 26px 0; }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; color: #33415c; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: .9rem; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}
.field .hint { font-size: .74rem; color: var(--muted); margin-top: 3px; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar select, .toolbar input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .88rem; background: #fff;
}

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }

/* login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #1e3a8a 0%, #0b1220 55%);
  padding: 20px;
}
.login-card {
  width: 420px; max-width: 96vw; background: var(--surface);
  border-radius: 14px; padding: 34px; box-shadow: 0 24px 60px rgba(0,0,0,.4);
}
.login-card .brandline { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.login-card h1 { font-size: 1.3rem; }
.login-card .field { margin-bottom: 14px; }
.demo-accounts { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 14px; }
.demo-accounts table { width: 100%; font-size: .8rem; }
.demo-accounts td { padding: 4px 6px; border-bottom: 1px solid #eef1f6; }
.mfa-note { background: #eaf1ff; border: 1px solid #cfe0ff; color: #1e40af;
  padding: 9px 12px; border-radius: 8px; font-size: .82rem; margin-bottom: 14px; }

/* asset detail */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 170px 1fr; row-gap: 7px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid #e5eaf2; margin-left: 6px; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}
.timeline .when { font-size: .74rem; color: var(--muted); }
.codes { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; }
.codes .code-box { text-align: center; }
.codes .code-box svg { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.qr-big svg { width: 190px; height: 190px; }
.bar-svg svg { max-width: 100%; }

/* label sheet */
.label-sheet { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.label {
  border: 1px dashed #94a3b8; border-radius: 8px; padding: 12px;
  display: flex; gap: 12px; align-items: center; background: #fff;
}
.label svg { width: 92px; height: 92px; flex: 0 0 92px; }
.label .t { font-weight: 700; font-size: .95rem; }
.label .s { font-size: .78rem; color: var(--muted); }

/* notifications */
.notif { border-left: 3px solid var(--accent); background: #f8faff; padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; }
.notif.unread { background: #eef4ff; }
.notif .when { color: var(--muted); font-size: .76rem; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: .86rem; }
.pager a, .pager span.cur { padding: 5px 11px; border: 1px solid var(--border); border-radius: 7px; }
.pager span.cur { background: var(--accent); color: #fff; border-color: var(--accent); }

.flash { padding: 11px 15px; border-radius: 9px; margin-bottom: 16px; font-size: .9rem; }
.flash.ok { background: #dcfce7; color: var(--ok); border: 1px solid #bbf7d0; }
.flash.err { background: #fee2e2; color: var(--bad); border: 1px solid #fecaca; }

.inline-form { display: inline; }
.signature-pad {
  width: 100%; height: 110px; border: 1px dashed var(--border); border-radius: 8px;
  background: #fff; touch-action: none; cursor: crosshair;
}
.qr-scan { display: flex; gap: 18px; flex-wrap: wrap; }
.scan-demo { background: var(--surface-2); border: 1px solid var(--border); padding: 16px; border-radius: 10px; }

.footer-note { color: var(--muted); font-size: .78rem; margin-top: 30px; text-align: center; }
@media print {
  .sidebar, .topbar, .toolbar, .actions, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
}
