/* ==========================================================================
   Arvete haldus — Erply-laadne kasutajaliides
   ========================================================================== */
:root {
  --tume:        #232f3e;   /* ülemine menüüriba */
  --tume-hover:  #33414f;
  --kollane:     #f2c94c;   /* olekuriba ja tegevusnupud */
  --kollane-tume:#e0b73c;
  --sinine:      #4a90c2;   /* aktiivne valik vasakus paneelis */
  --sinine-tume: #3a7ba6;
  --sinine-hele: #eaf3f9;
  --hall-paneel: #ececec;   /* vasak filtripaneel */
  --hall-aare:   #d8d8d8;
  --hall-tekst:  #7a7a7a;
  --tekst:       #2b2b2b;
  --taust:       #ffffff;
  --roheline:    #2e7d52;
  --roheline-hele:#e6f4ec;
  --punane:      #c0392b;
  --punane-hele: #fdecea;
  --oranz:       #b26a00;
  --oranz-hele:  #fdf3e3;
  --lilla:       #6b4fa8;
  --lilla-hele:  #f0ebfa;
  --raadius:     4px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--tekst);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Ülemine menüüriba
   ========================================================================== */
.ylariba {
  background: var(--tume);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 18px;
  height: 54px;
  position: sticky; top: 0; z-index: 60;
}
.ylariba .logo {
  font-weight: 700; font-size: 19px; letter-spacing: 1.2px;
  margin-right: 14px; white-space: nowrap; color: #fff;
}
.ylariba .otsinupp {
  background: none; border: 0; color: #c9d1d9; font-size: 17px;
  padding: 8px 12px; cursor: pointer; border-radius: 3px;
}
.ylariba .otsinupp:hover { background: var(--tume-hover); color: #fff; }

.peamenyy { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.peamenyy button {
  background: none; border: 0; color: #dfe4ea; font-family: inherit;
  font-size: 14.5px; padding: 17px 15px; cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.peamenyy button:hover { color: #fff; background: var(--tume-hover); }
.peamenyy button.aktiivne {
  color: #fff; font-weight: 600; border-bottom-color: var(--kollane);
}
.peamenyy .marge {
  background: #e0523f; color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 9px; margin-left: 6px; vertical-align: 1px;
}

.ylariba .parem { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.ylariba .ikoonnupp {
  background: none; border: 0; color: #c9d1d9; font-size: 16px;
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
}
.ylariba .ikoonnupp:hover { background: var(--tume-hover); color: #fff; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid #6b7684;
  color: #fff; background: none; font-size: 12px; font-weight: 700;
  cursor: pointer; letter-spacing: .5px;
}
.avatar:hover { background: var(--tume-hover); }

/* kasutajamenüü */
.ripp {
  position: absolute; top: 50px; right: 14px; background: #fff;
  border: 1px solid var(--hall-aare); border-radius: 4px; min-width: 210px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 200; overflow: hidden;
}
.ripp .pais { padding: 11px 14px; border-bottom: 1px solid #eee; background: #fafafa; }
.ripp .pais b { display: block; font-size: 13.5px; }
.ripp .pais span { font-size: 11.5px; color: var(--hall-tekst); }
.ripp button {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  background: none; border: 0; font-family: inherit; font-size: 13.5px;
  cursor: pointer; color: var(--tekst);
}
.ripp button:hover { background: #f3f4f6; }

/* ==========================================================================
   Kollane olekuriba (alamvaated)
   ========================================================================== */
.olekuriba {
  background: var(--kollane);
  display: flex; align-items: center; gap: 0;
  padding: 0 22px; min-height: 40px; flex-wrap: wrap;
  position: sticky; top: 54px; z-index: 55;
}
.olekuriba button {
  background: none; border: 0; font-family: inherit; cursor: pointer;
  font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: #6d5a12; padding: 11px 14px; white-space: nowrap;
}
.olekuriba button:hover { color: #2b2b2b; }
.olekuriba button.aktiivne { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.12); }
.olekuriba .nool { color: #b99a2e; font-size: 12px; user-select: none; }
.olekuriba .versioon {
  margin-left: auto; font-size: 12.5px; font-weight: 700; color: #6d5a12;
  padding: 11px 0;
}

/* ==========================================================================
   Paigutus: vasak filtripaneel + sisu
   ========================================================================== */
.kere { display: flex; align-items: flex-start; min-height: calc(100vh - 94px); }

.filtripaneel {
  width: 236px; flex: 0 0 236px; background: var(--hall-paneel);
  align-self: stretch; padding-bottom: 30px;
}
.filtripaneel .rypm { padding: 14px 16px 7px; display: flex; align-items: center; gap: 8px; }
.filtripaneel .rypm .ruudud {
  display: grid; grid-template-columns: 6px 6px; grid-gap: 2px;
}
.filtripaneel .rypm .ruudud i { width: 6px; height: 6px; background: #2b2b2b; display: block; }
.filtripaneel .rypm b { font-size: 14px; font-weight: 700; }
.filtripaneel .valik {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px 9px 26px; font-size: 14px; cursor: pointer; color: #333;
  border: 0; background: none; width: 100%; text-align: left; font-family: inherit;
}
.filtripaneel .valik:hover { background: #e0e0e0; }
.filtripaneel .valik.aktiivne { background: var(--sinine); color: #fff; }
.filtripaneel .valik .arv {
  margin-left: auto; font-size: 11.5px; color: var(--hall-tekst);
  font-variant-numeric: tabular-nums;
}
.filtripaneel .valik.aktiivne .arv { color: rgba(255,255,255,.85); }
.filtripaneel .lahutaja { height: 10px; }

.sisuala { flex: 1; min-width: 0; padding: 22px 26px 60px; background: #fff; }

/* ==========================================================================
   Lehe pealkiri ja tegevused
   ========================================================================== */
.lehepais { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.lehepais h1 { margin: 0; font-size: 30px; font-weight: 400; letter-spacing: -.3px; }
.lehepais .parem { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ringnupp {
  width: 30px; height: 30px; border-radius: 50%; background: #4a4a4a; color: #fff;
  border: 0; font-size: 14px; line-height: 1; cursor: pointer; letter-spacing: 1px;
}
.ringnupp:hover { background: #2b2b2b; }

/* ==========================================================================
   Nupud
   ========================================================================== */
button, .nupp {
  font-family: inherit; font-size: 13.5px;
  padding: 7px 16px; border-radius: 3px; border: 1px solid var(--hall-aare);
  background: #fff; color: var(--tekst); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
button:hover, .nupp:hover { background: #f4f4f4; }
button:disabled { opacity: .5; cursor: not-allowed; }

button.esmane, .nupp.esmane {
  background: var(--kollane); border-color: var(--kollane); color: #4a3c07;
  font-weight: 600;
}
button.esmane:hover, .nupp.esmane:hover { background: var(--kollane-tume); }

button.sinine { background: var(--sinine); border-color: var(--sinine); color: #fff; }
button.sinine:hover { background: var(--sinine-tume); }
button.roheline { background: var(--roheline); border-color: var(--roheline); color: #fff; }
button.roheline:hover { background: #24603f; }
button.oht { background: #fff; border-color: #e6b0aa; color: var(--punane); }
button.oht:hover { background: var(--punane-hele); }
button.vaike { padding: 4px 10px; font-size: 12.5px; }
button.puhas { border-color: transparent; background: transparent; }
button.puhas:hover { background: #f0f0f0; }

/* ==========================================================================
   Vormid — Erply suured ümarad väljad
   ========================================================================== */
label {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--hall-tekst);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: .5px;
}
input, select, textarea {
  width: 100%; padding: 11px 14px; font-family: inherit; font-size: 14px;
  border: 1px solid #dcdcdc; border-radius: 22px; background: #fff; color: var(--tekst);
}
textarea { border-radius: 10px; resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--sinine); box-shadow: 0 0 0 3px rgba(74,144,194,.14);
}
input[readonly] { background: #f6f6f6; color: var(--hall-tekst); }
input::placeholder { color: #b3b3b3; text-transform: uppercase; font-size: 13px; letter-spacing: .3px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 16'%3E%3Cpath fill='%23555' d='M5 0L9 5H1zM5 16L1 11h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  background-size: 9px 14px; padding-right: 34px;
}

.valjad { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.valjad.kaks { grid-template-columns: 1fr 1fr; }
.valjad.kolm { grid-template-columns: repeat(3, 1fr); }
.vali { margin-bottom: 14px; }
.markeri-rida { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.markeri-rida input[type=checkbox] { width: 16px; height: 16px; margin: 0; border-radius: 3px; }
.markeri-rida label {
  margin: 0; font-weight: 400; color: var(--tekst); font-size: 13.5px;
  text-transform: none; letter-spacing: 0;
}
.abi { font-size: 11.5px; color: #9a9a9a; margin-top: 5px; line-height: 1.45; }
fieldset { border: 1px solid #e5e5e5; border-radius: 6px; padding: 16px; margin: 0 0 18px; }
legend {
  font-size: 11.5px; font-weight: 700; color: var(--hall-tekst);
  text-transform: uppercase; letter-spacing: .6px; padding: 0 7px;
}

/* otsinguplokk kahes veerus, nagu Erplys */
.otsiplokk { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 26px; margin-bottom: 8px; }
.otsiplokk .vali { margin: 0; }
.otsiplokk-jalus { display: flex; justify-content: flex-end; gap: 9px; margin: 14px 0 22px; }
@media (max-width: 1100px) { .otsiplokk { grid-template-columns: 1fr; } }

/* ==========================================================================
   Tabelid
   ========================================================================== */
.tabelikest { border: 1px solid #e8e8e8; border-radius: 5px; overflow: auto; max-height: 70vh; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 13px; background: #f7f7f7;
  border-bottom: 1px solid #e0e0e0; font-weight: 700; font-size: 11.5px;
  color: #6b6b6b; text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
tbody td { padding: 10px 13px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tbody tr:hover { background: #fbfbf5; }
tbody tr.klikitav { cursor: pointer; }
tfoot td { padding: 10px 13px; background: #f7f7f7; border-top: 1px solid #e0e0e0; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.kesk, th.kesk { text-align: center; }
.tyhi { padding: 54px 20px; text-align: center; color: #a8a8a8; }
.tyhi .suur { font-size: 34px; margin-bottom: 10px; opacity: .45; }

/* ==========================================================================
   Näidikud
   ========================================================================== */
.naidikud { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.naidik { background: #fff; border: 1px solid #e8e8e8; border-radius: 5px; padding: 15px 17px; }
.naidik .silt { font-size: 11px; color: var(--hall-tekst); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.naidik .vaartus { font-size: 26px; font-weight: 400; margin-top: 8px; letter-spacing: -.5px; }
.naidik .lisa { font-size: 12px; color: var(--hall-tekst); margin-top: 5px; }
.naidik.roheline .vaartus { color: var(--roheline); }
.naidik.punane .vaartus { color: var(--punane); }
.naidik.sinine .vaartus { color: var(--sinine); }

/* ==========================================================================
   Sildid
   ========================================================================== */
.silt-mark {
  display: inline-block; padding: 3px 9px; border-radius: 3px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; line-height: 1.5;
  text-transform: uppercase; letter-spacing: .3px;
}
.s-hall     { background: #eee; color: #666; }
.s-sinine   { background: var(--sinine-hele); color: var(--sinine-tume); }
.s-roheline { background: var(--roheline-hele); color: var(--roheline); }
.s-punane   { background: var(--punane-hele); color: var(--punane); }
.s-kollane  { background: var(--oranz-hele); color: var(--oranz); }
.s-lilla    { background: var(--lilla-hele); color: var(--lilla); }

/* ==========================================================================
   Modaal
   ========================================================================== */
.modaal-taust {
  position: fixed; inset: 0; background: rgba(35,47,62,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 34px 18px; overflow-y: auto; z-index: 300;
}
.modaal { background: #fff; border-radius: 6px; width: 100%; max-width: 940px;
          box-shadow: 0 18px 44px rgba(0,0,0,.28); margin: auto; }
.modaal.kitsas { max-width: 560px; }
.modaal.lai { max-width: 1160px; }
.modaal-pais {
  padding: 15px 20px; border-bottom: 1px solid #e8e8e8;
  display: flex; align-items: center; gap: 12px;
}
.modaal-pais h2 { margin: 0; font-size: 20px; font-weight: 400; }
.modaal-keha { padding: 20px; max-height: 74vh; overflow-y: auto; }
.modaal-jalus {
  padding: 13px 20px; border-top: 1px solid #e8e8e8; background: #fafafa;
  display: flex; gap: 9px; justify-content: flex-end; border-radius: 0 0 6px 6px;
}
.modaal-jalus .vasak { margin-right: auto; }

/* ==========================================================================
   Ridade redaktor
   ========================================================================== */
.read-tabel input, .read-tabel select {
  padding: 6px 10px; font-size: 13px; border-radius: 3px;
}
.read-tabel select { background-position: right 8px center; padding-right: 26px; }
.read-tabel td { padding: 5px 6px; }
.read-tabel .kitsas { width: 96px; }
.read-tabel .kitsam { width: 74px; }

/* ==========================================================================
   Teated
   ========================================================================== */
#teated { position: fixed; bottom: 22px; right: 22px; z-index: 400;
          display: flex; flex-direction: column; gap: 9px; max-width: 430px; }
.teade {
  background: var(--tume); color: #fff; padding: 13px 16px; border-radius: 4px;
  font-size: 13.5px; box-shadow: 0 8px 22px rgba(0,0,0,.26);
  animation: sisse .18s ease-out; line-height: 1.45;
}
.teade.ok { background: var(--roheline); }
.teade.viga { background: var(--punane); }
.teade.hoiatus { background: var(--oranz); }
@keyframes sisse { from { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   Muu
   ========================================================================== */
.laadimine { padding: 46px; text-align: center; color: #a8a8a8; }
.spinner {
  width: 24px; height: 24px; border: 3px solid #e4e4e4;
  border-top-color: var(--sinine); border-radius: 50%;
  animation: pyorle .7s linear infinite; margin: 0 auto 13px;
}
@keyframes pyorle { to { transform: rotate(360deg); } }
.riba { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.hall { color: var(--hall-tekst); }
.nork { color: #b0b0b0; }
.vaike-tekst { font-size: 12px; }
.paks { font-weight: 700; }
.pdf-raam { width: 100%; height: 66vh; border: 1px solid #e5e5e5; border-radius: 4px; }
.edenemisriba { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.edenemisriba i { display: block; height: 100%; background: var(--sinine); transition: width .3s; }

.diagramm { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 10px; }
.diagramm .veerg { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
                   align-items: center; gap: 4px; height: 100%; }
.diagramm .tulp { width: 100%; display: flex; gap: 2px; align-items: flex-end; height: 100%; }
.diagramm .tulp span { flex: 1; border-radius: 2px 2px 0 0; min-height: 2px; }
.diagramm .myyk { background: var(--sinine); }
.diagramm .ost { background: #a9cde4; }
.diagramm .nimi { font-size: 10.5px; color: #a0a0a0; white-space: nowrap; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--hall-tekst); margin-top: 11px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.jaotus { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.kaart { background: #fff; border: 1px solid #e8e8e8; border-radius: 5px; margin-bottom: 20px; }
.kaart-pais { padding: 13px 16px; border-bottom: 1px solid #eee; display: flex;
              align-items: center; gap: 10px; flex-wrap: wrap; }
.kaart-pais h2 { margin: 0; font-size: 15px; font-weight: 700; }
.kaart-pais .parem { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.kaart-keha { padding: 16px; }
.kaart-keha.tihe { padding: 0; }

.tootepilt { width: 46px; height: 46px; object-fit: contain; border: 1px solid #eee;
             border-radius: 4px; background: #fafafa; }

@media (max-width: 1080px) { .jaotus { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .filtripaneel { display: none; }
  .peamenyy button { padding: 17px 10px; font-size: 13.5px; }
  .sisuala { padding: 16px 14px 50px; }
  .valjad, .valjad.kaks, .valjad.kolm { grid-template-columns: 1fr; }
}


/* ---------- Moodulivahetaja (VIVIN platvorm) ---------- */
.moodulinupp {
  background: none; border: 1px solid #46566a; color: #cdd4dd;
  font-size: 13px; padding: 6px 12px; border-radius: 3px; margin-right: 8px;
}
.moodulinupp:hover { background: var(--tume-hover); color: #fff; border-color: #6b7684; }
.moodulid-ripp {
  position: absolute; top: 50px; right: 96px; background: #fff;
  border: 1px solid var(--hall-aare); border-radius: 4px; min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 200; overflow: hidden;
}
.moodulid-ripp .pais {
  padding: 9px 14px; background: #fafafa; border-bottom: 1px solid #eee;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--hall-tekst); font-weight: 700;
}
.moodulid-ripp a, .moodulid-ripp button {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  background: none; border: 0; font-family: inherit; font-size: 13.5px;
  cursor: pointer; color: var(--tekst); text-decoration: none;
}
.moodulid-ripp a:hover, .moodulid-ripp button:hover { background: #f3f4f6; }
.moodulid-ripp .praegune { background: var(--sinine-hele); font-weight: 600; }


/* ---------- Hulgivalik tabelites ---------- */
.valikuriba {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 10px 14px;
  background: var(--sinine); color: #fff; border-radius: 6px;
}
.valikuriba .arv { font-weight: 700; margin-right: auto; }
.valikuriba button { padding: 5px 12px; font-size: 13px; }
tr.valitud > td { background: #eaf2fb !important; }
td.valikulahter, th.valikulahter { width: 34px; text-align: center; padding-right: 0; }
.valikulahter input { width: 16px; height: 16px; cursor: pointer; }
