/* AIRO Themen — dark, functional, mobile-first */
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-bg: #1f3a5f;
  --danger: #f85149;
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 8px;
  --tap: 44px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg3);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; min-height: var(--tap); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 80px; resize: vertical; }
a { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 8px 14px; border-radius: var(--radius);
  background: var(--bg3); border: 1px solid var(--border); white-space: nowrap;
}
.btn.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #388bfd; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); background: var(--bg3); }
.btn.danger { color: var(--danger); }
.btn:active { transform: scale(.97); }

/* Overlays & modals */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(1,4,9,.8);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto;
  overflow-x: hidden; display: flex; flex-direction: column;
}
.modal-body { overflow-x: hidden; }
.modal-body > * { max-width: 100%; min-width: 0; }
#tm-back { display: none; }
.login-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
}
.login-box h1 { font-size: 22px; }
.login-box p { color: var(--text-dim); }
.error-msg { color: var(--danger); min-height: 1.4em; font-size: 14px; }

.modal-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg2); z-index: 2;
}
.modal-head .ticket-id { color: var(--text-dim); font-weight: 600; margin-right: auto; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.quick-modal { padding: 20px; gap: 12px; }
.quick-modal h2 { font-size: 18px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 130px; }
.row.right { justify-content: flex-end; }
.row.right > * { flex: 0 0 auto; min-width: auto; width: auto; }

/* Topbar */
#topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg2);
  position: sticky; top: 0; z-index: 50; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: .5px; }
.brand span { color: var(--accent); font-weight: 500; margin-left: 4px; }
#nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav button {
  padding: 8px 12px; min-height: var(--tap); border-radius: var(--radius);
  color: var(--text-dim); font-weight: 600; white-space: nowrap;
}
#nav button.active { color: var(--text); background: var(--bg3); }
.topbar-right { display: flex; gap: 8px; margin-left: auto; align-items: center; }
#user-switch { width: auto; min-width: 90px; }

.dropdown {
  position: fixed; top: 56px; right: 12px; z-index: 60;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; min-width: 240px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.dropdown button { padding: 12px 16px; text-align: left; min-height: var(--tap); }
.dropdown button:hover { background: var(--bg3); }

/* Filter bar */
#filterbar {
  display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto;
  border-bottom: 1px solid var(--border); background: var(--bg);
  scrollbar-width: none;
}
#filterbar::-webkit-scrollbar { display: none; }
#filterbar > * { flex: 0 0 auto; width: auto; }
#search { flex: 1 1 160px; min-width: 140px; }

/* Views */
#views { padding: 12px; }
.view { max-width: 1200px; margin: 0 auto; }

/* Ticket card (shared by list & kanban) */
.tcard {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; position: relative;
  display: flex; flex-direction: column; gap: 6px;
}
.tcard:hover { border-color: var(--accent); }
.tcard .t-title { font-weight: 600; word-break: break-word; }
.tcard .t-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--text-dim); }
.tcard.unseen::before {
  content: ""; position: absolute; top: 10px; right: 10px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}
