@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #1c2230;
  --ink-soft: #545e70;
  --line: #e0e3e9;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --sidebar: #1c2438;
  --sidebar-ink: #c7cdda;
  --sidebar-ink-active: #ffffff;
  --accent: #b45309;
  --accent-soft: #fef3e6;
  --good: #15803d;
  --good-soft: #eafaf0;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.5;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

a { color: var(--ink); text-decoration: none; }
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.layout { min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  /* Fixed: stays put while the main column scrolls. Taken out of flow, so
     .main below just needs a matching margin-left — no flex needed here. */
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 0 20px 24px 20px;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}
.sidebar .brand span { color: var(--accent); }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; }

.sidebar nav a {
  color: var(--sidebar-ink);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,0.1); color: #fff; }

.sidebar .user-box {
  padding: 12px 20px 0 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 12px;
  font-size: 12.5px;
}
.sidebar .user-box .name { color: #fff; font-weight: 600; margin-bottom: 6px; }
.sidebar .user-box a { color: var(--sidebar-ink); }
.sidebar .user-box a:hover { color: #fff; }

.main { padding: 32px 40px; max-width: 1200px; margin-left: 220px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; margin: 0 0 4px 0; }
.page-header .sub { color: var(--ink-soft); font-size: 13.5px; }

.btn {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #2c3446; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #96450a; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-soft); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11.5px; font-weight: 600;
}
.badge.open { background: var(--accent-soft); color: var(--accent); }
.badge.in_progress { background: #e8eefc; color: #1d4ed8; }
.badge.waiting_on_client { background: #f3f0fc; color: #6d28d9; }
.badge.closed { background: var(--good-soft); color: var(--good); }
.badge.support { background: #eef1f5; color: var(--ink-soft); }
.badge.maintenance { background: #fef7e6; color: #92620a; }
.badge.low { background: var(--bad-soft); color: var(--bad); }
.badge.critical { background: var(--bad-soft); color: var(--bad); }
.badge.warning { background: #fef7e6; color: #92620a; }
.badge.resolved { background: var(--good-soft); color: var(--good); }
.badge.info { background: #eef1f5; color: var(--ink-soft); }
.badge.security { background: var(--bad-soft); color: var(--bad); }
.badge.informational { background: #eef1f5; color: var(--ink-soft); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.stat .num { font-family: 'IBM Plex Mono', monospace; font-size: 28px; font-weight: 600; }
.stat .label { color: var(--ink-soft); font-size: 12.5px; margin-top: 4px; }
.stat.warn .num { color: var(--bad); }

form.stacked { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit; font-size: 13.5px; background: #fff;
}
.field textarea { resize: vertical; min-height: 80px; }
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox label { margin-bottom: 0; }
.field.checkbox input { width: auto; }
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

.empty { color: var(--ink-soft); font-size: 13.5px; padding: 24px 0; text-align: center; }

.banner { padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 20px; }
.banner.success { background: var(--good-soft); color: var(--good); }
.banner.error { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--accent-soft); color: var(--accent); }

.modal-overlay[hidden] { display: none; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(28, 34, 48, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; z-index: 1000; overflow-y: auto;
}
.modal-box {
  background: var(--surface); border-radius: 8px; padding: 20px 22px;
  max-width: 720px; width: 100%; box-shadow: 0 12px 32px rgba(0,0,0,0.18);
}

/* Ticket detail's control panel. Fixed (not sticky) and positioned against
   the viewport — left:220px clears the fixed sidebar, right:0 means it
   spans every remaining pixel on a wide monitor, regardless of .main's own
   max-width. A JS-measured spacer element (#tcp-spacer, sized to the
   panel's actual rendered height) takes its place in normal flow so page
   content isn't hidden underneath it. */
.ticket-control-panel {
  position: fixed;
  top: 0;
  left: 220px;
  right: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 40px 14px 40px;
  box-shadow: 0 2px 8px rgba(20, 24, 34, 0.04);
}
.tcp-row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.tcp-row1 h1 { font-size: 20px; margin: 0 0 4px 0; }
.tcp-clock {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  padding-top: 3px;
}
.tcp-row2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.tcp-row2 select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit; font-size: 12.5px; background: #fff; cursor: pointer;
}
.tcp-row2 select.priority-low { color: var(--ink-soft); }
.tcp-row2 select.priority-normal { color: var(--ink); }
.tcp-row2 select.priority-high { color: #92620a; font-weight: 600; border-color: #e9c988; }
.tcp-row2 select.priority-urgent { color: var(--bad); font-weight: 700; border-color: #f0b4b4; }
.tcp-clock-group {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
  padding: 4px 10px; background: var(--accent-soft); border-radius: 100px;
}
.tcp-clock-group .elapsed { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; color: var(--accent); font-weight: 600; }

.badge.preventative { background: #eaf3fb; color: #1d6fa5; }
.stat.profit { border-color: var(--good); }
.stat.profit .num { color: var(--good); }

.login-wrap {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--sidebar);
}
.login-card {
  background: #fff; padding: 40px; border-radius: 10px; width: 340px;
}
.login-card h1 { font-size: 19px; margin: 0 0 4px 0; }
.login-card .sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 24px; }
.login-card .error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.login-card .btn { width: 100%; margin-top: 6px; padding: 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--ink-soft); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tool-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; position: relative;
}
.tool-tile:hover { border-color: var(--accent); }
.tool-tile img { width: 32px; height: 32px; border-radius: 6px; }
.tool-tile .tool-name { font-size: 12.5px; font-weight: 600; }
.tool-tile .tool-category { font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.tool-tile .tool-edit-link {
  position: absolute; top: 6px; right: 8px; font-size: 11px; color: var(--ink-soft); opacity: 0;
}
.tool-tile:hover .tool-edit-link { opacity: 1; }
.tool-category-heading { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); font-weight: 600; margin: 18px 0 8px 0; }
.tool-category-heading:first-child { margin-top: 0; }
