/* =========================================================================
   IMed Hub — brand design system
   Source: IMed Brandstyle, Brandbook v1.0 (February 2025)
   Primary: Dark Purple #2D2663 · Lime Green #D2DE2B · Cyan #36C3F2
            Lilac #4978BC · Orange #F15642 · White
   Neutrals: Dark grey #414042 · Mid grey #939598 · Chalk #D8E1E3 · Light grey #EAEEEE
   Typeface: Barlow (Light / Regular / Medium / Bold)
   Gradients echo the logo: lime → cyan → lilac
   ========================================================================= */

:root {
  /* brand primaries */
  --navy: #2d2663;          /* Dark Purple */
  --navy-700: #262052;      /* shade of Dark Purple */
  --navy-900: #1e1a45;      /* shade of Dark Purple */
  --blue: #4978bc;          /* Lilac — primary action colour */
  --blue-600: #3d68a8;      /* Lilac shade */
  --sky: #36c3f2;           /* Cyan */
  --green: #d2de2b;         /* Lime Green */
  --lime: #d2de2b;          /* Lime Green */
  --purple: #4978bc;        /* mapped to Lilac (brand palette) */
  --orange: #f15642;        /* Orange */

  /* brand neutrals */
  --ink: #414042;           /* Dark grey */
  --muted: #939598;         /* Mid grey */
  --line: #d8e1e3;          /* Chalk */
  --line-2: #eaeeee;        /* Light grey */
  --bg: #eef1f2;            /* Light grey tint */
  --surface: #ffffff;
  --surface-2: #f7f9f9;     /* Chalk tint */

  /* semantic tints/shades derived from brand colours */
  --ok: #78840f;            /* Lime shade (legible) */
  --ok-bg: #f3f5d3;         /* Lime tint */
  --amber: #F5C518;         /* Amber/yellow — Medium priority */
  --amber-ink: #8a6d00;     /* Amber shade (legible text) */
  --amber-bg: #fdf6d8;      /* Amber tint */
  --warn: #d0491f;          /* Orange shade */
  --warn-bg: #fde9e2;       /* Orange tint */
  --danger: #b83224;        /* Orange deep shade */
  --danger-bg: #fbe3df;     /* Orange tint */
  --info: #4978bc;          /* Lilac */
  --info-bg: #e7eef8;       /* Lilac tint */

  --grad: linear-gradient(120deg, #d2de2b 0%, #36c3f2 58%, #4978bc 100%);
  --grad-soft: linear-gradient(120deg, rgba(210,222,43,.16), rgba(54,195,242,.14), rgba(73,120,188,.14));

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(45,38,99,.04), 0 8px 24px rgba(45,38,99,.06);
  --shadow-lg: 0 12px 40px rgba(45,38,99,.14);
  --sidebar-w: 256px;
  --topbar-h: 64px;

  --font-head: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5 { font-family: var(--font-head); color: var(--navy); margin: 0; font-weight: 700; letter-spacing: -.01em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea { font-family: var(--font-body); font-size: 14px; }
::selection { background: rgba(54,195,242,.3); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d4d8e4; border-radius: 20px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #c2c7d8; }

/* ---------- utility ---------- */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6{gap:6px;} .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-8{margin-top:8px;} .mt-16{margin-top:16px;} .mt-24{margin-top:24px;}
.mb-8{margin-bottom:8px;} .mb-16{margin-bottom:16px;} .mb-24{margin-bottom:24px;}
.full { width: 100%; }
.icon { width: 18px; height: 18px; stroke-width: 2; flex: none; }
.icon-sm { width: 15px; height: 15px; flex: none; }
.icon-lg { width: 22px; height: 22px; flex: none; }

/* =========================================================================
   LOGIN
   ========================================================================= */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
}
.auth-hero {
  position: relative;
  background: linear-gradient(150deg, var(--navy-900) 0%, var(--navy) 48%, var(--blue) 100%);
  color: #fff;
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-hero::after {
  content: ""; position: absolute; right: -120px; top: -120px;
  width: 460px; height: 460px; border-radius: 50%;
  background: var(--grad); opacity: .22; filter: blur(8px);
}
.auth-hero::before {
  content: ""; position: absolute; left: -80px; bottom: -140px;
  width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgba(54,195,242,.5), transparent 70%);
}
.auth-hero .hero-top, .auth-hero .hero-bottom { position: relative; z-index: 1; }
.auth-hero h1 { color: #fff; font-size: 38px; line-height: 1.12; margin-bottom: 18px; }
.auth-hero p { color: rgba(255,255,255,.82); font-size: 16px; max-width: 440px; }
.auth-hero .pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.auth-hero .pill {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  padding: 7px 13px; border-radius: 100px; font-size: 13px; color: #fff;
  display: flex; align-items: center; gap: 7px;
}
.auth-logo-badge {
  background: #fff; border-radius: 12px; padding: 12px 18px; display: inline-flex;
  box-shadow: var(--shadow); align-self: flex-start;
}
.auth-logo-badge img { height: 30px; display: block; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.auth-card > p { color: var(--muted); margin: 0 0 26px; }
.role-toggle { display: flex; background: var(--bg); border-radius: 12px; padding: 5px; margin-bottom: 22px; }
.role-toggle button {
  flex: 1; border: 0; background: transparent; padding: 11px; border-radius: 9px;
  font-weight: 600; color: var(--muted); font-size: 14px; transition: .15s;
}
.role-toggle button.active { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); transition: .15s; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(73,120,188,.16);
}
.field textarea { resize: vertical; min-height: 84px; }
.demo-accounts { margin-top: 22px; padding: 14px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; font-size: 12.5px; }
.demo-accounts b { color: var(--navy); }
.demo-accounts .acc { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.demo-accounts .acc:hover { color: var(--blue); cursor: pointer; }

/* =========================================================================
   BUTTONS / BADGES / CHIPS
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1.5px solid transparent; border-radius: 10px; padding: 9px 15px;
  font-weight: 600; font-size: 14px; background: var(--surface); color: var(--navy);
  transition: .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); box-shadow: 0 6px 18px rgba(73,120,188,.32); }
.btn-grad { background: var(--grad); color: #fff; border: 0; }
.btn-grad:hover { filter: brightness(1.05); box-shadow: 0 6px 20px rgba(54,195,242,.4); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--navy); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-subtle { background: var(--bg); border-color: transparent; color: var(--navy); }
.btn-subtle:hover { background: #e9edf7; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f7dada; }
.btn-block { width: 100%; padding: 12px; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 8px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 100px; background: var(--bg); color: var(--muted); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-amber { background: var(--amber-bg); color: var(--amber-ink); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-navy { background: rgba(45,38,99,.1); color: var(--navy); }
.badge-grad { background: var(--grad-soft); color: var(--navy); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--navy); font-weight: 500;
}
.chip:hover { border-color: var(--blue); cursor: pointer; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 700; font-size: 13px; font-family: var(--font-head);
  background: var(--grad);
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
/* company logos: white tile, clipped to the circle, padded so a square logo sits inside it */
.avatar.logo { background: #fff; border: 1px solid var(--line); overflow: hidden; }
.avatar.logo img { object-fit: contain; padding: 15%; box-sizing: border-box; border-radius: 0; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid #fff; margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* =========================================================================
   APP SHELL
   ========================================================================= */
#app { min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  /* Brandbook: full-colour ident sits on flat Dark Purple */
  background: var(--navy);
  color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { padding: 18px 20px 14px; display: flex; align-items: center; gap: 10px; }
.sidebar-logo .mark { height: 32px; display: block; }
/* Logo family style: "IMed" bold + product word light, in a brand colour (Cyan) */
.sidebar-logo .name { font-family: var(--font-head); font-weight: 700; font-size: 18px; color: #fff; letter-spacing: -.01em; }
/* search inputs: built-in clear (×) button, brand-styled */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; height: 13px; width: 13px; flex: none; cursor: pointer; opacity: .5;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%232D2663" stroke-width="3" stroke-linecap="round"><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg>') center/contain no-repeat;
}
input[type="search"]::-webkit-search-cancel-button:hover { opacity: 1; }
input[type="search"] { -webkit-appearance: none; }

.ts-cell .ts-pend { display: inline-block; margin-left: 3px; font-size: 10px; font-weight: 700; color: var(--amber-ink); background: var(--amber-bg); border: 1px dashed var(--amber-ink); border-radius: 6px; padding: 0 4px; }

.sidebar-logo .beta-tag { display: inline-block; margin-top: 2px; background: var(--sky); color: var(--navy-900, #1a1640); font-size: 8.5px; font-weight: 800; letter-spacing: .14em; padding: 1px 8px; border-radius: 100px; }
.sidebar-logo .name span { color: var(--sky); font-weight: 300; }
.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: rgba(255,255,255,.4); padding: 16px 12px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,.78); font-weight: 500; font-size: 14px; margin-bottom: 2px; transition: .13s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--grad); }
.nav-item .icon { opacity: .9; }
.nav-item.nav-sub { padding-left: 34px; font-size: 13px; opacity: .92; }
.nav-item.nav-sub .icon { width: 13px; height: 13px; opacity: .6; }
.nav-item.nav-sub.active::before { left: 10px; }
.nav-item .count { margin-left: auto; background: rgba(255,255,255,.16); border-radius: 100px; font-size: 11px; padding: 1px 8px; font-weight: 700; }
.nav-item .count.alert { background: var(--sky); color: var(--navy-900); }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot .org { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.85); font-size: 13px; }
.iso-tag { font-size: 10.5px; color: rgba(255,255,255,.5); margin-top: 8px; display: flex; align-items: center; gap: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { width: 100%; padding: 9px 13px 9px 38px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.topbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar .viewas-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 4px 6px 4px 12px; border-radius: 100px; background: color-mix(in srgb, var(--amber) 18%, white); border: 1.5px solid var(--amber); color: var(--navy); white-space: nowrap; }
.topbar .viewas-pill .btn { padding: 3px 11px; border-radius: 100px; background: var(--navy); color: #fff; border: none; font-size: 12px; }
.topbar .viewas-pill .btn:hover { background: var(--blue); }
.topbar .role-pill { font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 100px; }
.topbar .role-pill.internal { background: var(--info-bg); color: var(--blue); }
.topbar .role-pill.client { background: var(--grad-soft); color: var(--navy); }
.iconbtn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--navy); }
.iconbtn:hover { border-color: var(--blue); color: var(--blue); }
.iconbtn .ndot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }
.user-menu { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 100px; border: 1px solid var(--line); }
.user-menu:hover { border-color: var(--blue); cursor: pointer; }
.user-menu .meta { line-height: 1.15; }
.user-menu .meta .nm { font-weight: 700; font-size: 13px; color: var(--navy); }
.user-menu .meta .rl { font-size: 11.5px; color: var(--muted); }

.content { padding: 26px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.page-head h1 { font-size: 25px; }
.page-head p.sub { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* =========================================================================
   CARDS / GRID / TABLES
   ========================================================================= */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 15.5px; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.col-span-2 { grid-column: span 2; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat .ico { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.stat .ico.blue { background: var(--info-bg); color: var(--blue); }
.stat .ico.grad { background: var(--grad-soft); color: var(--navy); }
.stat .ico.green { background: var(--ok-bg); color: var(--ok); }
.stat .ico.warn { background: var(--warn-bg); color: var(--warn); }
.stat .ico.purple { background: rgba(73,120,188,.12); color: var(--purple); }
.stat .ico.danger { background: rgba(241,86,66,.12); color: var(--orange); }
.stat .val { font-family: var(--font-head); font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 6px; }
.stat .trend { font-size: 12px; font-weight: 700; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.stat .trend.up { color: var(--ok); }
.stat .trend.down { color: var(--danger); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line-2); font-size: 14px; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl .row-click { cursor: pointer; }
.t-title { font-weight: 600; color: var(--navy); }
.t-sub { font-size: 12.5px; color: var(--muted); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--line); stroke-width: 1.5; opacity: .9; }

/* progress */
.progress { height: 7px; border-radius: 100px; background: var(--line-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 100px; background: var(--grad); }
.progress.blue > span { background: var(--blue); }

/* =========================================================================
   DOCS / TREE / KANBAN / TIMELINE
   ========================================================================= */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.tree { font-size: 14px; }
.tree-node { border-radius: 8px; }
.tree-row { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 8px; color: var(--navy); cursor: pointer; }
.tree-row:hover { background: var(--surface-2); }
.tree-row.active { background: var(--info-bg); color: var(--blue); font-weight: 600; }
.tree-row .count { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.tree-children { margin-left: 16px; border-left: 1px solid var(--line-2); padding-left: 4px; }
/* Documents tree — folder icons in brand colours (no background bands, text unchanged).
   Company = Lime · Project = Dark Purple · Project subfolders = Cyan · Shared Area = dark Orange.
   An expanded folder shows the open icon with a lighter fill of its own colour. */
.tree-row.tf-company .icon-sm { color: var(--green); }
.tree-row.tf-project .icon-sm { color: var(--navy); }
.tree-row.tf-sub .icon-sm { color: var(--sky); }
.tree-row.tf-shared .icon-sm { color: var(--warn); }
.tree-row.expanded .icon-sm { fill: color-mix(in srgb, var(--navy) 16%, white); }
.tree-row.tf-company.expanded .icon-sm { fill: color-mix(in srgb, var(--green) 30%, white); }
.tree-row.tf-project.expanded .icon-sm { fill: color-mix(in srgb, var(--navy) 22%, white); }
.tree-row.tf-sub.expanded .icon-sm { fill: color-mix(in srgb, var(--sky) 26%, white); }
.tree-row.tf-shared.expanded .icon-sm { fill: color-mix(in srgb, var(--warn) 22%, white); }
.tree-row.active { background: var(--info-bg); color: var(--blue); font-weight: 600; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
.kcol-head { padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); font-weight: 700; color: var(--navy); font-size: 13.5px; }
.kcol-head .n { margin-left: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 100px; font-size: 11.5px; padding: 1px 8px; color: var(--muted); }
.kcol-head .bar { width: 8px; height: 8px; border-radius: 2px; }
.kcol-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; transition: .12s; }
.kcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); border-color: #d6dbe8; }
.kcard .k-co { font-weight: 700; color: var(--navy); font-size: 14px; }
.kcard .k-val { font-family: var(--font-head); font-weight: 700; color: var(--navy); }
/* compact programme board: narrower columns, tighter cards */
.kanban.compact { grid-auto-columns: minmax(185px, 1fr); gap: 10px; }
.kanban.compact .kcol-head { padding: 8px 10px; font-size: 12.5px; }
.kanban.compact .kcol-body { padding: 7px; gap: 7px; }
.kanban.compact .kcard { padding: 8px 9px; border-radius: 9px; }
.kanban.compact .kcard .k-co { font-size: 12.5px !important; line-height: 1.25 !important; }
.kanban.compact .kcard .badge { font-size: 9.5px !important; padding: 1px 6px !important; }
.kanban.compact .kcard .progress { height: 4px !important; margin-bottom: 4px !important; }
.kanban.compact .kcard .k-meta { margin-top: 2px; }
.kcard .k-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; flex-wrap: wrap; row-gap: 5px; }
.kcard .k-meta .flex, .kanban .kcard .flex { flex-wrap: wrap; row-gap: 4px; min-width: 0; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 18px 14px; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--blue); }
.tl-item.done::before { background: var(--blue); }
.tl-item.grad::before { border-color: var(--green); }
.tl-time { font-size: 12px; color: var(--muted); }

/* checklist / tasks */
.task-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.task-row:last-child { border-bottom: 0; }
.check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; cursor: pointer; color: transparent; transition: .12s; }
.check:hover { border-color: var(--blue); }
.check.done { background: var(--blue); border-color: var(--blue); color: #fff; }
.task-row.done .t-name { text-decoration: line-through; color: var(--muted); }
.t-name { font-weight: 500; color: var(--navy); }

/* signature pad */
.sigpad { border: 2px dashed var(--line); border-radius: 12px; background: var(--surface-2); touch-action: none; width: 100%; height: 170px; cursor: crosshair; }
.sig-done { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface-2); }
.sig-img { font-family: 'Brush Script MT','Segoe Script',cursive; font-size: 34px; color: var(--navy); }

/* =========================================================================
   AI ASSISTANT
   ========================================================================= */
.ai-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.ai-mode { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 11px; cursor: pointer; border: 1px solid transparent; }
.ai-mode:hover { background: var(--surface-2); }
.ai-mode.active { background: var(--grad-soft); border-color: rgba(73,120,188,.25); }
.ai-mode .ico { width: 34px; height: 34px; border-radius: 9px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--blue); flex: none; }
.ai-mode.active .ico { background: var(--blue); color: #fff; border-color: var(--blue); }
.ai-out { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 18px; font-size: 14.5px; line-height: 1.6; min-height: 200px; }
.ai-out.typing::after { content: "▍"; color: var(--blue); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--grad); color: #fff; padding: 3px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 700; }
.ai-chat { display: flex; flex-direction: column; gap: 10px; min-height: 260px; max-height: 440px; overflow-y: auto; padding: 4px 2px; margin-bottom: 14px; }
.ai-msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.ai-msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }

/* =========================================================================
   MODAL / TOAST / DRAWER
   ========================================================================= */
.overlay { position: fixed; inset: 0; background: rgba(26,22,64,.45); backdrop-filter: blur(2px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s; }
.modal.wide { max-width: 760px; }
.modal-head, .modal-foot, .modal-top { flex: none; }
.modal-body { overflow-y: auto; min-height: 0; }
.modal-top { padding: 12px 22px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.modal-head { padding: 20px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.x-btn { background: var(--bg); border: 0; width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.x-btn:hover { background: #e9edf7; color: var(--navy); }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--navy); color: #fff; padding: 13px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 11px; min-width: 280px; max-width: 380px; animation: slidein .2s; font-size: 14px; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }
.toast .tico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; background: rgba(255,255,255,.15); }
.toast.ok .tico { background: var(--ok); }
.toast.info .tico { background: var(--blue); }
.toast.warn .tico { background: var(--warn); }

/* notifications dropdown */
.dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); width: 340px; z-index: 60; overflow: hidden; }
.notif { display: flex; gap: 11px; padding: 13px 15px; border-bottom: 1px solid var(--line-2); }
.notif:hover { background: var(--surface-2); }
.notif .nd { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--info-bg); color: var(--blue); }
.notif .nt { font-size: 13.5px; color: var(--navy); }
.notif .ng { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* segmented control */
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 4px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

/* file drop */
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 30px; text-align: center; background: var(--surface-2); transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--info-bg); }
.dropzone .icon-lg { color: var(--blue); margin-bottom: 8px; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: center; font-weight: 700; padding-bottom: 4px; }
.cal .day { border: 1px solid var(--line-2); border-radius: 9px; min-height: 78px; padding: 6px; background: var(--surface); position: relative; }
.cal .day.out { background: var(--surface-2); color: var(--line); }
.cal .day.today { border-color: var(--blue); }
.cal .day .dn { font-size: 12px; font-weight: 700; color: var(--navy); }
.cal .ev { font-size: 10.5px; padding: 2px 5px; border-radius: 5px; margin-top: 3px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev.leave { background: var(--warn-bg); color: var(--warn); }
.cal .ev.hol { background: var(--ok-bg); color: var(--ok); }
.cal .ev.mile { background: var(--info-bg); color: var(--blue); }
.cal .ev.blk { background: var(--navy); color: #fff; }
.rescell { cursor: pointer; transition: filter .12s; }
.rescell:hover { filter: brightness(.96); }
.rescell.rag-green { background: var(--ok-bg); color: var(--ok); }
.rescell.rag-amber { background: var(--warn-bg); color: var(--warn); }
.rescell.rag-red { background: color-mix(in srgb, var(--orange) 16%, white); color: var(--orange); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 11px 16px; font-weight: 600; color: var(--muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px; cursor: pointer; font-size: 14px; }
.tab:hover { color: var(--navy); }
.tab.active { color: var(--blue); border-color: var(--blue); }

/* def list */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--navy); font-weight: 500; }

.banner { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 12px; font-size: 14px; }
.banner-info { background: var(--info-bg); color: var(--blue); }
.banner-grad { background: var(--grad-soft); color: var(--navy); border: 1px solid rgba(73,120,188,.2); }
.banner .icon { flex: none; }

hr.sep { border: 0; border-top: 1px solid var(--line-2); margin: 18px 0; }

/* =========================================================================
   PROPOSAL DOCUMENT (client preview / client view)
   ========================================================================= */
.prop-doc { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-lg); background: #fff; }
.prop-cover {
  position: relative; min-height: 620px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, var(--navy-900) 0%, var(--navy) 52%, var(--blue) 118%);
  color: #fff; padding: 46px 52px; overflow: hidden;
}
.prop-cover::before {
  content: ""; position: absolute; right: -140px; top: -140px; width: 480px; height: 480px; border-radius: 50%;
  background: var(--grad); opacity: .25; filter: blur(6px);
}
.prop-cover::after {
  content: ""; position: absolute; left: -100px; bottom: -160px; width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(54,195,242,.45), transparent 70%);
}
.prop-cover > * { position: relative; z-index: 1; }
.prop-cover .cover-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.prop-cover .logo-badge { background: #fff; padding: 10px 16px; border-radius: 11px; display: inline-flex; }
.prop-cover .logo-badge img { height: 24px; display: block; }
.prop-cover .cover-kicker { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: rgba(255,255,255,.65); font-weight: 700; padding: 8px 14px; border: 1px solid rgba(255,255,255,.25); border-radius: 100px; }
.prop-cover .cover-headline { font-family: var(--font-head); font-weight: 700; font-size: 44px; line-height: 1.08; letter-spacing: -.01em; max-width: 620px; }
.prop-cover .cover-sub { font-weight: 300; font-size: 20px; color: rgba(255,255,255,.85); margin-top: 14px; max-width: 520px; }
.prop-cover .cover-rule { width: 84px; height: 5px; border-radius: 5px; background: var(--grad); margin-bottom: 22px; }
.prop-cover .cover-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; border-top: 1px solid rgba(255,255,255,.18); padding-top: 22px; }
.prop-cover .cover-foot .lbl { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.5); font-weight: 700; margin-bottom: 4px; }
.prop-cover .cover-foot .val { font-weight: 600; font-size: 15px; color: #fff; }
.prop-body { padding: 52px 56px; background: #fff; }
.prop-section { margin-bottom: 44px; }
.prop-section:last-child { margin-bottom: 0; }
.prop-h { font-family: var(--font-head); font-weight: 700; font-size: 23px; color: var(--navy); margin-bottom: 6px; }
.prop-hrule { width: 44px; height: 4px; border-radius: 4px; background: var(--grad); margin-bottom: 16px; }
.prop-text { line-height: 1.75; font-size: 15px; color: var(--ink); white-space: pre-wrap; }
.prop-team { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.prop-member { display: flex; gap: 15px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 16px; }
.prop-photo { width: 74px; height: 74px; border-radius: 50%; object-fit: cover; flex: none; border: 3px solid #fff; box-shadow: var(--shadow); }
.prop-photo-fallback { width: 74px; height: 74px; border-radius: 50%; flex: none; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 700; font-size: 22px; border: 3px solid #fff; box-shadow: var(--shadow); }
.prop-member .m-name { font-weight: 700; color: var(--navy); font-size: 15px; }
.prop-member .m-role { font-size: 12.5px; color: var(--blue); font-weight: 600; margin-bottom: 6px; }
.prop-member .m-bio { font-size: 13px; color: var(--muted); line-height: 1.55; }
@media (max-width: 760px) {
  .prop-cover { padding: 30px 26px; min-height: 520px; }
  .prop-cover .cover-headline { font-size: 32px; }
  .prop-body { padding: 30px 26px; }
  .prop-team { grid-template-columns: 1fr; }
}
@media print {
  .prop-cover { min-height: 95vh; border-radius: 0; }
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -280px; width: 280px; z-index: 80; transition: left .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .menu-toggle { display: flex !important; }
  .split, .ai-layout { grid-template-columns: 1fr; }
}
@media (min-width: 901px) { .menu-toggle { display: none; } }
@media (max-width: 680px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .content { padding: 18px; }
  .topbar { padding: 0 14px; }
  .topbar .search { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 8px; }
}
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 70; }
@media (min-width: 901px) { .scrim { display: none; } }

/* ---- Reports: date-range controls ---- */
.rep-date {
  padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--navy); font: inherit; font-size: 13px; font-weight: 500;
}
.rep-date:focus { outline: none; border-color: var(--sky); }

/* ---- Print (Reports export to PDF via browser print) ---- */
@media print {
  .sidebar, .topbar, .page-actions, .chip, .rep-date, .toast-wrap, .overlay, .scrim, .menu-toggle { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .stat { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
}

/* ---- Tasks hub (Teamwork-style) ---- */
.tchk {
  width: 24px; height: 24px; min-width: 24px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface); color: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: .15s;
}
.tchk:hover { border-color: var(--green); color: var(--green); }
.task-row:last-child { border-bottom: none !important; }
.task-row:hover { background: var(--surface-2); }
.tbl-dark thead th {
  background: var(--navy); color: #fff; border-bottom: none;
  font-size: 11.5px; letter-spacing: .03em; white-space: nowrap;
}
.tbl-dark thead th:first-child { border-top-left-radius: 10px; }
.tbl-dark thead th:last-child { border-top-right-radius: 10px; }

/* ---- Import wizard ---- */
.imp-type { border: 2px solid transparent; transition: .15s; }
.imp-type:hover { border-color: var(--line); }
.imp-type.active { border-color: var(--sky); background: var(--surface-2); }

/* ---- E-sign: merged agreement document ---- */
.agree { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.agree-cover { padding: 22px 26px; border-bottom: 2px solid var(--navy); }
.agree-title { font-family: var(--font-head); font-weight: 700; font-size: 20px; color: var(--navy); line-height: 1.25; }
.agree-sec { padding: 18px 26px; border-bottom: 1px solid var(--line); }
.agree-sec:last-child { border-bottom: none; }
.agree-sec-head { font-family: var(--font-head); font-weight: 700; font-size: 14px; color: var(--navy); margin-bottom: 10px; }
.agree-body { font-size: 13.5px; line-height: 1.7; color: var(--ink); }
.sig-box { border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 14px; text-align: center; background: var(--surface-2); }
.sig-box img { max-height: 64px; max-width: 100%; }
.sig-script { font-family: 'Snell Roundhand', 'Brush Script MT', cursive; font-size: 26px; color: var(--navy); padding: 12px 0; }
.sig-meta { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; font-size: 12px; color: var(--navy); }

/* ---- View-only access: hide page-level action buttons ---- */
.viewonly .page-actions { display: none !important; }

/* ---- Time: timesheet grid ---- */
.ts-grid td, .ts-grid th { white-space: nowrap; }
.ts-cell { cursor: pointer; min-width: 52px; color: var(--navy); font-weight: 600; }
.ts-cell:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--sky); border-radius: 6px; }
.ts-cell.has { background: var(--surface-2); }
.ts-cell.locked { cursor: not-allowed; color: var(--muted); }
.ts-wknd { background: rgba(0,0,0,.025); }

/* ---- Project Finance: burn chart ---- */
.burn-chart { display: flex; gap: 6px; align-items: flex-end; height: 130px; }
.burn-col { flex: 1; display: flex; flex-direction: column; height: 100%; min-width: 0; }
.burn-bars { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.burn-time { background: linear-gradient(180deg, #36C3F2, #4978BC); border-radius: 3px 3px 0 0; }
.burn-exp { background: var(--orange); border-radius: 3px 3px 0 0; margin-bottom: 1px; }
.burn-lbl { font-size: 9px; color: var(--muted); text-align: center; line-height: 1.2; padding-top: 4px; white-space: nowrap; overflow: hidden; }

/* ---- CRM inbox (tickets & enquiries, service-hub style) ---- */
.icol { background: #F0F1F3; border-radius: 14px; padding: 10px; min-width: 250px; }
.icol-head { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px 10px; color: var(--navy); font-size: 14px; }
.icol-body { min-height: 120px; display: flex; flex-direction: column; gap: 10px; border-radius: 10px; }
.icard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; cursor: pointer; box-shadow: 0 1px 3px rgba(45,38,99,.07); }
.icard:hover { box-shadow: 0 4px 14px rgba(45,38,99,.13); }
.icard-title { font-weight: 700; color: var(--lilac); font-size: 14px; line-height: 1.35; }