.tcard.dragging { opacity: .4; }
.chip {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; color: #0d1117;
}
.pill { padding: 1px 7px; border-radius: 4px; font-size: 11.5px; font-weight: 700; }
.prio-Low { background: #263041; color: #9fb2cb; }
.prio-Med { background: #1f3a5f; color: #79b8ff; }
.prio-High { background: #4d2d12; color: #f0883e; }
.prio-Urgent { background: #4b1113; color: #ff7b72; }
.due { font-weight: 600; }
.due.overdue { color: var(--danger); }
.blocked-flag { color: var(--danger); font-weight: 700; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff;
}
.av-DJ { background: #8957e5; } .av-Marina { background: #db61a2; } .av-Ario { background: #2ea043; }
.av-none { background: var(--bg3); color: var(--text-dim); }
.ooo-badge { font-size: 11px; }

/* List view */
#view-list { display: flex; flex-direction: column; gap: 8px; }
.list-count { color: var(--text-dim); font-size: 13px; padding: 2px 4px; }
.folder-head {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-weight: 700; font-size: 14px;
}
.folder-head:first-child { margin-top: 0; }
.folder-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.folder-head .count { color: var(--text-dim); font-weight: 500; font-size: 13px; }
.folder-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  padding: 1px 7px; border-radius: 4px; background: var(--bg3); color: var(--text-dim);
}
.folder-tag .folder-dot { width: 7px; height: 7px; }

/* Timeline */
#view-timeline { max-width: 800px; position: relative; padding-left: 4px; }
.tl-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; gap: 8px; }
.tl-day { display: flex; gap: 14px; position: relative; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 14px; }
.tl-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--bg3);
  border: 2px solid var(--border); flex: 0 0 auto; margin-top: 5px;
}
.tl-day.today .tl-dot { background: var(--accent); border-color: var(--accent); }
.tl-day.past .tl-dot { border-color: var(--text-dim); }
.tl-line { width: 2px; flex: 1; background: var(--border); min-height: 12px; }
.tl-content { flex: 1; padding-bottom: 20px; min-width: 0; }
.tl-date { font-weight: 700; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.tl-day.today .tl-date { color: var(--accent); }
.tl-date .overdue { color: var(--danger); }
.tl-items { display: flex; flex-direction: column; gap: 8px; }
.tl-note {
  background: var(--bg2); border: 1px solid var(--border); border-left: 3px solid var(--warn);
  border-radius: var(--radius); padding: 10px 12px;
}
.tl-note h3 { font-size: 15px; display: flex; align-items: baseline; gap: 8px; }
.tl-note h3 .by { font-size: 11.5px; color: var(--text-dim); font-weight: 400; margin-left: auto; }
.tl-note .md { margin-top: 4px; }
.tl-note-actions { display: flex; gap: 4px; margin-top: 6px; }
.tl-note-actions button { color: var(--text-dim); font-size: 12.5px; min-height: 32px; padding: 4px 8px; }
.tl-note-actions button:hover { color: var(--text); }
.note-form {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px;
}

/* Kanban */
#view-kanban {
  display: flex; gap: 12px; overflow-x: auto; align-items: flex-start;
  max-width: none; padding-bottom: 24px; scroll-snap-type: x proximity;
}
.kcol {
  flex: 0 0 290px; scroll-snap-align: start;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; max-height: calc(100vh - 180px);
}
.kcol-head {
  padding: 10px 12px; font-weight: 700; display: flex; gap: 8px; align-items: center;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg2); border-radius: 10px 10px 0 0;
}
.kcol-head .count { color: var(--text-dim); font-weight: 500; font-size: 13px; }
.kcol-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }
.kcol.dragover .kcol-body { background: var(--accent-bg); border-radius: 0 0 10px 10px; }
.drop-slot { height: 3px; border-radius: 2px; }
.drop-slot.active { background: var(--accent); height: 6px; }

/* Graph */
#view-graph { position: relative; height: calc(100vh - 170px); max-width: none; }
#graph-canvas { width: 100%; height: 100%; display: block; border-radius: 10px; background: var(--bg2); border: 1px solid var(--border); touch-action: none; }
#graph-hint { position: absolute; bottom: 10px; left: 12px; color: var(--text-dim); font-size: 12px; pointer-events: none; }

/* Dashboard */
#view-dashboard { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { #view-dashboard { grid-template-columns: 1fr 1fr; } }
.dash-section { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.dash-section h2 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.dash-section h2 .count { color: var(--text-dim); font-weight: 500; }
.dash-section .stack { display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--text-dim); font-style: italic; padding: 8px 2px; }

