:root {
  --bg: #0f1117;
  --bg2: #1a1d26;
  --bg3: #242833;
  --border: #2d3140;
  --text: #e4e6ed;
  --text2: #9ca0b0;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.auth-card .logo p {
  color: var(--text2);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
}

.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text2);
}

.auth-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-link a:hover { text-decoration: underline; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  color: #86efac;
}

/* NAVBAR */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.navbar .nav-links {
  display: flex;
  gap: 4px;
}

.navbar .nav-links a {
  color: var(--text2);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.navbar .nav-links a:hover,
.navbar .nav-links a.active {
  color: var(--text);
  background: var(--bg3);
}

.navbar .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar .user-info {
  font-size: 13px;
  color: var(--text2);
}

.navbar .btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.navbar .btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* DASHBOARD */
.dashboard { padding: 24px 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
}

/* TICKET LIST */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.ticket-list { display: flex; flex-direction: column; gap: 8px; }

.ticket-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.ticket-item:hover { border-color: var(--accent); }

.ticket-item .ticket-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ticket-item .ticket-status.nowe { background: var(--accent); }
.ticket-item .ticket-status.wycenione { background: var(--warning); }
.ticket-item .ticket-status.zaakceptowane { background: #8b5cf6; }
.ticket-item .ticket-status.w_realizacji { background: #f97316; }
.ticket-item .ticket-status.zakonczone { background: var(--success); }
.ticket-item .ticket-status.zamkniete { background: var(--text2); }
.ticket-item .ticket-status.odrzucone { background: var(--danger); }

.ticket-item .ticket-info { flex: 1; min-width: 0; }
.ticket-item .ticket-info .ticket-subject { font-weight: 500; margin-bottom: 2px; }
.ticket-item .ticket-info .ticket-meta { font-size: 13px; color: var(--text2); }
.ticket-item .ticket-number { font-size: 13px; color: var(--text2); font-family: monospace; }

/* TICKET DETAIL */
.ticket-detail {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 16px;
}

.ticket-detail .ticket-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.ticket-detail .ticket-header h2 { font-size: 18px; }
.ticket-detail .ticket-header .meta { font-size: 13px; color: var(--text2); margin-top: 4px; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-nowe { background: rgba(59,130,246,0.2); color: #93c5fd; }
.badge-wycenione { background: rgba(245,158,11,0.2); color: #fcd34d; }
.badge-zaakceptowane { background: rgba(139,92,246,0.2); color: #c4b5fd; }
.badge-w_realizacji { background: rgba(249,115,22,0.2); color: #fdba74; }
.badge-zakonczone { background: rgba(34,197,94,0.2); color: #86efac; }
.badge-zamkniete { background: rgba(156,160,176,0.2); color: #9ca0b0; }
.badge-odrzucone { background: rgba(239,68,68,0.2); color: #fca5a5; }

.cost-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.cost-box .cost-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--warning);
}

.cost-box .cost-desc {
  font-size: 14px;
  color: var(--text2);
  margin-top: 4px;
}

.cost-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* MESSAGES */
.messages-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.messages-section h3 {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--text2);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.message-item {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.message-item.client {
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
  margin-left: 40px;
}

.message-item.admin {
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.2);
  margin-right: 40px;
}

.message-item.system {
  background: var(--bg3);
  border: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text2);
}

.message-item .sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 2px;
}

.message-item .time {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
}

.message-input {
  display: flex;
  gap: 8px;
}

.message-input input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.message-input input:focus { border-color: var(--accent); }

/* PHOTOS */
.photos-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.photos-grid img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}

/* DEVICES */
.device-list { display: flex; flex-direction: column; gap: 8px; }

.device-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.device-item .device-info h4 { font-size: 15px; font-weight: 500; }
.device-item .device-info .serial { font-size: 13px; color: var(--text2); font-family: monospace; }
.device-item .device-info .location { font-size: 13px; color: var(--text2); }

.device-actions { display: flex; gap: 8px; }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* PROFILE */
.profile-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 16px;
}

.profile-section h2 { margin-bottom: 20px; }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p { font-size: 15px; }

/* FILE INPUT */
.file-input-wrapper {
  position: relative;
  margin-top: 8px;
}

.file-input-wrapper input[type="file"] { display: none; }

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  transition: border-color 0.2s;
}

.file-input-label:hover { border-color: var(--accent); color: var(--text); }

.file-previews {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.file-previews .preview {
  position: relative;
  width: 60px;
  height: 60px;
}

.file-previews .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.file-previews .preview .remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* LOADING */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ADMIN EXTRAS */
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.85; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { opacity: 0.85; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-logout {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  padding: 6px 10px;
}
.btn-logout:hover { color: var(--danger); }

.nav-right { display: flex; align-items: center; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ticket-detail {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.ticket-detail .ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 16px;
}
.ticket-detail .ticket-header h2 { margin-bottom: 4px; font-size: 18px; }
.ticket-detail .meta { font-size: 13px; color: var(--text2); }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-nowe { background: var(--accent); color: #fff; }
.badge-wycenione { background: var(--warning); color: #000; }
.badge-zaakceptowane { background: #8b5cf6; color: #fff; }
.badge-w_realizacji { background: #06b6d4; color: #fff; }
.badge-zakonczone { background: var(--success); color: #fff; }
.badge-zamkniete { background: var(--text2); color: var(--bg); }
.badge-odrzucone { background: var(--danger); color: #fff; }

.messages-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.messages-section h3 { margin-bottom: 12px; font-size: 15px; }

.message-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.message-item {
  background: var(--bg3);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  max-width: 80%;
}
.message-item.client { margin-left: auto; background: var(--accent); color: #fff; }
.message-item.admin { background: var(--bg3); }
.message-item.system { background: var(--border); font-style: italic; font-size: 13px; text-align: center; max-width: 100%; }
.message-item .sender { font-size: 11px; font-weight: 600; margin-bottom: 2px; opacity: 0.7; }
.message-item .time { font-size: 11px; margin-top: 4px; opacity: 0.5; }

.message-input {
  display: flex;
  gap: 8px;
}
.message-input input { flex: 1; }

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.photos-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
}

/* RESPONSIVE */
@media (max-width: 640px) {
  .auth-card { padding: 24px; }
  .navbar { padding: 0 12px; }
  .navbar .nav-links a { padding: 6px 10px; font-size: 13px; }
  .ticket-item { flex-wrap: wrap; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .message-item.client { margin-left: 16px; }
  .message-item.admin { margin-right: 16px; }
  .cost-actions { flex-direction: column; }
}
