:root {
  --ink: #0f1720;
  --ink-soft: #4b5563;
  --border: #e2e5ea;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --sidebar-bg: #12213e;
  --sidebar-ink: #c7d0e3;
  --sidebar-ink-active: #ffffff;
  --brand: #1c3f95;
  --brand-dark: #142c68;
  --accent: #d0342c;
  --ok: #1b7f4c;
  --warn: #b6790a;
  --crit: #b3241c;
  --radius: 8px;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Auth shell (login / not-authorized pages) ---- */
.content-noauth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--sidebar-bg), var(--brand-dark));
}

.auth-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 40px 36px;
  width: 380px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.auth-card h1 { font-size: 20px; margin: 4px 0 0; }
.auth-card .subtitle { color: var(--ink-soft); margin: 6px 0 28px; font-size: 13px; }

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: 14px;
}
.btn-microsoft:hover { background: var(--brand-dark); text-decoration: none; }

.auth-footnote { margin-top: 22px; font-size: 12px; color: var(--ink-soft); }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 20px 14px;
}

.brand { padding: 0 10px 22px; }
.brand-mark { display: block; font-weight: 800; font-size: 18px; color: #fff; letter-spacing: 0.04em; }
.brand-sub { display: block; font-size: 11px; color: var(--sidebar-ink); opacity: 0.75; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--sidebar-ink);
  font-size: 13.5px;
  font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-link-alert { color: #ffb4ae; }
.nav-link-alert:hover { color: #ffe2df; background: rgba(211,63,55,0.18); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 18px; margin: 0; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 16px; }
.user-chip { text-align: right; line-height: 1.2; }
.user-name { display: block; font-weight: 600; font-size: 13px; }
.user-role { display: block; font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.signout { font-size: 13px; color: var(--ink-soft); }

.content { padding: 24px 28px 48px; max-width: 1180px; width: 100%; }

/* ---- Cards / tiles ---- */
.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.tile .tile-value { font-size: 28px; font-weight: 800; }
.tile .tile-label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }

.panel-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel h2 { font-size: 14px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); }

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.action-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  font-weight: 600;
  color: var(--ink);
}
.action-card:hover { border-color: var(--brand); text-decoration: none; }
.action-card.alert { border-color: rgba(179,36,28,0.35); }
.action-card.alert:hover { border-color: var(--crit); }
.action-card .desc { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { background: #f0f2f5; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-low { background: #e6eefc; color: var(--brand); }
.badge-medium { background: #fdf1dc; color: var(--warn); }
.badge-high { background: #fbe4d5; color: #b34d0a; }
.badge-critical { background: #fadedc; color: var(--crit); }
.badge-new, .badge-open { background: #e6eefc; color: var(--brand); }
.badge-triage, .badge-in_progress { background: #fdf1dc; color: var(--warn); }
.badge-assigned { background: #e9e6fc; color: #5b3ec9; }
.badge-waiting_for_user, .badge-blocked { background: #f1eee9; color: #6b5a3b; }
.badge-resolved, .badge-done { background: #dff2e6; color: var(--ok); }
.badge-closed { background: #eceef1; color: var(--ink-soft); }

/* ---- Forms ---- */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; max-width: 640px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
input[type=text], input[type=email], input[type=date], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }

.btn { display: inline-block; padding: 9px 18px; border-radius: 6px; font-size: 13.5px; font-weight: 600; border: none; cursor: pointer; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: #eceef1; color: var(--ink); }
.btn-secondary:hover { background: #e1e4e9; text-decoration: none; }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }

/* ---- Misc ---- */
.muted { color: var(--ink-soft); }
.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }
.empty-state { padding: 30px; text-align: center; color: var(--ink-soft); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-link { padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface); border: 1px solid var(--border); color: var(--ink-soft); }
.filter-link.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.filter-link:hover { text-decoration: none; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-meta { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.comment-internal { background: #fdf6ec; border-radius: 6px; padding: 10px 12px; }
.article-body { white-space: pre-wrap; line-height: 1.7; }
.error-card { max-width: 460px; text-align: center; }

/* ---- Utility classes (kept out of inline style="" so CSP style-src can stay 'self') ---- */
.mt-16 { margin-top: 16px; }
.btn-row-center { justify-content: center; margin-top: 18px; }
.grow { flex: 1; }
.tile-row-narrow { grid-template-columns: minmax(160px, 260px); }
.text-ink { color: var(--ink); }
.mb-0 { margin-bottom: 0; }
.search-input { max-width: 320px; }
.textarea-lg { min-height: 280px; }
