:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --accent: #0d5c63;
  --accent-hover: #09484d;
  --danger: #9b2c2c;
  --border: #d5dde5;
  --ok: #1b6b3a;
  --sidebar: #0b3d42;
  --sidebar-text: #d7e8ea;
  --radius: 8px;
  --font: "Segoe UI", system-ui, sans-serif;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--accent); }

.app-body { min-height: 100vh; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0d5c63 0%, #0b3d42 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar a { color: var(--sidebar-text); text-decoration: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  padding: 0.5rem 0.65rem 1rem;
}

.sidebar-brand a { color: #fff; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-nav a {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 0.85rem;
  margin-top: 0.85rem;
}

.user-chip {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0.35rem 0.75rem;
  font-size: 0.9rem;
}

.user-chip strong { color: #fff; }

.btn-block { width: 100%; }

.role-badge { align-self: flex-start; }
.role-admin { background: #ffe8c8; color: #8a5200; }
.role-urednik { background: #d9eef1; color: #0d5c63; }
.role-pregled { background: #eef2f5; color: #5c6b7a; }

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-bar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.sidebar-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: inherit;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
}

.mobile-bar .sidebar-toggle {
  border-color: var(--border);
  color: var(--text);
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.container {
  max-width: 1100px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.25rem 2rem;
  flex: 1;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.page-head h1 { margin: 0 0 0.25rem; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at top left, rgba(13, 92, 99, 0.12), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(13, 92, 99, 0.08), transparent 45%),
    var(--bg);
}

.auth-wrap { width: min(100%, 400px); padding: 1rem; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.auth-card h1 {
  margin: 0 0 0.25rem;
  color: var(--accent);
}

.muted { color: var(--muted); font-size: 0.95rem; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.form-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.check-inline {
  flex-direction: row;
  align-items: center;
  font-weight: 500;
  gap: 0.45rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="url"],
input[type="search"],
select,
textarea {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  width: 100%;
  background: #fff;
}

.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.btn-link.danger { color: var(--danger); }

.inline-form { display: inline; margin: 0; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fde8e8;
  color: var(--danger);
  border: 1px solid #f5c2c2;
}

.alert-success {
  background: #e7f6ec;
  color: var(--ok);
  border: 1px solid #b7e0c2;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
}

.data-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #fafbfc;
  white-space: nowrap;
}

.data-table td {
  word-break: break-word;
}

.data-table td:first-child,
.data-table th:first-child {
  white-space: nowrap;
}

.data-table .col-contact,
.data-table .col-media,
.data-table .col-email {
  min-width: 10rem;
}

.data-table .col-actions {
  width: 1%;
  white-space: nowrap;
}

.data-table .col-status {
  width: 1%;
  white-space: nowrap;
}

.data-table .col-status .badge {
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }

.actions {
  white-space: nowrap;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filters-bouncer {
  grid-template-columns: 1.5fr 1fr 1fr 0.9fr 1fr auto;
}

.filters-advanced {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 0.9fr 1fr 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.stat-link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-link:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(13, 92, 99, 0.15);
}

.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel-head h2 { margin: 0; font-size: 1.1rem; }

.bar-stack {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef2f5;
  margin-bottom: 0.85rem;
}

.bar-seg { height: 100%; min-width: 2px; }

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.legend-list a {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.cat-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.mini-bar {
  height: 6px;
  background: #eef2f5;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.mini-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.email-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.alert-warning {
  background: #fff8e6;
  color: #8a6d1d;
  border: 1px solid #f0d78c;
}

.badge-bouncer { text-transform: lowercase; }

.bouncer-unknown,
.bouncer-unchecked {
  background: #eef2f5;
  color: var(--muted);
}

.bouncer-text-deliverable { color: #1a7a3c; }
.bouncer-text-undeliverable { color: #b42318; }
.bouncer-text-risky { color: #c05600; }

@media (max-width: 800px) {
  .filters,
  .filters-bouncer,
  .filters-advanced,
  .grid-2,
  .detail-grid,
  .dashboard-panels,
  .repeat-row,
  #phone-rows .repeat-row {
    grid-template-columns: 1fr;
  }

  .dl { grid-template-columns: 1fr; }
  .dl dt { margin-top: 0.35rem; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label { font-weight: 600; }

.quick-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin: 0;
}

.fieldset legend {
  padding: 0 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.media-picker-add {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.media-picker-add select {
  flex: 1;
  min-width: 0;
}

.media-picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.media-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border, #d7dde5);
  border-radius: 6px;
  background: #f8fafc;
}

.settings-check {
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.35rem 0;
}

.settings-check input {
  margin-top: 0.35rem;
}

.repeat-rows { display: flex; flex-direction: column; gap: 0.65rem; margin-bottom: 0.75rem; }

.repeat-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.65rem;
  align-items: center;
}

#phone-rows .repeat-row {
  grid-template-columns: 1fr 1fr auto auto;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--muted);
  font-weight: 600;
}

.badge-ok { background: #e7f6ec; color: var(--ok); }
.badge-off { background: #f0f0f0; color: var(--muted); }

/* Bouncer statusi — mora biti nakon .badge da se boje ne pregaze */
.badge.bouncer-deliverable,
.bar-seg.bouncer-deliverable {
  background: #d8f5e1;
  color: #1a7a3c;
}

.badge.bouncer-undeliverable,
.bar-seg.bouncer-undeliverable {
  background: #ffd6d6;
  color: #b42318;
}

.badge.bouncer-risky,
.bar-seg.bouncer-risky {
  background: #ffe4c4;
  color: #c05600;
}

.badge.bouncer-unknown,
.badge.bouncer-unchecked,
.bar-seg.bouncer-unknown,
.bar-seg.bouncer-unchecked {
  background: #eef2f5;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.dl dt { color: var(--muted); font-size: 0.9rem; }
.dl dd { margin: 0; }

.plain-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}

.plain-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.meta-foot { font-size: 0.85rem; margin-top: 1.5rem; }

code {
  font-size: 0.85rem;
  background: #eef2f5;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.alert {
  position: relative;
  padding-right: 2.5rem;
}

.flash-close {
  position: absolute;
  right: 0.6rem;
  top: 0.45rem;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
}

.flash-fade {
  opacity: 0;
  transition: opacity 0.6s ease;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state h2 { margin: 0 0 0.5rem; }

.empty-icon {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.35;
  margin-bottom: 0.5rem;
}

.error-state .empty-icon { color: var(--danger); }

.filters-audit {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.9fr 0.9fr 0.9fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.audit-table pre {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  white-space: pre-wrap;
  max-width: 420px;
}

.diff-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.diff-list li { margin-bottom: 0.25rem; }

.diff-old {
  text-decoration: line-through;
  color: var(--danger);
  opacity: 0.85;
}

.diff-new { color: var(--ok); font-weight: 600; }

.badge-action-created { background: #e7f6ec; color: var(--ok); }
.badge-action-updated { background: #e8f1ff; color: #1e4d8c; }
.badge-action-deleted { background: #fde8e8; color: var(--danger); }
.badge-action-deactivated { background: #fff4d6; color: #8a6d1d; }
.badge-action-login,
.badge-action-logout { background: #eef2f5; color: var(--muted); }

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.nowrap { white-space: nowrap; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 30;
  }

  .mobile-bar { display: flex; }
  .sidebar-brand .sidebar-toggle { display: none; }

  .filters-audit { grid-template-columns: 1fr; }
}

