/* ============================================================
   Four Seasons Hotel Jeddah — T&C Management System
   Design system / global styles
   ============================================================ */

:root {
  --navy-950: #0a1530;
  --navy-900: #0d1b3f;
  --navy-800: #122451;
  --navy-700: #17306a;
  --gold: #c9a24b;
  --gold-light: #e4c874;

  --blue-600: #2f5fdb;
  --blue-700: #2650bd;
  --blue-50: #eaf0ff;
  --blue-100: #dbe6ff;

  --green-600: #16a34a;
  --green-700: #0f7a37;
  --green-50: #e9f9ef;

  --orange-600: #ea8a1f;
  --orange-50: #fef3e6;

  --purple-600: #7c5cf0;
  --purple-50: #f1edfe;

  --teal-600: #0e9daa;
  --teal-50: #e6f8fa;

  --red-600: #dc3545;
  --red-50: #fdeaec;

  --gray-25: #fafbfc;
  --gray-50: #f6f7fb;
  --gray-100: #eef0f5;
  --gray-200: #e3e6ee;
  --gray-300: #d3d7e2;
  --gray-400: #a7adbd;
  --gray-500: #7c8296;
  --gray-600: #5b6072;
  --gray-700: #414659;
  --gray-800: #2b2f3d;
  --gray-900: #1a1d29;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.16);

  --sidebar-w: 250px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
svg { display: block; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--blue-600);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }

/* ============================== Layout ============================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900) 60%, var(--navy-800));
  color: #cdd6ec;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform 0.25s ease, width 0.25s ease;
}

.sidebar-brand {
  padding: 20px 22px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-mark {
  width: 40px; height: 40px;
  margin: 0 auto 10px;
  color: var(--gold-light);
}

.brand-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.brand-logos .midad-logo {
  height: 24px;
  width: auto;
}
.brand-logos .fs-logo {
  height: 52px;
  width: auto;
  filter: brightness(0) invert(1);
}
.brand-logos .brand-divider {
  color: rgba(255, 255, 255, 0.25);
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
}

.sidebar-brand .brand-name {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 2px;
  font-size: 16px;
  color: #fff;
  font-weight: 600;
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--gold-light);
  margin-top: 2px;
}

.sidebar-brand .brand-system {
  margin-top: 14px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #8b93b3;
  text-transform: uppercase;
  font-weight: 600;
}

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

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: #b7bfd9;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-item .icon { color: #8a93b8; transition: color 0.15s ease; }

.sidebar-nav .nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.sidebar-nav .nav-item:hover .icon { color: #fff; }

.sidebar-nav .nav-item.active {
  background: var(--blue-600);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.sidebar-nav .nav-item.active .icon { color: #fff; }

.sidebar-foot {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-foot-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-user-wrap { flex: 1; min-width: 0; }

.sidebar-foot .icon-btn {
  color: #8b93b3;
  flex-shrink: 0;
}
.sidebar-foot .icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-foot .badge-dot { border-color: var(--navy-800); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  border-radius: var(--radius-md);
  position: relative;
}
.sidebar-user:hover { background: rgba(255,255,255,0.06); }

.sidebar-user .user-meta { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: #8b93b3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  border: 0;
  padding: 0;
  background: var(--gold);
  color: #3a2c05;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600);
  position: relative;
}
.icon-btn:hover { background: var(--gray-100); color: var(--gray-800); }

.badge-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 16px; height: 16px;
  background: var(--red-600);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 26px 28px 60px;
  max-width: 1600px;
  width: 100%;
}

/* ============================== Page header ============================== */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header p {
  margin: 0;
  color: var(--gray-500);
  font-size: 13.5px;
}

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================== Buttons ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); }

.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); }

.btn-danger { background: #fff; color: var(--red-600); border-color: #f2c6cc; }
.btn-danger:hover { background: var(--red-50); }

.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================== Stat cards ============================== */

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

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--blue-50); color: var(--blue-600); }
.stat-icon.green { background: var(--green-50); color: var(--green-600); }
.stat-icon.orange { background: var(--orange-50); color: var(--orange-600); }
.stat-icon.purple { background: var(--purple-50); color: var(--purple-600); }
.stat-icon.teal { background: var(--teal-50); color: var(--teal-600); }
.stat-icon.red { background: var(--red-50); color: var(--red-600); }

