/* ==========================================================================
   Span Tech CRM — design system
   Works identically in RTL (Arabic) and LTR (English) via logical properties.
   ========================================================================== */

:root {
  /* brand — taken from the Span Tech logo */
  --brand-900: #0a2647;
  --brand-800: #103d7a;
  --brand-700: #1a56a7;
  --brand-600: #2670c9;
  --brand-500: #3d8bdd;
  --brand-100: #e3eefb;
  --brand-50:  #f2f7fd;

  --accent-600: #c9761a;
  --accent-100: #fdf1e2;

  --ok-700: #14683f; --ok-600: #178553; --ok-100: #e3f5ec;
  --warn-700: #8a5a00; --warn-100: #fdf3dc;
  --danger-700: #a32020; --danger-600: #c62828; --danger-100: #fdeaea;

  --ink-900: #111827;
  --ink-700: #374151;
  --ink-500: #6b7280;
  --ink-400: #9ca3af;
  --ink-300: #d1d5db;
  --ink-200: #e5e7eb;
  --ink-100: #f3f4f6;
  --ink-50:  #f9fafb;
  --white: #ffffff;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .1), 0 2px 4px -2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, .08), 0 4px 6px -2px rgba(16, 24, 40, .03);

  --sidebar-w: 248px;
  --header-h: 60px;

  --font-ar: 'Cairo', 'Tajawal', 'Segoe UI', 'Noto Naskh Arabic', 'Traditional Arabic', Tahoma, sans-serif;
  --font-en: 'Inter', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

:root[dir='rtl'] { --font: var(--font-ar); }
:root[dir='ltr'] { --font: var(--font-en); }

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-900);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
}

/* Latin numerals everywhere, even in Arabic — engineers read figures faster. */
.num, td.num, th.num, input[type='number'] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  direction: ltr;
  unicode-bidi: plaintext;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 700; line-height: 1.3; color: var(--ink-900); }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; } h4 { font-size: .92rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .5rem .9rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--brand-700); color: var(--white);
  font-family: inherit; font-size: .875rem; font-weight: 600; line-height: 1.2;
  cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { background: var(--brand-800); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--white); color: var(--ink-700); border-color: var(--ink-300); }
