/* ============================================
   eKnjigovodstvo — dizajn sistem
   ============================================ */

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E3E6EA;
  --border-strong: #C9CED6;

  --text-primary: #16181D;
  --text-secondary: #5B6270;
  --text-muted: #8A909C;

  --sidebar-bg: #16181D;
  --sidebar-text: #C9CED6;
  --sidebar-text-active: #FFFFFF;
  --sidebar-hover: #23262E;

  --accent: #2757D6;
  --accent-hover: #1E46B8;
  --accent-bg: #EAF0FE;

  --success: #1A8A5F;
  --success-bg: #E4F5EE;
  --warning: #B8720A;
  --warning-bg: #FDF1DF;
  --danger: #C4342A;
  --danger-bg: #FBEAE8;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16,18,23,0.06);
  --shadow-md: 0 4px 16px rgba(16,18,23,0.08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

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

h1, h2, h3, h4 {
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

p { margin: 0 0 0.75rem; color: var(--text-secondary); }

/* ---------- Layout ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 0.2px;
}
.sidebar-brand span { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}
.sidebar-divider {
  width: 80%;
  height: 1px;
  margin: 10px auto 0;
  background: rgba(255,255,255,0.12);
  border: none;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
}
.sidebar-footer .user-name { color: #fff; font-weight: 600; display: block; }
.sidebar-footer a { color: var(--text-muted); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar h1 { font-size: 17px; margin: 0; }

.content { padding: 24px; flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 600; color: var(--text-primary); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}
.field { margin-bottom: 16px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 400; font-size: 13.5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px;
  background: var(--surface);
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}
.no-sticky th {
  position: static;
  box-shadow: none;
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }

/* ---------- Bedzevi po firmi ---------- */
.badge-c1 { background: #EAF0FE; color: #2757D6; }
.badge-c2 { background: #F3E8FD; color: #7C3AED; }
.badge-c3 { background: #E0F7F5; color: #0D9488; }
.badge-c4 { background: #FFF1E0; color: #C2650A; }
.badge-c5 { background: #FDE8F1; color: #BE185D; }
.badge-c6 { background: #EAFBE7; color: #1A8A5F; }

/* ---------- Status select (boja po vrednosti) ---------- */
.status-select { font-weight: 600; border-radius: 6px; }
.status-izdata { background: var(--surface-2); color: var(--text-secondary); }
.status-placena { background: var(--success-bg); color: var(--success); }
.status-delimicno_placena { background: var(--warning-bg); color: var(--warning); }
.status-stornirana { background: var(--danger-bg); color: var(--danger); }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(196,52,42,0.2); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(26,138,95,0.2); }

/* ---------- Auth pages (no sidebar) ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.auth-brand {
  text-align: center;
  margin-bottom: 24px;
  font-size: 18px;
  font-weight: 700;
}
.auth-brand span { color: var(--accent); }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