.stat-body { min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--gray-500); font-weight: 600; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.stat-sub { font-size: 11.5px; color: var(--gray-400); margin-top: 4px; }
.stat-sub.up { color: var(--green-600); }
.stat-sub.warn { color: var(--orange-600); }
.stat-sub.danger { color: var(--red-600); }
.stat-sub.link { color: var(--blue-600); font-weight: 600; }

/* ============================== Card / panel ============================== */

.panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header h3 { margin: 0; font-size: 15.5px; font-weight: 700; color: var(--gray-900); }
.panel-body { padding: 20px; }

/* Dashboard "Progress by Volume" — horizontal bars, one per volume, scaled
   relative to the largest volume so they use the panel's full width. */
.vol-progress-list { display: flex; flex-direction: column; gap: 14px; }
.vol-progress-row { display: flex; align-items: center; gap: 16px; }
.vol-progress-label {
  display: flex; align-items: center; gap: 8px;
  width: 150px; flex-shrink: 0;
  font-size: 13px; color: var(--gray-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vol-progress-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.vol-progress-track { flex: 1; height: 10px; background: var(--gray-100); border-radius: var(--radius-full); overflow: hidden; }
.vol-progress-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.3s ease; }
.vol-progress-value {
  width: 110px; flex-shrink: 0; text-align: right;
  font-size: 12.5px; font-weight: 700; color: var(--gray-700); white-space: nowrap;
}

/* ============================== Toolbar / filters ============================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* Wraps a primary .toolbar plus a collapsible .toolbar-extra row as one
   continuous panel, so "More Filters" expands in place instead of
   popping in a separate bordered card. */
.toolbar-panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  padding: 14px 16px;
}
.toolbar-panel .toolbar {
  background: none; border: none; box-shadow: none; padding: 0; margin-bottom: 0;
}
.toolbar-extra {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

.search-input {
  flex: 1 1 220px;
  min-width: 180px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-input .icon { position: absolute; left: 12px; color: var(--gray-400); }
.search-input input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--gray-25);
}
.search-input input:focus { outline: none; border-color: var(--blue-600); background: #fff; }

.select, select.select {
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--gray-700);
  font-size: 13px;
  min-width: 130px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%237c8296' stroke-width='1.5' fill='none' fill-rule='evenodd'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.select:focus { outline: none; border-color: var(--blue-600); }
.select:disabled { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }

/* ============================== Tables ============================== */

.table-wrap { overflow-x: auto; }

table.data-table {
  /* auto width (not a fixed 100%) lets table-layout:auto size each column
     to its own content instead of squeezing every column to fit the panel;
     min-width keeps narrow tables filling the panel as before, and
     .table-wrap's overflow-x:auto kicks in once content needs more room. */
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  position: relative;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--gray-500);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  /* Only bites once a column has been manually narrowed below its content's
     natural width (see js/table-resize.js) — table-layout:auto never
     shrinks a column past its content, so this is a no-op until then. */
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gray-700);
  vertical-align: middle;
  text-align: left;
  /* Cells default to one line so each column's width reflects its own
     content instead of wrapping to whatever width the row was squeezed
     into. Cells that intentionally wrap (e.g. long descriptions) opt back
     in with their own white-space: normal / max-width. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------- Resizable columns (js/table-resize.js) ------------------------- */

.col-resize-handle {
  /* Stays fully inside the <th> box (not straddling its edge) — the <th>
     has overflow:hidden for text-ellipsis, which would clip (and kill hit-
     testing on) any part of the handle that stuck outside it. */
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
  touch-action: none;
}
.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; right: 2px;
  width: 2px;
  background: transparent;
}
.col-resize-handle:hover::after, .col-resize-handle.is-resizing::after {
  background: var(--blue-600);
}
body.col-resizing { cursor: col-resize !important; user-select: none !important; }
body.col-resizing * { cursor: col-resize !important; }

.data-table tbody tr:hover { background: var(--gray-25); }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-strong { font-weight: 700; color: var(--gray-900); }
.cell-tag { font-weight: 700; color: var(--blue-600); }
.cell-muted { color: var(--gray-500); font-size: 12.5px; }