.btn-secondary:hover { background: var(--ink-100); }
.btn-ghost { background: transparent; color: var(--brand-700); }
.btn-ghost:hover { background: var(--brand-50); }
.btn-danger { background: var(--danger-600); }
.btn-danger:hover { background: var(--danger-700); }
.btn-success { background: var(--ok-700); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-lg { padding: .65rem 1.3rem; font-size: .95rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .35rem; width: 30px; height: 30px; }

/* ------------------------------------------------------------------- forms */
.field { margin-bottom: .85rem; }
.field > label {
  display: block; margin-bottom: .28rem;
  font-size: .8rem; font-weight: 600; color: var(--ink-700);
}
.field .hint { margin-top: .22rem; font-size: .74rem; color: var(--ink-500); }

input[type='text'], input[type='email'], input[type='password'], input[type='number'],
input[type='date'], input[type='datetime-local'], input[type='tel'], input[type='url'],
select, textarea {
  width: 100%; padding: .48rem .65rem;
  border: 1px solid var(--ink-300); border-radius: var(--radius-sm);
  background: var(--white); color: var(--ink-900);
  font-family: inherit; font-size: .875rem; line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
input:disabled, select:disabled, textarea:disabled { background: var(--ink-100); color: var(--ink-500); }
textarea { min-height: 76px; resize: vertical; }
select { cursor: pointer; }

.checkbox { display: flex; align-items: center; gap: .45rem; cursor: pointer; font-size: .85rem; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand-700); cursor: pointer; }

.grid { display: grid; gap: .85rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--brand-900); color: #cdd9e9;
  transition: transform .2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
/* The brand mark is full colour, so it sits on a light chip rather than
   being flattened to white against the navy sidebar. */
.sidebar-brand img {
  height: 40px; width: 40px; padding: 3px; flex-shrink: 0;
  object-fit: contain; background: var(--white); border-radius: 8px;
}
.sidebar-brand .name { font-size: 1rem; font-weight: 700; color: var(--white); letter-spacing: .01em; }
.sidebar-brand .sub { font-size: .7rem; color: #8fa6c4; }

.sidebar-nav { flex: 1; padding: .7rem .6rem; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem; margin-bottom: .15rem; border-radius: var(--radius-sm);
  color: #cdd9e9; font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: var(--white); text-decoration: none; }
.nav-item.active { background: var(--brand-700); color: var(--white); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-inline-start: auto; min-width: 20px; padding: 0 .35rem;
  border-radius: 999px; background: var(--danger-600); color: var(--white);
  font-size: .7rem; font-weight: 700; text-align: center; line-height: 18px;
}

.sidebar-footer { padding: .7rem; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .78rem; }
.sidebar-user { display: flex; align-items: center; gap: .55rem; padding: .4rem .3rem; }
.avatar {
  display: grid; place-items: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-600); color: var(--white); font-size: .8rem; font-weight: 700;
}
.sidebar-user .who { min-width: 0; }
.sidebar-user .who b { display: block; color: var(--white); font-size: .82rem; font-weight: 600; }
.sidebar-user .who span { color: #8fa6c4; font-size: .72rem; }

.main { flex: 1; min-width: 0; margin-inline-start: var(--sidebar-w); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  height: var(--header-h); padding: 0 1.2rem;
  background: var(--white); border-bottom: 1px solid var(--ink-200);
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .5rem; }
.menu-toggle { display: none; }

.lang-switch {
  display: inline-flex; border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm); overflow: hidden;
}
.lang-switch button {
  padding: .3rem .6rem; border: 0; background: var(--white);
  color: var(--ink-700); font-family: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.lang-switch button.active { background: var(--brand-700); color: var(--white); }

.content { padding: 1.2rem; max-width: 1560px; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(calc(var(--sidebar-w) * -1)); }
  :root[dir='rtl'] .sidebar { transform: translateX(var(--sidebar-w)); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-inline-start: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: .9rem; }
}

.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(17, 24, 39, .45); backdrop-filter: blur(1px);
}

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--white); border: 1px solid var(--ink-200);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .8rem 1rem; border-bottom: 1px solid var(--ink-200);
}
.card-header h2, .card-header h3 { margin: 0; }
.card-header .spacer { margin-inline-start: auto; }
.card-body { padding: 1rem; }
.card-body.tight { padding: .6rem; }
.card-body.flush { padding: 0; }