/* Activity */
#view-activity { display: flex; flex-direction: column; gap: 2px; max-width: 800px; }
.act-row {
  display: flex; gap: 10px; padding: 10px 8px; border-bottom: 1px solid var(--border);
  font-size: 14px; align-items: baseline; cursor: pointer;
}
.act-row:hover { background: var(--bg2); }
.act-time { color: var(--text-dim); font-size: 12px; flex: 0 0 auto; min-width: 110px; }
.act-actor { font-weight: 700; }
.act-detail { color: var(--text-dim); }

/* Ticket modal internals */
.tm-title-input { font-size: 18px; font-weight: 700; }
.tm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; }
.label-picker { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.label-picker .chip { cursor: pointer; opacity: .35; border: 1px solid transparent; min-height: 28px; }
.label-picker .chip.on { opacity: 1; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.dep-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.dep-row .dep-link { cursor: pointer; color: var(--accent); font-weight: 600; }
.dep-row .state-tag { font-size: 11px; color: var(--text-dim); }
.dep-add { display: flex; gap: 8px; }
.subtask-row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.subtask-row input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--ok); flex: 0 0 auto; }
.subtask-row .st-title { flex: 1; word-break: break-word; }
.subtask-row .st-title.done { text-decoration: line-through; color: var(--text-dim); }
.subtask-add { display: flex; gap: 8px; }

/* Dropzone */
.dropzone {
  min-height: 200px; border: 2px dashed var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--text-dim); cursor: pointer; text-align: center; padding: 16px;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover, .dropzone:hover { border-color: var(--accent); background: var(--accent-bg); color: var(--text); }
.dropzone .dz-icon { font-size: 34px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumb { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb .del {
  position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65);
  border-radius: 6px; width: 30px; height: 30px; color: #fff; display: flex; align-items: center; justify-content: center;
}
.comment { background: var(--bg3); border-radius: var(--radius); padding: 10px 12px; }
.comment .c-head { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.comment .c-head b { color: var(--text); }
.comment-add { display: flex; flex-direction: column; gap: 8px; }

/* Markdown */
.md p { margin: 0 0 8px; } .md p:last-child { margin: 0; }
.md h1, .md h2, .md h3 { margin: 12px 0 6px; line-height: 1.25; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3 { font-size: 15px; }
.md code { background: var(--bg3); padding: 1px 5px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, monospace; }
.md pre { background: var(--bg3); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
.md pre code { background: none; padding: 0; }
.md ul, .md ol { margin: 4px 0 8px 22px; }
.md blockquote { border-left: 3px solid var(--border); padding-left: 10px; color: var(--text-dim); margin: 8px 0; }

/* Lightbox */
#lightbox { background: rgba(1,4,9,.94); }
#lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }
#lightbox button { position: fixed; top: 12px; right: 12px; font-size: 20px; }

/* Toast */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast-msg {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 20px;
  padding: 10px 18px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.4);
  animation: toast-in .2s ease-out;
}
.toast-msg.error { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Mobile */
@media (max-width: 640px) {
  /* Header: row 1 = AIRO + actions, row 2 = view nav (filterbar is row 3) */
  #topbar { gap: 6px; padding: 6px 8px; flex-wrap: wrap; }
  .brand { order: 1; }
  .brand span { display: none; }
  .topbar-right { order: 2; margin-left: auto; }
  #nav { order: 3; flex: 1 1 100%; }
  #btn-new { padding: 8px 10px; }
  #tm-back { display: inline-flex; }
  #tm-close { display: none; }
  #views { padding: 8px; }
  .modal { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; border: none; }
  .overlay { padding: 0; }
  .overlay#quick-modal, .overlay#lightbox { padding: 12px; }
  #quick-modal .modal { height: auto; border-radius: 12px; border: 1px solid var(--border); }
  .kcol { flex: 0 0 84vw; max-height: calc(100vh - 200px); }
  #view-graph { height: calc(100vh - 200px); }
  .act-time { min-width: 78px; }
}
