* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--suma-navy-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-brand { background: var(--suma-navy-deep); display: flex; flex-direction: column; justify-content: center; padding: 64px; color: #cfd8e6; position: relative; overflow: hidden; }
.login-brand img { width: 280px; max-width: 100%; }
.login-brand p { margin-top: 28px; font-size: 16px; max-width: 360px; }
.login-brand::before, .login-brand::after { content: ''; position: absolute; background: var(--suma-gold); opacity: .10; }
.login-brand::before { right: 40px; bottom: -60px; width: 110px; height: 330px; }
.login-brand::after  { right: -70px; bottom: 50px; width: 330px; height: 110px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form form { width: 100%; max-width: 360px; }
.login-form h1 { margin-bottom: 6px; }
@media (max-width: 800px) { .login-wrap { grid-template-columns: 1fr; } .login-brand { padding: 32px; } .login-brand p { display: none; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.sidebar { background: var(--suma-navy-deep); color: #c3cde0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar .logo img { width: 140px; display: block; }
.sidebar .logo span { display: block; margin-top: 8px; font-size: 11px; letter-spacing: .14em; color: var(--suma-gold); text-transform: uppercase; }
.nav { padding: 12px 10px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #c3cde0; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--suma-navy-soft); color: #fff; text-decoration: none; }
.nav a.active { background: var(--suma-navy); color: #fff; box-shadow: inset 3px 0 0 var(--suma-gold); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; background: var(--suma-gold); color: var(--suma-navy-deep); font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }
.sidebar .me { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); font-size: 13px; }
.sidebar .me b { color: #fff; display: block; }
.sidebar .me button { background: none; border: 0; color: var(--suma-gold); padding: 0; cursor: pointer; font: inherit; font-size: 12px; margin-top: 4px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 22px 32px 0; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.content { padding: 20px 32px 48px; }
.btn.menu-btn { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c5cede; text-decoration: none; }
.btn.primary { background: var(--suma-navy); border-color: var(--suma-navy); color: #fff; }
.btn.primary:hover { background: var(--suma-navy-soft); }
.btn.gold { background: var(--suma-gold); border-color: var(--suma-gold); color: var(--suma-navy-deep); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn > svg { width: 15px; height: 15px; flex: none; }
.btn:disabled { opacity: .6; cursor: default; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--suma-gold); outline-offset: -1px; border-color: var(--suma-gold); }
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input { max-width: 300px; }
.filters select { width: auto; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0; }

/* ---------- Cards & tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: block; color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--suma-gold); }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 30px; font-weight: 700; color: var(--suma-navy); margin-top: 4px; }
.stat.alert { box-shadow: inset 4px 0 0 var(--suma-gold); }
.stat.alert .value { color: var(--suma-gold-deep); }
td.overdue { color: var(--suma-gold-deep); font-weight: 700; }
td.nowrap { white-space: nowrap; }
td.subj { min-width: 200px; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fafbfd; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f8f9fc; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.mono { white-space: nowrap; font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap; background: #eef1f6; color: var(--muted); }
/* Status: navy for active work, gold for waiting, grey for done */
.s-New      { background: var(--suma-navy); color: #fff; }
.s-Open     { background: var(--navy-tint); color: var(--suma-navy); }
.s-Pending  { background: var(--suma-gold-tint); color: var(--gold-text); }
.s-Resolved { background: var(--grey-tint); color: var(--muted); }
.s-Closed   { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
/* Priority: gold = needs attention, navy = normal */
.p-Urgent { background: var(--suma-gold); color: var(--suma-navy-deep); }
.p-High   { background: var(--suma-gold-tint); color: var(--gold-text); }
.p-Medium { background: var(--navy-tint); color: var(--suma-navy); }
.p-Low    { background: var(--grey-tint); color: var(--muted); }
/* Account type / customer status */
.t-Customer, .s-Active { background: var(--navy-tint); color: var(--suma-navy); }
.t-Prospect, .s-Lead   { background: var(--suma-gold-tint); color: var(--gold-text); }
.t-Partner, .t-Vendor  { background: transparent; color: var(--suma-navy); box-shadow: inset 0 0 0 1px var(--navy-tint-2); }
.t-Inactive, .s-Inactive { background: var(--grey-tint); color: var(--muted); }

/* ---------- Detail pages ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } }
.props { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13.5px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; word-break: break-word; }
.section { margin-top: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); }

.thread { display: flex; flex-direction: column; gap: 12px; }
.comment { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: #fff; }
.comment.internal { background: var(--suma-gold-tint); border-color: #e9dfb5; }
.comment .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.comment .body { white-space: pre-wrap; }
.composer { margin-top: 14px; }
.composer .row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 10px; }
.composer label.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin: 0; font-weight: 500; }
.composer label.check input { width: auto; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border: 0; }
.timeline .when { color: var(--muted); font-size: 12px; }
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar .lbl { width: 80px; }
.bar .track { flex: 1; height: 8px; border-radius: 4px; background: #eef1f6; overflow: hidden; }
.bar .fill { height: 100%; background: var(--suma-navy); border-radius: 4px; }
.bar .n { width: 28px; text-align: right; font-weight: 600; }

/* ---------- Ticket documents ---------- */
svg.clip { width: 14px; height: 14px; vertical-align: -2px; margin-right: 1px; }
.docs { padding: 6px 16px 16px; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ficon { position: relative; width: 34px; height: 40px; flex: none; color: var(--suma-navy); }
.ficon svg { width: 34px; height: 40px; }
.ficon em { position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%); font-style: normal; font-size: 8.5px; font-weight: 700;
  text-transform: uppercase; background: var(--suma-navy); color: #fff; padding: 0 3px; border-radius: 2px; letter-spacing: .03em; }
.finfo { flex: 1; min-width: 0; }
.finfo a { font-weight: 600; word-break: break-all; }
.finfo .muted { font-size: 12px; }
.factions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dropzone { margin-top: 12px; border: 2px dashed var(--navy-tint-2); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--suma-navy); background: #fafbfd; transition: background .15s, border-color .15s; }
.dropzone > svg { width: 22px; height: 22px; color: var(--suma-gold-deep); }
.dropzone .muted { font-size: 12px; margin-top: 2px; }
.dropzone.over { border-color: var(--suma-gold); background: var(--suma-gold-tint); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--suma-navy-soft); text-decoration: underline; cursor: pointer; }
.progress { margin-top: 12px; text-align: left; font-size: 12px; }
.progress .track { height: 6px; background: var(--navy-tint); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.progress .fill { height: 100%; background: var(--suma-gold); transition: width .1s; }
@media (max-width: 640px) { .files li { flex-wrap: wrap; } .factions { width: 100%; justify-content: flex-start; padding-left: 46px; } }

/* ---------- Record tabs, credentials ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--suma-navy); text-decoration: none; }
.tabs a.active { color: var(--suma-navy); border-bottom-color: var(--suma-gold); }
.tabs .n { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--navy-tint); color: var(--suma-navy); font-size: 11px; text-align: center; }
.stats.mini { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stats.mini .value { font-size: 24px; }
.stats.mini .value.small { font-size: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; padding-top: 6px; }
.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.mono-lg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; letter-spacing: .02em; }
svg.lock { width: 13px; height: 13px; vertical-align: -1px; color: var(--suma-gold-deep); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 500; margin: 0; }
label.check input { width: auto; }

.form-heading { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--suma-navy); border-top: 1px solid var(--border); padding-top: 14px; margin: 4px 0 10px; }

/* ---------- Contracts & e-signature ---------- */
.c-Draft    { background: #eef1f6; color: var(--muted); }
.c-Sent, .c-Viewed { background: var(--suma-gold-tint); color: var(--gold-text); }
.c-Signed   { background: var(--suma-navy); color: #fff; }
.c-Declined, .c-Voided, .c-Expired { background: #f6eaea; color: var(--danger); }
table.contracts td { vertical-align: top; }
table.contracts .signer { margin-bottom: 4px; font-size: 13px; }
table.contracts .signer .badge { font-size: 11px; padding: 1px 7px; }
td.actions .btns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 330px; margin-left: auto; }
td.actions .btns .btn + .btn { margin-left: 0; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.muted.small, .small { font-size: 12px; }
.empty { padding: 28px; text-align: center; }
.card.note { border-left: 4px solid var(--suma-gold); margin-bottom: 16px; }
.card.ok { border-left: 4px solid var(--suma-navy); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #eef1f6; padding: 1px 5px; border-radius: 4px; }
textarea.keybox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
ol.steps { padding-left: 20px; margin: 0 0 12px; line-height: 1.55; }
ol.steps li { margin-bottom: 6px; }
.signer-row { display: grid; grid-template-columns: 22px 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.signer-row .num { width: 22px; height: 22px; border-radius: 50%; background: var(--suma-navy); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.signer-add { display: flex; gap: 8px; align-items: center; }
.signer-add select { flex: 1; }
@media (max-width: 640px) { .signer-row { grid-template-columns: 22px 1fr auto; } .signer-row input[type=email] { grid-column: 2; } }

/* ---------- Email, templates & SLA ---------- */
.modal.wide { max-width: 860px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { border: 1px solid var(--border); background: #f6f8fb; border-radius: 20px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; color: var(--suma-navy); }
.chip:hover { border-color: var(--suma-gold); }
details.vars summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.var-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.var { border: 1px dashed #c5cede; background: #fff; border-radius: 6px; padding: 2px 7px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--suma-navy); cursor: pointer; }
.var:hover { border-color: var(--suma-gold); background: var(--suma-gold-tint); }
.row-check { margin: 0 0 10px !important; }
table.sla-table { width: 100%; border-collapse: collapse; margin-top: 8px; table-layout: fixed; }
table.sla-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 6px 4px; text-transform: none; letter-spacing: 0; white-space: normal; }
table.sla-table td { padding: 4px; }
table.sla-table input { width: 100%; }
.sla-ok  { background: #eef1f6; color: var(--suma-navy); }
.sla-met { background: var(--suma-navy); color: #fff; }
.sla-warn { background: var(--suma-gold-tint); color: var(--gold-text); }
.sla-bad { background: #f6eaea; color: var(--danger); }
.email-body { white-space: pre-wrap; border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin: 12px 0 18px; background: #fafbfc; }
.nowrap { white-space: nowrap; }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 28, 53, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; border-top: 4px solid var(--suma-gold); border-radius: 12px 12px 0 0; }
.modal header h2 { margin: 0; }
.modal header button { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal .body { padding: 20px 22px 6px; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--suma-navy); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 60; border-left: 4px solid var(--suma-gold); }
.toast.err { background: var(--danger); border-left-color: #fff; }
