/* ===================================================================
   IT4Shore Client Portal — styles
   Reuses the marketing site's green + charcoal brand so the logged-in
   area feels like the same company. Charcoal header, light workspace.
   =================================================================== */
:root {
  --navy-900: #14211a;   /* deepest charcoal-green */
  --navy-800: #1f2d24;   /* dark charcoal-green */
  --navy-700: #33453a;   /* mid charcoal-green */
  --green-600: #3aa832;  /* PRIMARY brand green */
  --green-500: #46bb3c;
  --leaf:      #7ed36a;  /* bright leaf-green accent */

  --ink:    #0f172a;
  --slate:  #475569;
  --slate-2:#64748b;
  --line:   #e2e8f0;
  --bg:     #f4f7fb;
  --card:   #ffffff;

  --ok:     #16a34a;
  --warn:   #d97706;
  --bad:    #dc2626;
  --muted:  #94a3b8;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow: 0 10px 30px -14px rgba(15,23,42,.28);
  --maxw: 1120px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--green-600); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 20;
  background: var(--navy-800); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* ---------- Header ---------- */
.p-header { background: var(--navy-900); color: #fff; box-shadow: var(--shadow); }
.p-header-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.brand-name strong { color: var(--leaf); }
.brand-tag { font-size: .56rem; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: #9fb6a6; margin-top: 3px; }

.p-header-right { display: flex; align-items: center; gap: 12px; }
.p-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: #d7e6d2; font-size: .82rem; font-weight: 600; border: 1px solid #3a4b41;
  padding: 7px 13px; border-radius: 999px; white-space: nowrap;
}
.p-back:hover { background: var(--navy-700); color: #fff; text-decoration: none; }
.p-back svg { display: block; }

.p-user { display: flex; align-items: center; gap: 16px; }
.p-user-meta { display: flex; flex-direction: column; text-align: right; line-height: 1.25; }
.p-user-name { font-weight: 700; font-size: .92rem; }
.p-user-email { font-size: .76rem; color: #9fb6a6; }
.p-signout {
  color: #d7e6d2; font-size: .82rem; font-weight: 600; border: 1px solid #3a4b41;
  padding: 7px 13px; border-radius: 999px; white-space: nowrap;
}
.p-signout:hover { background: var(--navy-700); text-decoration: none; }

.p-tabs {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  display: flex; gap: 4px; overflow-x: auto;
}
.p-tabs a {
  color: #b9c9c0; font-weight: 600; font-size: .95rem; padding: 12px 16px;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.p-tabs a:hover { color: #fff; text-decoration: none; }
.p-tabs a.active { color: #fff; border-bottom-color: var(--leaf); }

/* ---------- Main ---------- */
.p-main {
  flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 30px 24px 48px;
  outline: none;
}
.view-head { margin: 0 0 22px; }
.view-head h1 { font-size: 1.6rem; letter-spacing: -.02em; margin: 0 0 4px; }
.view-head p { margin: 0; color: var(--slate); }
.crumb { display: inline-block; margin-bottom: 14px; font-size: .9rem; font-weight: 600; }
.crumb::before { content: "‹ "; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stat .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-2); font-weight: 700; }
.stat .num { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.stat .num.ok { color: var(--ok); }
.stat .num.bad { color: var(--bad); }
.stat .num.brand { color: var(--green-600); }
.stat-ico {
  position: absolute; top: 15px; right: 15px; width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #eef2f7; color: var(--slate-2);
}
.stat-ico svg { width: 18px; height: 18px; }
.stat-ico.ok    { background: #dcfce7; color: #15803d; }
.stat-ico.bad   { background: #fee2e2; color: #b91c1c; }
.stat-ico.warn  { background: #fef3c7; color: #b45309; }
.stat-ico.brand { background: #e4f6e0; color: var(--green-600); }

/* ---------- Cards / sections ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 22px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 1.05rem; margin: 0; }
.card-body { padding: 6px 0; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d3dde8; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.empty.pad { padding: 30px 20px; }

/* ---------- Recent-tickets mini list (dashboard) ---------- */
.mini-list { list-style: none; margin: 0; padding: 4px 0; }
.mini-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 20px; border-bottom: 1px solid #eef2f7;
}
.mini-item:last-child { border-bottom: 0; }
.mini-item.clickable { cursor: pointer; transition: background .12s ease; }
.mini-item.clickable:hover { background: #f7faf6; }
.mini-main { display: flex; flex-direction: column; min-width: 0; }
.mini-title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-sub { color: var(--slate-2); font-size: .8rem; margin-top: 2px; }

/* ---------- Needs-attention panel (dashboard) ---------- */
.attn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 16px 20px; }
.attn {
  display: flex; align-items: center; gap: 13px; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fbfdfb;
  color: var(--ink); transition: transform .13s ease, box-shadow .13s ease, border-color .13s ease;
}
.attn:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: #cfe0d2; }
.attn-ico { flex: none; width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.attn-ico svg { width: 20px; height: 20px; }
.attn-ico.bad   { background: #fee2e2; color: #b91c1c; }
.attn-ico.warn  { background: #fef3c7; color: #b45309; }
.attn-ico.brand { background: #e4f6e0; color: var(--green-600); }
.attn-body { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.attn-n { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.attn-label { font-size: .82rem; color: var(--slate); font-weight: 600; }

/* ---------- Skeleton layout helpers ---------- */
.sk-mt { margin-top: 14px; }
.sk-row { padding: 10px 20px; }
.card > .sk-row + .sk-row { border-top: 1px solid #eef2f7; }
.skeleton { display: block; }

/* health bar */
.health { padding: 20px; }
.health-bar { height: 12px; border-radius: 999px; background: #eef2f7; overflow: hidden; display: flex; }
.health-bar > i { display: block; height: 100%; }
.health-bar > i.on { background: var(--ok); }
.health-bar > i.off { background: var(--bad); }
.health-legend { display: flex; gap: 18px; margin-top: 12px; font-size: .85rem; color: var(--slate); }
.health-legend b { color: var(--ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--ok); } .dot.off { background: var(--bad); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--slate-2); font-weight: 700; padding: 12px 20px; border-bottom: 1px solid var(--line);
}
tbody td { padding: 13px 20px; border-bottom: 1px solid #eef2f7; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f7faf6; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { color: var(--slate-2); font-size: .82rem; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; line-height: 1.4;
}
.pill.ok   { background: #dcfce7; color: #15803d; }
.pill.bad  { background: #fee2e2; color: #b91c1c; }
.pill.warn { background: #fef3c7; color: #b45309; }
.pill.info { background: #e0f2fe; color: #0369a1; }
.pill.mute { background: #eef2f7; color: #475569; }

/* ---------- Ticket detail ---------- */
.ticket-meta { display: flex; flex-wrap: wrap; gap: 10px 26px; padding: 4px 20px 18px; color: var(--slate); font-size: .9rem; }
.ticket-meta b { color: var(--ink); font-weight: 700; }
.thread { padding: 6px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; background: #fbfdfb; }
.msg.first { background: #f1f8ef; border-color: #cfe8c7; }
.msg-head { display: flex; justify-content: space-between; gap: 12px; font-size: .82rem; margin-bottom: 6px; }
.msg-head .who { font-weight: 700; color: var(--ink); }
.msg-head .when { color: var(--slate-2); }
.msg-body { white-space: pre-wrap; line-height: 1.5; }

.detail-list { list-style: none; margin: 0; padding: 8px 20px 18px; }
.detail-list li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid #eef2f7; font-size: .92rem; }
.detail-list li:last-child { border-bottom: 0; }
.detail-list .k { color: var(--slate-2); }
.detail-list .v { font-weight: 600; text-align: right; }

/* ---------- Buttons / notices ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem;
  padding: 9px 16px; border-radius: 999px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--green-500), var(--green-600)); color: #fff;
}
.btn:hover { text-decoration: none; filter: brightness(1.03); }
.btn[disabled] { background: #cbd5e1; cursor: not-allowed; filter: none; }
.btn-ghost { background: #fff; color: var(--navy-800); border: 1px solid var(--line); }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  background: #f1f8ef; border: 1px solid #cfe8c7; color: #2f5a28;
  padding: 14px 16px; border-radius: var(--radius-sm); font-size: .9rem; margin: 0 0 20px;
}
.notice.soft { background: #f8fafc; border-color: var(--line); color: var(--slate); }

.empty { text-align: center; color: var(--slate); padding: 46px 20px; }
.empty .big { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }

/* ---------- Forms (new ticket) ---------- */
.form-wrap { padding: 20px; }
.ticket-form { display: flex; flex-direction: column; gap: 18px; }
.form-field { display: flex; flex-direction: column; gap: 7px; }
.form-field label { font-size: .82rem; font-weight: 700; color: var(--ink); }
.form-hint { font-size: .78rem; color: var(--slate-2); }
.ticket-form input,
.ticket-form select,
.ticket-form textarea {
  font-family: inherit; font-size: .94rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; width: 100%; transition: border-color .12s ease, box-shadow .12s ease;
}
.ticket-form textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.ticket-form select { max-width: 220px; }
.ticket-form input:focus,
.ticket-form select:focus,
.ticket-form textarea:focus {
  outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(70,187,60,.15);
}
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-error {
  background: #fee2e2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem;
}

.p-error {
  max-width: 560px; margin: 40px auto; background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--bad); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm);
}
.p-error h1 { font-size: 1.2rem; margin: 0 0 8px; }
.p-error p { color: var(--slate); margin: 0 0 14px; }

/* ---------- Loading ---------- */
.p-loading { display: flex; align-items: center; gap: 12px; color: var(--slate); padding: 60px 10px; justify-content: center; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid #d7e0da; border-top-color: var(--green-600);
  animation: spin .7s linear infinite; display: inline-block;
}
.skeleton { background: linear-gradient(90deg,#eef2f7 25%,#e2e8f0 37%,#eef2f7 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Footer ---------- */
.p-footer {
  border-top: 1px solid var(--line); background: #fff;
  padding: 16px 24px; color: var(--slate-2); font-size: .84rem;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.p-footer .maxw { max-width: var(--maxw); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .p-user-meta { display: none; }
  .view-head h1 { font-size: 1.35rem; }
}

/* Below this width, data tables flagged .stack render as stacked cards:
   the header row is hidden and each cell shows its column name (data-label)
   beside the value, so nothing gets clipped or needs horizontal scrolling. */
@media (max-width: 640px) {
  .attn-grid { grid-template-columns: 1fr; }
  .tbl-wrap { overflow-x: visible; }

  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    margin: 12px 14px; padding: 4px 2px; background: #fff;
  }
  table.stack tbody tr:last-child td { border-bottom: 1px solid #eef2f7; }
  table.stack td {
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    padding: 10px 16px; border-bottom: 1px solid #eef2f7; text-align: right;
  }
  table.stack td:last-child { border-bottom: 0; }
  table.stack td::before {
    content: attr(data-label); flex: none; text-align: left;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-2);
  }
  table.stack td .cell-main, table.stack td .cell-sub { text-align: right; }
  /* clickable rows already show intent via the whole-card tap target */
  table.stack tbody tr.clickable:hover { background: #f7faf6; }
}
