:root {
  --green: #6eb539;
  --green-dark: #4f8a24;
  --green-soft: #eef7e7;
  --black: #000;
  --ink: #161616;
  --muted: #666;
  --line: #e2e4df;
  --bg: #f5f6f3;
  --card: #fff;
  --red: #c62828;
  --red-soft: #fdecea;
  --amber: #b26a00;
  --amber-soft: #fff4e0;
  --blue: #1f5fa8;
  --blue-soft: #e8f0fa;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Roboto Condensed', 'Arial Narrow', Arial, sans-serif; font-size: 16px; line-height: 1.45;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--green-dark); }
h1 { font-size: 26px; margin: 0 0 16px; font-weight: 700; }
h2 { font-size: 20px; margin: 24px 0 12px; }
h3 { font-size: 17px; margin: 18px 0 8px; }

/* ---- top bar ---- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 16px; padding: 10px 20px; position: sticky; top: 0; z-index: 10;
  box-shadow: inset 0 -3px 0 var(--green);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--black); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong { font-size: 22px; letter-spacing: .02em; }
.brand-text small { font-size: 12px; color: var(--green-dark); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.mainnav { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a { text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: var(--radius); font-weight: 500; }
.mainnav a:hover { background: var(--green-soft); }
.mainnav a.active { background: var(--ink); color: #fff; }
.mainnav a.cta { background: var(--green); color: #fff; }
.mainnav a.cta:hover { background: var(--green-dark); }
.userbox { margin-left: auto; display: flex; gap: 4px; align-items: center; font-size: 14px; }
.userbox a { color: var(--muted); }
.nav-toggle { display: none; margin-left: auto; font-size: 22px; background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px; cursor: pointer; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 18px; border-top: 4px solid var(--green); background: #fff; }

/* ---- cards / layout ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---- forms ---- */
label { display: block; font-weight: 700; margin: 0 0 6px; font-size: 15px; }
.field { margin-bottom: 16px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=time], input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #c9ccc4; border-radius: var(--radius); background: #fff; color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700;
  padding: 10px 18px; border-radius: var(--radius); border: 1px solid var(--ink); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f0f0f0; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #333; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-big { font-size: 19px; padding: 14px 26px; width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.priority-choice { display: flex; gap: 10px; }
.priority-choice label { flex: 1; border: 1px solid #c9ccc4; border-radius: var(--radius); padding: 10px 12px; font-weight: 500; cursor: pointer; display: flex; gap: 8px; align-items: center; margin: 0; }
.priority-choice input { accent-color: var(--green); }
.priority-choice label:has(input:checked) { border-color: var(--green); background: var(--green-soft); }

/* ---- flash ---- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border-left: 5px solid; }
.flash-ok { background: var(--green-soft); border-color: var(--green); }
.flash-error { background: var(--red-soft); border-color: var(--red); }
.flash-info { background: var(--blue-soft); border-color: var(--blue); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { text-align: left; background: #fafbf8; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #fafcf7; }
table.list tr.is-new td:first-child { box-shadow: inset 4px 0 0 var(--green); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.st-nowe { background: var(--amber-soft); color: var(--amber); }
.st-w_realizacji { background: var(--blue-soft); color: var(--blue); }
.st-wykonane { background: var(--green-soft); color: var(--green-dark); }
.st-zamkniete { background: #eee; color: #444; }
.st-odrzucone { background: var(--red-soft); color: var(--red); }
.pri-pilny { background: var(--red); color: #fff; }
.sla-ok { color: var(--green-dark); font-weight: 700; }
.sla-late { color: var(--red); font-weight: 700; }
.sla-warn { color: var(--amber); font-weight: 700; }

/* ---- filters ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 150px; padding: 8px 10px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 7px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); font-weight: 500; }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs .count { opacity: .7; margin-left: 4px; }

/* ---- ticket view ---- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.sla-box { border-radius: var(--radius); padding: 16px; text-align: center; margin-bottom: 14px; }
.sla-box .big { font-size: 30px; font-weight: 700; line-height: 1.1; }
.sla-box.pending { background: var(--amber-soft); color: var(--amber); }
.sla-box.late { background: var(--red-soft); color: var(--red); }
.sla-box.met { background: var(--green-soft); color: var(--green-dark); }
.desc { white-space: pre-wrap; background: #fafbf8; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photos a { display: block; width: 110px; height: 110px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #eee; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--line); margin-left: 8px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--green); }
.timeline li.ev-eskalacja::before { border-color: var(--red); background: var(--red); }
.timeline li.ev-system::before { border-color: #aaa; }
.timeline li.internal .ev-body { background: #fffbe8; border-color: #f0e2a8; }
.ev-meta { font-size: 13px; color: var(--muted); }
.ev-body { margin-top: 6px; white-space: pre-wrap; background: #fafbf8; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.steps { display: flex; gap: 0; margin: 4px 0 18px; }
.steps span { flex: 1; text-align: center; font-size: 13px; padding: 8px 4px; background: #eceee9; color: var(--muted); position: relative; font-weight: 700; }
.steps span:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.steps span:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.steps span.done { background: var(--green); color: #fff; }
.steps span.current { background: var(--ink); color: #fff; }

/* ---- confirmation ---- */
.confirm-hero { text-align: center; padding: 34px 20px; }
.confirm-hero .tick { width: 72px; height: 72px; border-radius: 50%; background: var(--green); color: #fff; font-size: 42px; line-height: 72px; margin: 0 auto 14px; }
.confirm-hero .ticket-no { font-size: 28px; font-weight: 700; letter-spacing: .02em; }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-top: 4px solid var(--green); }
.stat .v { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 14px; }
.stat.bad { border-top-color: var(--red); }

/* ---- auth pages ---- */
body.guest .container { max-width: 440px; }
.auth-card { margin-top: 30px; }
.auth-card h1 { text-align: center; }

/* ---- live alert ---- */
.live-alert { position: fixed; right: 16px; bottom: 16px; background: var(--ink); color: #fff; padding: 14px 18px; border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.25); border-left: 6px solid var(--green); z-index: 50; display: none; max-width: 340px; }
.live-alert a { color: #b8f08f; font-weight: 700; }
.live-alert.show { display: block; }

.hours-table td, .hours-table th { padding: 6px 8px; }
.hours-table input[type=time] { width: 130px; }
code { background: #f0f1ed; padding: 1px 5px; border-radius: 3px; font-size: 14px; }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .mainnav { display: none; flex-direction: column; align-items: stretch; position: absolute; top: 100%; left: 0; right: 0; background: #fff; padding: 10px 16px 16px; border-bottom: 1px solid var(--line); box-shadow: 0 8px 20px rgba(0,0,0,.08); }
  .mainnav.open { display: flex; }
  .userbox { margin: 8px 0 0; justify-content: space-between; }
  .container { padding: 16px 16px 32px; }
  h1 { font-size: 22px; }
  table.list .hide-sm { display: none; }
  .priority-choice { flex-direction: column; }
}