/* --------------------------------------------------------------- KPI tiles */
.kpi-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1rem; }
.kpi {
  padding: .9rem 1rem; background: var(--white);
  border: 1px solid var(--ink-200); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  border-inline-start: 3px solid var(--brand-600);
}
.kpi .label { font-size: .76rem; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { margin-top: .25rem; font-size: 1.55rem; font-weight: 700; color: var(--ink-900); line-height: 1.2; }
.kpi .meta { margin-top: .1rem; font-size: .76rem; color: var(--ink-500); }
.kpi.ok { border-inline-start-color: var(--ok-700); }
.kpi.warn { border-inline-start-color: var(--warn-700); }
.kpi.danger { border-inline-start-color: var(--danger-600); }
.kpi.accent { border-inline-start-color: var(--accent-600); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data th {
  padding: .6rem .7rem; background: var(--ink-50);
  border-bottom: 1px solid var(--ink-200);
  font-size: .74rem; font-weight: 700; color: var(--ink-500);
  text-transform: uppercase; letter-spacing: .03em; text-align: start; white-space: nowrap;
}
table.data td { padding: .6rem .7rem; border-bottom: 1px solid var(--ink-100); vertical-align: middle; }
table.data tbody tr:hover { background: var(--brand-50); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.num, table.data th.num { text-align: end; }
table.data .muted { color: var(--ink-500); font-size: .8rem; }
table.data tfoot td { padding: .6rem .7rem; font-weight: 700; border-top: 2px solid var(--ink-200); }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-400); }
.empty svg { width: 40px; height: 40px; margin-bottom: .5rem; opacity: .45; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .5rem; border-radius: 999px;
  font-size: .73rem; font-weight: 600; white-space: nowrap;
  background: var(--ink-100); color: var(--ink-700);
}
.badge.blue { background: var(--brand-100); color: var(--brand-800); }
.badge.green { background: var(--ok-100); color: var(--ok-700); }
.badge.amber { background: var(--warn-100); color: var(--warn-700); }
.badge.red { background: var(--danger-100); color: var(--danger-700); }
.badge.orange { background: var(--accent-100); color: var(--accent-600); }
.badge.grey { background: var(--ink-100); color: var(--ink-500); }

.stars { color: var(--accent-600); letter-spacing: .05em; font-size: .8rem; }

/* ------------------------------------------------------------------ toolbar */
.toolbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .85rem;
}
.toolbar .search-box { position: relative; flex: 1; min-width: 190px; max-width: 340px; }
.toolbar .search-box input { padding-inline-start: 2rem; }
.toolbar .search-box svg {
  position: absolute; inset-block-start: 50%; inset-inline-start: .55rem;
  width: 15px; height: 15px; transform: translateY(-50%); color: var(--ink-400); pointer-events: none;
}
.toolbar select { width: auto; min-width: 120px; }
.toolbar .spacer { margin-inline-start: auto; }

.segmented { display: inline-flex; border: 1px solid var(--ink-300); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  padding: .42rem .75rem; border: 0; background: var(--white);
  color: var(--ink-700); font-family: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.segmented button + button { border-inline-start: 1px solid var(--ink-300); }
.segmented button.active { background: var(--brand-700); color: var(--white); }

/* ------------------------------------------------------------------ modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2.5rem 1rem; overflow-y: auto;
  background: rgba(17, 24, 39, .55);
}
.modal {
  width: 100%; max-width: 620px;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 980px; }
.modal.narrow { max-width: 420px; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.99); } }
.modal-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--ink-200);
}
.modal-header h2 { margin: 0; font-size: 1.05rem; }
.modal-header .close {
  margin-inline-start: auto; width: 30px; height: 30px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--ink-500); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.modal-header .close:hover { background: var(--ink-100); }
.modal-body { padding: 1.1rem; max-height: 68vh; overflow-y: auto; }
.modal-footer {
  display: flex; gap: .5rem; justify-content: flex-end;
  padding: .85rem 1.1rem; border-top: 1px solid var(--ink-200);
  background: var(--ink-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed; z-index: 90; inset-block-end: 1.2rem; inset-inline-end: 1.2rem;
  display: flex; flex-direction: column; gap: .5rem; max-width: 380px;
}
.toast {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .7rem .9rem; border-radius: var(--radius);
  background: var(--ink-900); color: var(--white);
  font-size: .85rem; box-shadow: var(--shadow-lg);
  animation: slide-in .18s ease-out;
}
.toast.success { background: var(--ok-700); }
.toast.error { background: var(--danger-700); }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ kanban */
.board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .6rem; align-items: flex-start; }
.board-col {
  flex: 0 0 272px; display: flex; flex-direction: column;
  background: var(--ink-100); border-radius: var(--radius); max-height: calc(100vh - 230px);
}
.board-col-head {
  display: flex; align-items: center; gap: .4rem;
  padding: .6rem .75rem; border-bottom: 2px solid var(--ink-200);
}
.board-col-head .title { font-size: .82rem; font-weight: 700; }
.board-col-head .count {
  padding: 0 .4rem; border-radius: 999px; background: var(--white);
  color: var(--ink-500); font-size: .72rem; font-weight: 700;
}
.board-col-head .sum { margin-inline-start: auto; font-size: .75rem; font-weight: 600; color: var(--ink-500); }
.board-col-body { flex: 1; padding: .5rem; overflow-y: auto; min-height: 90px; }
.board-col.drag-over .board-col-body { background: var(--brand-50); border-radius: var(--radius-sm); }

