/* Fin Tracker - light theme, mobile-first */
:root {
  --accent: #2b6cb0;
  --accent-dark: #22548a;
  --ink: #111;
  --muted: #666;
  --border: #e2e8f0;
  --bg: #fff;
  --bg-soft: #f7fafc;
  --danger: #c53030;
  --success: #2f855a;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p  { margin: .4rem 0; }

.muted { color: var(--muted); }
.center { text-align: center; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Layout */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}
.main--full { max-width: 420px; padding-top: 4rem; }

/* Nav */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.nav__inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem;
  flex-wrap: wrap;
}
.nav__brand { font-weight: 600; color: var(--ink); font-size: 1.1rem; }
.nav__links { display: flex; gap: 1rem; flex: 1 1 auto; flex-wrap: wrap; }
.nav__links a { color: var(--ink); padding: .25rem 0; border-bottom: 2px solid transparent; }
.nav__links a.active { border-bottom-color: var(--accent); color: var(--accent); }
.nav__user { display: flex; align-items: center; gap: .5rem; }
.nav__user-name { font-size: .9rem; color: var(--muted); }

/* Forms */
label {
  display: block;
  font-size: .85rem;
  margin: .7rem 0 .2rem;
  color: var(--ink);
  font-weight: 500;
}
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea { resize: vertical; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .35rem;
  font: inherit;
  padding: .55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  margin-top: .5rem;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn--outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn--outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn--sm { padding: .3rem .65rem; font-size: .85rem; margin-top: 0; }

/* Cards & tiles */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--bg-soft);
}
.tile__label { font-size: .85rem; color: var(--muted); }
.tile__value { font-size: 1.6rem; font-weight: 600; margin-top: .25rem; }

/* Grid */
.grid2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 720px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
}

/* Tables */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
.table th, .table td {
  text-align: left;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
}
.table th { background: var(--bg-soft); font-weight: 600; }
.table__row-clickable { cursor: pointer; }
.table__row-clickable:hover { background: var(--bg-soft); }

/* Responsive tables: stacked cards on small screens */
@media (max-width: 599px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem;
    margin-bottom: .5rem;
  }
  .table td {
    border: 0;
    padding: .25rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
  }
  .table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
  }
}

/* Toolbar */
.toolbar {
  display: flex; gap: 1rem; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.toolbar h1 { margin: 0; flex: 1; }
.toolbar input[type=search] { max-width: 280px; }

/* Pager */
.pager {
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  margin-top: 1rem;
}

/* Lists */
.list { list-style: none; padding: 0; margin: 0; }
.list__item {
  display: flex; gap: 1rem; align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.list__item:last-child { border-bottom: 0; }
.list__item a {
  display: flex; gap: 1rem; width: 100%;
  color: var(--ink);
}

/* Back link */
.back { display: inline-block; margin-bottom: .5rem; }

/* Tabs */
.tabs {
  display: flex; gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
}
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .5rem 1rem; font: inherit; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Dropzone */
.dropzone {
  margin-top: .75rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  background: var(--bg-soft);
  transition: border-color .15s, background .15s;
}
.dropzone--active {
  border-color: var(--accent);
  background: #eaf2fa;
}
.dropzone p { margin: 0 0 .5rem; color: var(--muted); }

/* Attachments */
.attachments {
  list-style: none; padding: 0; margin: .75rem 0 0;
  display: flex; flex-direction: column; gap: .5rem;
}
.attachment {
  display: flex; gap: .5rem; align-items: center;
  padding: .4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.attachment__name { flex: 1 1 auto; word-break: break-all; font-size: .9rem; }
.thumb {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.pdf-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .7rem; font-weight: 600; color: var(--danger);
}
.pdf-link { display: flex; gap: .5rem; align-items: center; }

/* Progress bar */
.progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--accent);
  transition: width .2s;
}

/* Toasts */
.toasts {
  position: fixed; top: 1rem; right: 1rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 1000;
  max-width: calc(100% - 2rem);
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: .6rem .9rem;
  border-radius: var(--radius);
  font-size: .9rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: slideIn .2s ease-out;
}
.toast--error { background: var(--danger); }
.toast--success { background: var(--success); }
.toast--info { background: var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Login */
.login { display: flex; justify-content: center; }
.login .card { width: 100%; }

/* Chart container */
.chart {
  width: 100%;
  overflow: hidden;
  margin-bottom: 1rem;
}
.chart svg { width: 100%; height: auto; display: block; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .dropzone, .progress__bar { transition: none; }
}

/* ---- Icons (SVG sprite) ---- */
.ic {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  vertical-align: -0.18em;
  color: currentColor;
}
.ic--lg { width: 1.8em; height: 1.8em; }
.nav__links a, .btn, .back { display: inline-flex; align-items: center; gap: .4em; }

/* Nav lang + ghost button */
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
}
.btn--ghost:hover { background: rgba(0,0,0,.04); }
.nav__lang { margin-right: .4rem; }

/* Search bar with icon */
.search {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 .6em;
}
.search input {
  border: none;
  outline: none;
  padding: .45em 0;
  width: 12rem;
  font: inherit;
  background: transparent;
}
.search .ic { color: var(--muted); }

/* Login lang switcher */
.login__lang { margin-top: 1rem; text-align: center; }

/* PDF icon tint */
.pdf-icon { color: var(--accent); }

/* Addresses + contact on order detail */
.contact { list-style: none; padding: 0; margin: .25rem 0 .75rem; display: flex; flex-direction: column; gap: .2rem; }
.contact__label { color: var(--muted); font-size: .85em; margin-right: .3em; }
.addr {
  font: inherit;
  white-space: pre-wrap;
  background: #f7f9fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  margin: .25rem 0 .9rem;
  line-height: 1.45;
}
.badge {
  display: inline-block;
  font-size: .75em;
  padding: .15em .55em;
  border-radius: 999px;
  margin-left: .5em;
  vertical-align: middle;
  font-weight: 500;
  letter-spacing: .01em;
}
.badge--ok   { background: #e6f4ea; color: #1e7b3a; }
.badge--warn { background: #fff4e5; color: #9a5b00; }