.name-cell { display: flex; align-items: center; justify-content: center; gap: 12px; }
#usrTbody .name-cell { width: 250px; max-width: 100%; justify-content: flex-start; }
#orgTbody .name-cell { justify-content: flex-start; text-align: left; }
.name-cell .logo-box {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--navy-900);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.name-cell .cell-muted { font-weight: 400; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; max-width: 220px; }
.chip {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--blue-50);
  color: var(--blue-700);
}
.chip.more { background: var(--gray-100); color: var(--gray-600); }

.org-expand-btn {
  width: 22px; height: 22px; flex-shrink: 0; border: none; background: var(--gray-100); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--gray-500); padding: 0;
}
.org-expand-btn:hover { background: var(--gray-200); color: var(--gray-700); }
.org-expand-btn .icon { transition: transform 0.15s ease; }
.org-expand-btn.expanded .icon { transform: rotate(90deg); }
.org-expand-spacer { width: 22px; height: 22px; flex-shrink: 0; }
.org-row-child { background: var(--gray-25); }
/* Rows here can hold one wrapping multi-line cell (e.g. a contractor's
   full Sub-Systems list) alongside plain one-line cells — top-align the
   whole row so every cell starts at the same line instead of the short
   ones floating centered in a row that's grown tall. */
.data-table tbody tr.org-row-parent > td, .data-table tbody tr.org-row-child > td { vertical-align: top; }
.org-tree-connector { width: 22px; flex-shrink: 0; }
.org-row-parent.is-expanded > td:first-child { position: relative; }
.org-row-parent.is-expanded > td:first-child::after {
  content: "";
  position: absolute;
  /* Anchored to the expand arrow's own bottom edge (14px cell padding +
     centered in the 40px logo row), not the row's midpoint — the row can
     grow much taller than the arrow when a sibling cell wraps onto many
     lines, and the arrow itself stays pinned near the top of the row. */
  left: 24px; top: 45.5px; bottom: 0;
  width: 2px;
  background: var(--gray-300);
}
.org-row-child > td:first-child { position: relative; }
.org-row-child > td:first-child::before {
  content: "";
  position: absolute;
  left: 24px; top: 0; bottom: 0;
  width: 2px;
  background: var(--gray-300);
}
.org-row-child.is-last > td:first-child::before { bottom: 50%; }
.org-row-child > td:first-child::after {
  content: "";
  position: absolute;
  left: 24px; top: 50%;
  width: 10px; height: 2px;
  background: var(--gray-300);
  transform: translateY(-1px);
}
.name-cell .logo-box.logo-box-sm { width: 30px; height: 30px; font-size: 10.5px; }

/* Volumes page hierarchy tree */
.vol-tree-group { margin-bottom: 2px; }
.vol-tree-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-align: left; padding: 8px 10px; border: none; background: none;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--gray-700);
}
.vol-tree-item:hover { background: var(--gray-50); }
.vol-tree-parent { font-weight: 700; color: var(--gray-900); }
.vol-tree-parent .icon { transition: transform 0.15s ease; flex-shrink: 0; color: var(--gray-400); }
.vol-tree-parent.expanded .icon { transform: rotate(90deg); }
.vol-tree-children { padding-left: 6px; }
.vol-tree-level { padding-left: 30px; font-size: 12.5px; color: var(--gray-600); }
.vol-tree-level.active { background: var(--blue-50); color: var(--blue-700); font-weight: 700; }


.add-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.add-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.add-type-card:hover { border-color: var(--blue-600); background: var(--blue-50); }
.add-type-card .icon { color: var(--blue-600); margin-bottom: 6px; }
.add-type-label { font-size: 14.5px; font-weight: 700; color: var(--gray-900); }

.stat-num { font-weight: 700; color: var(--gray-900); text-align: left; }
.stat-num .pct { color: var(--gray-500); font-weight: 500; font-size: 11.5px; }
.num-orange { color: var(--orange-600); }
.num-purple { color: var(--purple-600); }
.num-green { color: var(--green-600); }