.deal {
  padding: .6rem .7rem; margin-bottom: .45rem;
  background: var(--white); border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  cursor: grab; transition: box-shadow .15s, transform .1s;
}
.deal:hover { box-shadow: var(--shadow-md); }
.deal.dragging { opacity: .45; }
.deal .title { font-size: .84rem; font-weight: 600; margin-bottom: .2rem; }
.deal .customer { font-size: .76rem; color: var(--ink-500); margin-bottom: .35rem; }
.deal .row { display: flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--ink-500); }
.deal .value { font-weight: 700; color: var(--brand-800); }

/* stage accent bars */
.board-col[data-stage='new']         .board-col-head { border-bottom-color: var(--ink-400); }
.board-col[data-stage='qualified']   .board-col-head { border-bottom-color: var(--brand-500); }
.board-col[data-stage='quoted']      .board-col-head { border-bottom-color: var(--brand-700); }
.board-col[data-stage='negotiation'] .board-col-head { border-bottom-color: var(--accent-600); }
.board-col[data-stage='won']         .board-col-head { border-bottom-color: var(--ok-700); }
.board-col[data-stage='lost']        .board-col-head { border-bottom-color: var(--danger-600); }

/* ------------------------------------------------------- follow-up centre */
.followup {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .65rem .8rem; border-bottom: 1px solid var(--ink-100);
}
.followup:last-child { border-bottom: 0; }
.followup .tick {
  flex-shrink: 0; width: 20px; height: 20px; margin-top: .1rem;
  border: 2px solid var(--ink-300); border-radius: 50%;
  background: transparent; cursor: pointer; transition: border-color .15s, background .15s;
}
.followup .tick:hover { border-color: var(--ok-700); background: var(--ok-100); }
.followup .body { flex: 1; min-width: 0; }
.followup .subject { font-size: .87rem; font-weight: 600; }
.followup .meta { font-size: .76rem; color: var(--ink-500); }
.followup.is-overdue { background: #fffbfb; }
.followup.is-overdue .due { color: var(--danger-700); font-weight: 700; }
.followup.is-today .due { color: var(--warn-700); font-weight: 700; }
.followup.is-done { opacity: .55; }
.followup.is-done .subject { text-decoration: line-through; }

/* ------------------------------------------------------------------ charts */
.chart { width: 100%; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--ink-500); font-size: 11px; }
.chart .axis-line { stroke: var(--ink-200); stroke-width: 1; }
.chart .grid-line { stroke: var(--ink-100); stroke-width: 1; }
.chart .bar { transition: opacity .15s; }
.chart .bar:hover { opacity: .8; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .5rem; font-size: .76rem; color: var(--ink-500); }
.chart-legend .key { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 2px; }

