/* ===== Foxnox – modern design ===== */
:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0 0 .75rem; font-weight: 600; color: var(--text); }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 .75rem; }

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 .5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 1rem;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
}
.brand-text { font-weight: 700; letter-spacing: -0.01em; font-size: 0.98rem; }

.nav-group { margin-bottom: 1.1rem; }
.nav-title {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: 0 .75rem .35rem;
  font-weight: 600;
}
.nav-link {
  display: block;
  padding: .5rem .75rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 1px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.ico { display: inline-block; width: 1.2em; }

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.topbar-user { display: flex; align-items: center; gap: 1.5rem; }
.org-info { text-align: right; }
.org-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.org-name {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  padding: .25rem .6rem;
  border-radius: var(--radius-sm);
  display: inline-block;
}
.org-name:hover { background: var(--surface-2); text-decoration: none; }
.user-info {
  display: flex; align-items: center; gap: .75rem;
  padding-left: 1.5rem; border-left: 1px solid var(--border);
}
.user-name { font-size: .9rem; color: var(--text-muted); }
.user-logout {
  font-size: .85rem; color: var(--text-muted);
  padding: .35rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); text-decoration: none;
}
.user-logout:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.page { padding: 1.75rem 2rem 3rem; max-width: 1280px; width: 100%; }

/* ===== Cards / containers ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .9rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .35rem;
}
.stat .value {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.stat .sub { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }

/* ===== Buttons ===== */
button, .btn, input[type="submit"] {
  display: inline-block;
  padding: .55rem 1rem;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
button:hover, .btn:hover, input[type="submit"]:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  text-decoration: none;
}
button.secondary, .btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
button.secondary:hover, .btn.secondary:hover {
  background: var(--surface-2);
  border-color: #cbd5e1;
}
button.danger { background: var(--danger); border-color: var(--danger); }
button.small { padding: .3rem .65rem; font-size: .82rem; }

/* ===== Forms ===== */
form { display: block; }
label {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .9rem;
  font-weight: 500;
}
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="file"], select, textarea {
  display: block;
  width: 100%;
  padding: .55rem .75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: .3rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.grid label { margin-bottom: 0; }

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
thead {
  background: var(--surface-2);
}
th, td {
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
th {
  font-weight: 600;
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }

.tal { text-align: right; font-variant-numeric: tabular-nums; }
.summa { font-weight: 600; background: var(--surface-2); }
.summa td { border-top: 2px solid var(--border); }

.rader-tabell input, .rader-tabell select {
  margin: 0;
  border: 1px solid transparent;
  background: transparent;
}
.rader-tabell input:hover, .rader-tabell select:hover { border-color: var(--border); }
.rader-tabell input:focus, .rader-tabell select:focus { background: var(--surface); }

/* ===== Flash ===== */
.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .9rem;
  border: 1px solid;
}
.flash-success { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }

/* ===== Tags & badges ===== */
.tag {
  display: inline-block;
  padding: .15rem .55rem;
  font-size: .75rem;
  font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-warning { background: #fef3c7; color: var(--warning); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-info { background: var(--primary-soft); color: var(--primary); }

mark {
  background: var(--success-soft);
  color: var(--success);
  padding: .1rem .45rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
}

/* ===== Misc ===== */
.minor { color: var(--text-muted); font-size: .85rem; }
.toolbar {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.spacer { flex: 1; }

details summary {
  cursor: pointer;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '+ '; color: var(--primary); font-weight: 700; }
details[open] summary::before { content: '– '; }
details[open] summary { margin-bottom: 1rem; }

article {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  padding: .9rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

/* ===== Big numbers in reports ===== */
.big-number {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.big-number.positive { color: var(--success); }
.big-number.negative { color: var(--danger); }

/* ===== Responsive ===== */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .page, .topbar { padding: 1rem; }
}