/* Pills / badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.pill-green { background: var(--green-50); color: var(--green-700); }
.pill.pill-gray { background: var(--gray-100); color: var(--gray-600); }
.pill.pill-blue { background: var(--blue-50); color: var(--blue-700); }
.pill.pill-purple { background: var(--purple-50); color: var(--purple-600); }
.pill.pill-orange { background: var(--orange-50); color: var(--orange-600); }
.pill.pill-red { background: var(--red-50); color: var(--red-600); }
.pill.no-dot::before { display: none; }

/* .icon-btn is a 38px hit-box with a centered icon, so its glyph sits ~12px
   in from the button's own edge — pull the whole cluster left by that same
   inset so the first icon's glyph lines up with the column header text. */
.action-icons { display: flex; align-items: center; justify-content: flex-start; gap: 6px; margin-left: -12px; }

.qr-thumb {
  width: 40px; height: 40px;
  margin: 0 auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.qr-thumb:hover { border-color: var(--blue-600); }
.qr-thumb img, .qr-thumb canvas { width: 100%; height: 100%; }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--gray-500);
}
.pager-controls { display: flex; align-items: center; gap: 6px; }
.pager-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600);
  font-size: 12.5px;
  font-weight: 600;
}
.pager-btn.active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.pager-btn:hover:not(.active) { background: var(--gray-50); }

/* ============================== Forms ============================== */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--gray-700); }
.field .hint { font-size: 11.5px; color: var(--gray-400); font-weight: 400; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input[type=tel], .field input[type=date],
.field select, .field textarea {
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--gray-800);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-50);
}
.field input:disabled, .field select:disabled { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }

.tag-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--blue-50);
  border: 1px dashed var(--blue-600);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.tag-preview .tag-value { font-size: 18px; font-weight: 800; color: var(--blue-700); letter-spacing: 0.5px; }
.tag-preview .tag-label { font-size: 11.5px; color: var(--gray-500); font-weight: 600; }

.checkbox-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.checkbox-row:hover { background: var(--gray-25); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--blue-600); }
.checkbox-row .cb-meta { flex: 1; }
.checkbox-row .cb-title { font-weight: 600; font-size: 13px; color: var(--gray-800); }
.checkbox-row .cb-sub { font-size: 11.5px; color: var(--gray-500); }

.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

.radio-seg {
  display: inline-flex;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.radio-seg button {
  padding: 8px 16px;
  border: none;
  background: #fff;
  color: var(--gray-600);
  font-size: 12.5px;
  font-weight: 600;
  border-right: 1px solid var(--gray-300);
}
.radio-seg button:last-child { border-right: none; }
.radio-seg button.active { background: var(--blue-600); color: #fff; }

.add-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.add-type-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 16px; border: 1px solid var(--gray-200); border-radius: var(--radius-md);
  background: #fff; text-align: left; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.add-type-card:hover { border-color: var(--blue-600); background: var(--blue-50); }
.add-type-card svg { color: var(--blue-600); }

/* ============================== Modal ============================== */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.18s ease;
  margin: auto;
}
.modal.modal-lg { max-width: 760px; }
.modal.modal-xl { max-width: 1440px; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-header p { margin: 2px 0 0; font-size: 12px; color: var(--gray-500); }
.modal-close {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500); border: none; background: transparent;
}
.modal-close:hover { background: var(--gray-100); }

.modal-body { padding: 22px; max-height: 68vh; overflow-y: auto; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--gray-100);
}
.modal-footer.split { justify-content: space-between; }

/* Modal steps */
.step-bar { display: flex; align-items: center; gap: 6px; padding: 16px 22px 0; }
.step-bar .step {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; color: var(--gray-400); font-weight: 600;
  position: relative;
}
.step-bar .step .dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gray-100); color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 2px solid var(--gray-200);
  position: relative; z-index: 1;
}
.step-bar .step.done .dot { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.step-bar .step.active .dot { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.step-bar .step.active { color: var(--blue-700); }
.step-bar .step-line {
  position: absolute; top: 13px; left: -50%; width: 100%; height: 2px;
  background: var(--gray-200);
}
.step-bar .step:first-child .step-line { display: none; }
.step-bar .step.done .step-line { background: var(--green-600); }

/* ============================== Drawing pin picker ============================== */

.drawing-canvas-wrap {
  position: relative;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #eef1f7;
  cursor: crosshair;
  user-select: none;
}
.drawing-canvas-wrap svg { width: 100%; height: auto; display: block; }
.pin-marker {
  position: absolute;
  width: 22px; height: 22px;
  transform: translate(-50%, -100%);
  pointer-events: none;
}
.drawing-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 20px; color: var(--gray-400); text-align: center;
}

/* ============================== Tabs ============================== */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.tab-btn {
  flex: 0 0 auto;
  padding: 10px 16px;
  border: none; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--gray-800); }