.funnel-row { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.funnel-row .label { flex: 0 0 110px; font-size: .8rem; font-weight: 600; }
.funnel-row .track { flex: 1; height: 26px; background: var(--ink-100); border-radius: var(--radius-sm); overflow: hidden; }
.funnel-row .fill {
  height: 100%; display: flex; align-items: center;
  padding-inline: .5rem; background: var(--brand-600); color: var(--white);
  font-size: .76rem; font-weight: 700; border-radius: var(--radius-sm);
  transition: width .4s ease;
}
.funnel-row .pct { flex: 0 0 52px; font-size: .78rem; font-weight: 600; color: var(--ink-500); text-align: end; }

/* --------------------------------------------------------- quotation editor */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
@media (max-width: 1180px) { .editor-layout { grid-template-columns: 1fr; } }
.sticky-panel { position: sticky; top: calc(var(--header-h) + 1rem); }

.totals-table { width: 100%; font-size: .87rem; }
.totals-table td { padding: .35rem 0; }
.totals-table td:last-child { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals-table tr.grand td { padding-top: .6rem; border-top: 2px solid var(--ink-300); font-size: 1.02rem; font-weight: 800; color: var(--brand-800); }

.calc-note {
  padding: .5rem .65rem; margin-bottom: .7rem;
  background: var(--warn-100); border-radius: var(--radius-sm);
  font-size: .74rem; font-weight: 600; color: var(--warn-700);
}
.alert { padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600; margin-bottom: .7rem; }
.alert.danger { background: var(--danger-100); color: var(--danger-700); }
.alert.warn { background: var(--warn-100); color: var(--warn-700); }
.alert.ok { background: var(--ok-100); color: var(--ok-700); }
.alert.info { background: var(--brand-100); color: var(--brand-800); }

.items-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.items-table th {
  padding: .4rem .45rem; background: var(--ink-50); border-bottom: 1px solid var(--ink-200);
  font-size: .72rem; font-weight: 700; color: var(--ink-500); text-align: start;
}
.items-table td { padding: .3rem .25rem; border-bottom: 1px solid var(--ink-100); }
.items-table input { padding: .35rem .5rem; font-size: .82rem; }
.items-table .col-qty, .items-table .col-price { width: 108px; }
.items-table .col-amount { width: 120px; text-align: end; font-weight: 600; font-variant-numeric: tabular-nums; }
.items-table .col-del { width: 34px; }

/* --------------------------------------------------------------- utilities */
.row { display: flex; align-items: center; gap: .5rem; }
.row.wrap { flex-wrap: wrap; }
.spacer { margin-inline-start: auto; }
.muted { color: var(--ink-500); }
.small { font-size: .8rem; }
.tiny { font-size: .73rem; }
.bold { font-weight: 700; }
.center { text-align: center; }
.end { text-align: end; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; }
.detail-item .k { font-size: .73rem; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: .03em; }
.detail-item .v { font-size: .9rem; font-weight: 500; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--ink-200); margin-bottom: 1rem; overflow-x: auto; }
.tabs button {
  padding: .55rem .9rem; border: 0; border-bottom: 2px solid transparent; background: transparent;
  color: var(--ink-500); font-family: inherit; font-size: .87rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--brand-700); }
.tabs button.active { color: var(--brand-700); border-bottom-color: var(--brand-700); }

/* ------------------------------------------------------------ login screen */
.login-page {
  display: grid; place-items: center; min-height: 100vh; padding: 1rem;
  background: linear-gradient(140deg, var(--brand-900) 0%, var(--brand-700) 100%);
}
.login-card {
  width: 100%; max-width: 400px; padding: 2rem;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.login-card .logo { display: block; height: 92px; width: auto; margin: 0 auto 1rem; }
.login-card h1 { text-align: center; font-size: 1.25rem; margin-bottom: .2rem; }
.login-card .sub { text-align: center; color: var(--ink-500); font-size: .85rem; margin-bottom: 1.4rem; }
.login-card .lang-switch { margin: 0 auto 1.2rem; display: flex; width: fit-content; }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: var(--white); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: grid; place-items: center; min-height: 60vh; color: var(--ink-400); }

@media print {
  .sidebar, .topbar, .toolbar, .no-print { display: none !important; }
  .main { margin: 0 !important; }
  body { background: var(--white); }
}

/* ==========================================================================
   Notifications, inbox and calendar
   ========================================================================== */

/* --------------------------------------------------------------- bell */
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell-badge {
  position: absolute; inset-block-start: -5px; inset-inline-end: -5px;
  min-width: 17px; height: 17px; padding: 0 .25rem;
  border-radius: 999px; background: var(--danger-600); color: var(--white);
  font-size: .66rem; font-weight: 800; line-height: 17px; text-align: center;
}