.tab-btn.active { color: var(--blue-600); border-color: var(--blue-600); }

/* ============================== Checklist / stage steps ============================== */

.asset-timeline { display: flex; flex-direction: column; padding: 4px 0; }
.timeline-item { display: flex; align-items: stretch; gap: 14px; }
.timeline-connector-wrap { display: flex; flex-direction: column; align-items: center; width: 28px; flex-shrink: 0; }

.timeline-dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 3px solid var(--gray-200); color: var(--gray-400);
  position: relative; z-index: 1;
}
.timeline-dot .icon { width: 13px; height: 13px; }
.timeline-dot.done { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.timeline-dot.current { background: var(--blue-600); border-color: var(--blue-600); }
.timeline-dot.current::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--blue-600); animation: timelinePulse 1.8s ease-out infinite;
}
@keyframes timelinePulse {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.9); opacity: 0; }
}

.timeline-line { width: 3px; flex: 1; min-height: 20px; background: var(--gray-200); margin: 2px 0; border-radius: 2px; }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-line.done { background: var(--green-600); }
.timeline-line.animated {
  background: linear-gradient(180deg, var(--green-600) 0%, var(--blue-500) 45%, var(--gray-200) 100%);
  background-size: 100% 240%;
  animation: timelineFlow 1.6s linear infinite;
}
@keyframes timelineFlow {
  0% { background-position: 0 0%; }
  100% { background-position: 0 100%; }
}

.timeline-body { flex: 1; padding-bottom: 14px; padding-top: 4px; min-width: 0; }
.timeline-item:last-child .timeline-body { padding-bottom: 0; }
.timeline-milestone .timeline-body { padding-top: 6px; }
.timeline-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.timeline-title { font-size: 13px; font-weight: 700; color: var(--gray-600); }
.timeline-title.done { color: var(--green-700); }
.timeline-title.current { color: var(--blue-700); }
.timeline-pct { font-size: 12px; font-weight: 700; color: var(--gray-400); flex-shrink: 0; }
.timeline-pct.done { color: var(--green-700); }
.timeline-pct.current { color: var(--blue-700); }
.timeline-sub { font-size: 11.5px; color: var(--gray-400); margin-top: 2px; }
.timeline-milestone .timeline-title { font-size: 14px; }
.timeline-milestone .timeline-dot { width: 30px; height: 30px; }

.checklist-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.checklist-item input[type=checkbox] { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--green-600); flex-shrink: 0; }
.checklist-item .cl-title { font-weight: 700; font-size: 13px; color: var(--gray-800); }
.checklist-item .cl-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.checklist-item.checked { background: var(--green-50); border-color: #cdeed9; }
.checklist-item.checked .cl-title { color: var(--green-700); text-decoration: line-through; text-decoration-color: #9bd8b1; }

/* ============================== Empty / misc ============================== */

.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--blue-600); background: var(--blue-50); }
.dropzone-empty, .dropzone-file { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dropzone .icon-lg { width: 30px; height: 30px; color: var(--gray-300); margin-bottom: 4px; }
.dropzone.dragover .icon-lg { color: var(--blue-500); }
.dropzone-file .icon-lg { color: var(--blue-600); }

.doc-file-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.doc-file-card {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  padding: 12px 14px; background: #fff;
}
.doc-file-card .doc-file-icon { color: var(--blue-600); flex-shrink: 0; }
.doc-file-card .doc-file-meta { flex: 1; min-width: 0; }
.doc-file-card .doc-file-meta .cell-strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-file-card .doc-file-actions { display: flex; gap: 4px; flex-shrink: 0; }

.doc-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.doc-item:last-child { border-bottom: none; }
.doc-item .icon { color: var(--gray-400); flex-shrink: 0; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; color: var(--gray-400); gap: 10px;
}
.empty-state .icon-lg { width: 44px; height: 44px; color: var(--gray-300); }
.empty-state h4 { margin: 0; color: var(--gray-600); font-size: 15px; }
.empty-state p { margin: 0; font-size: 13px; max-width: 340px; }

.divider { height: 1px; background: var(--gray-100); margin: 18px 0; }
.section-divider { height: 2px; background: var(--gray-900); }

.section-title { font-size: 16px; font-weight: 700; color: var(--gray-900); margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title-underline { padding-bottom: 12px; border-bottom: 2px solid var(--gray-900); }

.hchain { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 2px 2px 6px; }
.hchain-node {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; min-width: 150px;
  background: var(--gray-25); border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  padding: 10px 14px;
}
.hchain-icon {
  width: 34px; height: 34px; border-radius: var(--radius-md); flex-shrink: 0;
  background: var(--blue-50); color: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
}
.hchain-icon .icon { width: 17px; height: 17px; }
.hchain-text { min-width: 0; }
.hchain-label { font-size: 10.5px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.4px; }
.hchain-value { font-size: 13.5px; font-weight: 700; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.hchain-sub { font-size: 11.5px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.hchain-connector { flex-shrink: 0; color: var(--gray-900); display: flex; align-items: center; margin: 0 4px; }
.hchain-connector .icon { width: 18px; height: 18px; stroke-width: 3; }
.section-num {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--blue-600); color: #fff; font-size: 12.5px; font-weight: 700;
}

.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: stretch; }
.two-col > .panel { display: flex; flex-direction: column; }
.two-col > .panel > .panel-body { flex: 1; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.two-col > *, .three-col > * { min-width: 0; }

/* dropdown menu */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); min-width: 200px; z-index: 60; overflow: hidden;
  animation: fadeIn 0.12s ease;
}
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 14px; font-size: 13px; color: var(--gray-700); background: none; border: none; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--gray-50); }
.dropdown-menu .dd-divider { height: 1px; background: var(--gray-100); margin: 4px 0; }
.dropdown-menu .dd-danger { color: var(--red-600); }

.sidebar-foot .dropdown-menu {
  top: auto;
  right: 0;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 0;
}

.kebab-menu { position: relative; display: inline-block; }

/* toast */
.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--gray-900); color: #fff; padding: 12px 18px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: slideUp 0.2s ease;
}
.toast.success { background: var(--green-700); }
.toast.error { background: var(--red-600); }

/* activity feed */
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-title { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.activity-sub { font-size: 11.5px; color: var(--gray-400); margin-top: 2px; }

.attention-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.attention-row:last-child { border-bottom: none; }
.attention-left { display: flex; align-items: center; gap: 12px; }
.attention-num { font-size: 17px; font-weight: 800; }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #16255a, var(--navy-950) 60%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 34px 30px;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { width: 46px; height: 46px; margin: 0 auto 12px; color: var(--navy-900); }
.login-brand .brand-name { font-family: Georgia, "Times New Roman", serif; letter-spacing: 2px; font-size: 18px; font-weight: 700; color: var(--navy-900); }
.login-brand .brand-sub { font-size: 10px; letter-spacing: 3px; color: var(--gold); margin-top: 3px; font-weight: 700; }
.login-brand .brand-system { margin-top: 10px; font-size: 12px; color: var(--gray-500); }
.login-error {
  background: var(--red-50); color: var(--red-600); border: 1px solid #f3c6cc;
  padding: 10px 12px; border-radius: var(--radius-md); font-size: 12.5px; margin-bottom: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.login-demo {
  margin-top: 20px; padding: 12px 14px; background: var(--gray-50); border-radius: var(--radius-md);
  font-size: 11.5px; color: var(--gray-500);
}
.login-demo strong { color: var(--gray-700); }
.login-demo .cred-row { display: flex; justify-content: space-between; margin-top: 4px; cursor: pointer; }
.login-demo .cred-row:hover { color: var(--blue-600); }

.password-field { position: relative; }
.password-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--gray-400); padding: 4px;
}

/* Responsive */
@media (max-width: 980px) {
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .field.span-2 { grid-column: auto; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .checkbox-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .content { padding: 18px 14px 40px; }
  .modal-overlay { padding: 16px 12px; }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer, .modal-footer > .flex { flex-wrap: wrap; }
  .modal-footer > .flex { justify-content: flex-end; margin-left: auto; }
  .pager { align-items: flex-start; }
  .pager-controls { flex-wrap: wrap; max-width: 100%; }
}

.mono { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