.notif-dropdown {
  position: absolute; inset-block-start: calc(100% + 8px); inset-inline-end: 0;
  z-index: 50; width: min(380px, calc(100vw - 2rem));
  background: var(--white); border: 1px solid var(--ink-200);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop .14s ease-out;
}
.notif-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .8rem; border-bottom: 1px solid var(--ink-200); background: var(--ink-50);
}
.notif-list { max-height: 60vh; overflow-y: auto; }
.notif-foot { border-top: 1px solid var(--ink-200); padding: .35rem; }

.notif-item {
  display: flex; gap: .55rem; align-items: flex-start;
  padding: .6rem .8rem; border-bottom: 1px solid var(--ink-100); cursor: pointer;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--brand-50); }
.notif-item.is-unread { background: #f7fbff; }
.notif-item.is-unread .notif-title { font-weight: 700; }

.notif-row {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .7rem .9rem; border-bottom: 1px solid var(--ink-100);
}
.notif-row:last-child { border-bottom: 0; }
.notif-row:hover { background: var(--ink-50); }
.notif-row.is-unread { background: #f7fbff; }
.notif-row.is-unread .notif-title { font-weight: 700; }

.notif-dot {
  flex-shrink: 0; width: 9px; height: 9px; margin-top: .4rem;
  border-radius: 50%; background: var(--brand-600);
}
.notif-dot.amber { background: var(--warn-700); }
.notif-dot.red { background: var(--danger-600); }
.notif-dot.blue { background: var(--brand-600); }

.notif-text { min-width: 0; flex: 1; }
.notif-title { font-size: .87rem; line-height: 1.4; }
.notif-body { font-size: .78rem; color: var(--ink-500); line-height: 1.45; }
.notif-time { font-size: .72rem; color: var(--ink-400); margin-top: .1rem; }

/* -------------------------------------------------------------- inbox */
.msg-row {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .75rem .9rem; border-bottom: 1px solid var(--ink-100); cursor: pointer;
}
.msg-row:last-child { border-bottom: 0; }
.msg-row:hover { background: var(--brand-50); }
.msg-row.is-unread { background: #f7fbff; }
.msg-row.is-unread .msg-subject { font-weight: 800; }
.msg-subject { font-size: .89rem; font-weight: 600; }
.msg-preview { font-size: .8rem; color: var(--ink-500); }

.msg-bubble {
  padding: .7rem .85rem; margin-bottom: .6rem;
  background: var(--ink-50); border: 1px solid var(--ink-200);
  border-radius: var(--radius); border-inline-start: 3px solid var(--brand-600);
}
.msg-text { font-size: .88rem; white-space: pre-wrap; line-height: 1.6; }

.recipient-picker {
  display: flex; flex-wrap: wrap; gap: .4rem;
  padding: .5rem; border: 1px solid var(--ink-300); border-radius: var(--radius-sm);
  max-height: 160px; overflow-y: auto;
}
.recipient-chip {
  padding: .25rem .55rem; border: 1px solid var(--ink-200);
  border-radius: 999px; background: var(--white); font-size: .8rem;
}
.recipient-chip:has(input:checked) {
  background: var(--brand-100); border-color: var(--brand-500); font-weight: 600;
}

/* ----------------------------------------------------------- calendar */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px; background: var(--ink-200);
  border: 1px solid var(--ink-200); border-radius: var(--radius-sm); overflow: hidden;
}
.cal-head {
  padding: .45rem .3rem; background: var(--ink-50);
  font-size: .74rem; font-weight: 700; color: var(--ink-500); text-align: center;
  text-transform: uppercase; letter-spacing: .02em;
}
.cal-cell {
  min-height: 104px; padding: .3rem; background: var(--white);
  display: flex; flex-direction: column; gap: 2px;
}
.cal-cell.is-outside { background: var(--ink-50); }
.cal-cell.is-outside .cal-daynum { color: var(--ink-300); }
.cal-cell.is-today { background: var(--brand-50); box-shadow: inset 0 0 0 2px var(--brand-500); }
.cal-daynum { font-size: .78rem; font-weight: 700; color: var(--ink-500); }
.cal-cell.is-today .cal-daynum { color: var(--brand-800); }

.cal-event {
  display: flex; align-items: center; gap: .25rem;
  padding: .12rem .3rem; border-radius: 3px;
  background: var(--ink-100); border-inline-start: 3px solid var(--brand-600);
  font-size: .7rem; line-height: 1.35; cursor: pointer;
  overflow: hidden; white-space: nowrap;
}
.cal-event:hover { background: var(--brand-100); }
.cal-event.is-overdue { background: var(--danger-100); color: var(--danger-700); font-weight: 600; }
.cal-event.is-done { opacity: .5; text-decoration: line-through; }
.cal-time { font-variant-numeric: tabular-nums; direction: ltr; color: var(--ink-500); flex-shrink: 0; }
.cal-more {
  align-self: flex-start; padding: 0 .3rem; border: 0; border-radius: 3px;
  background: transparent; color: var(--brand-700);
  font-family: inherit; font-size: .7rem; font-weight: 700; cursor: pointer;
}
.cal-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; }

.agenda-day {
  padding: .45rem .2rem .3rem; margin-top: .6rem;
  border-bottom: 2px solid var(--ink-200);
  font-size: .82rem; font-weight: 800; color: var(--brand-800);
}
.agenda-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .3rem; border-bottom: 1px solid var(--ink-100); cursor: pointer;
}
.agenda-row:hover { background: var(--brand-50); }
.agenda-row.is-overdue { background: #fffbfb; }
.agenda-row.is-done { opacity: .55; }
.agenda-row.is-done .bold { text-decoration: line-through; }
.agenda-time {
  font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
  direction: ltr; color: var(--ink-500); min-width: 46px;
}

@media (max-width: 720px) {
  .cal-cell { min-height: 74px; }
  .cal-event .cal-time { display: none; }
}

/* ------------------------------------------------------- permission matrix */
.perm-group { margin-bottom: .5rem; border: 1px solid var(--ink-200); border-radius: var(--radius-sm); }
.perm-group > summary {
  padding: .45rem .7rem; background: var(--ink-50);
  font-size: .85rem; font-weight: 700; cursor: pointer;
  border-radius: var(--radius-sm);
}
.perm-group-body { padding: .3rem .7rem .55rem; }
.perm-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .28rem 0; border-bottom: 1px solid var(--ink-100);
}
.perm-row:last-child { border-bottom: 0; }
.perm-row.is-override { background: var(--accent-100); border-radius: 4px; padding-inline: .3rem; }
.perm-tag {
  flex-shrink: 0; padding: .1rem .45rem; border-radius: 999px;
  background: var(--ink-100); color: var(--ink-500);
  font-size: .68rem; font-weight: 700;
}
.perm-row.is-override .perm-tag { background: var(--accent-600); color: var(--white); }

/* ------------------------------------------------------- incoming requests */
.req-row {
  display: flex; align-items: flex-start; gap: .8rem;
  padding: .8rem .9rem; border-bottom: 1px solid var(--ink-100); cursor: pointer;
}
.req-row:last-child { border-bottom: 0; }
.req-row:hover { background: var(--brand-50); }
.req-row.is-new { background: #fffdf5; border-inline-start: 3px solid var(--accent-600); }
.req-subject { font-size: .9rem; font-weight: 700; }

.conf-ring {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin: 0 auto .15rem;
  border-radius: 50%; border: 3px solid var(--ink-200);
  font-size: .74rem; font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr;
}
.conf-ring.high { border-color: var(--ok-700); color: var(--ok-700); }
.conf-ring.mid { border-color: var(--warn-700); color: var(--warn-700); }
.conf-ring.low { border-color: var(--ink-300); color: var(--ink-500); }

.mail-body {
  max-height: 260px; overflow: auto; margin: 0;
  padding: .7rem .8rem; background: var(--ink-50);
  border: 1px solid var(--ink-200); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .84rem; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
