/* =========================================================
   smallscreen_base.css  (<= 900px)
   Eesmärk: kompaktne, selge mobiilivaade
   ========================================================= */

html {
  color-scheme: light;
  --color-page: #f6f7f8;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f5f5;
  --color-surface-strong: #d5d6d5;
  --color-text: #515151;
  --color-text-muted: #727272;
  --color-heading: #515151;
  --color-border: #d9d9d9;
  --color-border-soft: #efefef;
  --color-brand: #cc0000;
  --color-brand-hover: #a80000;
  --color-nav: #181818;
  --color-nav-text: #ffffff;
  --color-sidebar: #4c5055;
  --color-accent: #aedaa6;
  --color-shadow: rgba(0,0,0,0.16);
  --color-shadow-strong: rgba(0,0,0,0.22);
  --color-success-bg: #d4edda;
  --color-success-text: #155724;
  --color-error-bg: #f8d7da;
  --color-error-text: #721c24;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-page: #121416;
  --color-surface: #1b1f23;
  --color-surface-muted: #242a30;
  --color-surface-strong: #323941;
  --color-text: #e8edf2;
  --color-text-muted: #b8c0c8;
  --color-heading: #f4f7fa;
  --color-border: #3b444d;
  --color-border-soft: #2f363d;
  --color-brand: #d71920;
  --color-brand-hover: #ff3b42;
  --color-nav: #0f1113;
  --color-nav-text: #f6f7f8;
  --color-sidebar: #242a30;
  --color-accent: #9bd18f;
  --color-shadow: rgba(0,0,0,0.45);
  --color-shadow-strong: rgba(0,0,0,0.65);
  --color-success-bg: #153a25;
  --color-success-text: #b8f1c8;
  --color-error-bg: #471b22;
  --color-error-text: #ffc2ca;
}

/* ========== 1) BASE RESET / GLOBAL ========== */
body {
  font-family: Arial, Helvetica, sans-serif; /* mandatory */
  font-size: small;
  margin: 0;
  background: var(--color-page);
  color: var(--color-text);
}

.hidden { display: none; }
.error { color: red; }

.field-error input,
.field-error select,
.field-error textarea {
  border: 1px solid red;
  color: red;
}

/* Buttons (kasutad nii headeris, vormides kui admin linkidel) */
a.btn {
  display: inline-block;
  text-align: center;
  padding: 2% 2%;
  text-transform: uppercase;
  font-weight: 400;
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-text);
  font-family: inherit;
  transition: all 0.3s ease;
  margin-right: 5px;
  text-decoration: none;
}

a.btn:hover {
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  cursor: pointer;
}

/* ========== 2) WARNING TEXT ========== */
#yellow-warning-text,
.yellow-warning-text,
#green-warning-text,
.green-warning-text,
#red-warning-text,
.red-warning-text,
#blue-warning-text,
.blue-warning-text {
  padding: 5px;
  margin-top: 10px;
  text-align: center;
  vertical-align: middle;
  font-weight: bold;
  color: #313131;
  text-transform: uppercase;
  font-size: 12px;
  text-decoration: none;
}

#yellow-warning-text,
.yellow-warning-text {
  background: #ffdc00;
}

#green-warning-text,
.green-warning-text {
  background: #30cc71;
}

#red-warning-text,
.red-warning-text {
  background: red;
}

#blue-warning-text,
.blue-warning-text {
  background: rgba(110, 196, 230, 0.719);
}

.warning-fullwidth{
  flex: 0 0 98%;      /* ⬅️ võtab TERVE rea */
  width: 98%;        /* kindluse mõttes */
  box-sizing: border-box;

  margin: 6px 10px 0 10px;
  padding: 2px 14px;

  border-radius: 4px;
  text-align: center;
}

/* ========== 3) HEADER / NAV ========== */
#header-logo {
  padding: 10px 0px 5px 0px; /* mandatory */
  text-align: center;        /* mandatory */
  background: var(--color-brand);
  color: black;
  min-height: 20px;
}

#hide_logo2 { display: none; }

.flex-row {
  display: flex;
  flex-direction: row;
}

#header-navbar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  background-color: var(--color-nav);
  transition: all 0.3s;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

#header-navbar .flex-row {
  align-items: center;
}

#header-navbar .app-navigation {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

#header-navbar .app-navigation::-webkit-scrollbar { display: none; }
#header-navbar .app-navigation a { flex: 0 0 auto; white-space: nowrap; }
#header-navbar .mobile-nav-actions { order: -1; flex: 0 0 auto; background: var(--color-nav); box-shadow: 8px 0 12px var(--color-nav); }

#header-navbar a {
  color: var(--color-nav-text);
  padding: 10px 16px;
  text-decoration: none;
  text-align: center;
}

#header-navbar a:hover {
  background-color: var(--color-surface-strong);
  color: var(--color-heading);
}

#header-navbar .app-navigation a.is-active {
  background: var(--color-surface-strong);
  color: var(--color-heading);
  box-shadow: inset 0 -3px 0 var(--color-brand);
}

/* hamburger mobiilis nähtav */
#hamburger-button{
  display: inline-block;
  color: var(--color-nav-text);
  padding: 10px 14px;
  text-decoration: none;
  font-size: 22px;
}

.theme-toggle-header { display: none !important; }

.language-switcher {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0 3px 0 0;
  padding: 2px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 6px;
  background: rgba(255,255,255,.06);
}

.language-switcher button {
  width: 29px;
  min-height: 30px;
  padding: 3px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-nav-text);
  font: inherit;
  font-size: 10px;
  font-weight: 800;
}

.language-switcher button.is-active {
  background: var(--color-surface);
  color: var(--color-heading);
}

body.mobile-drawer-open { overflow: hidden; }

.mobile-drawer-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(0, 0, 0, .58);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}

.mobile-drawer-backdrop.is-open { opacity: 1; visibility: visible; }

.mobile-drawer {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1100;
  flex-direction: column;
  width: min(88vw, 390px);
  overflow-y: auto;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 12px 0 35px rgba(0, 0, 0, .32);
  transform: translateX(-105%);
  transition: transform .22s ease;
}

.mobile-drawer.is-open { transform: translateX(0); }
.mobile-drawer-header { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 10px 16px; background: var(--color-nav); color: var(--color-nav-text); }
.mobile-drawer-header strong { font-size: 17px; }
.mobile-drawer-header button { width: 38px; height: 38px; padding: 0; border: 0; background: transparent; color: inherit; font-size: 28px; cursor: pointer; }
.mobile-drawer-section { padding: 16px; border-bottom: 1px solid var(--color-border-soft); }
.mobile-drawer-section h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.mobile-drawer-section > a,
.mobile-drawer-theme { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; min-height: 44px; padding: 10px 8px; border: 0; border-top: 1px solid var(--color-border-soft); background: transparent; color: var(--color-text) !important; text-decoration: none; text-align: left; }
.mobile-drawer-user { padding: 8px 8px 12px; }
.mobile-drawer-theme { margin: 0; font: inherit; cursor: pointer; }
.mobile-no-filters { margin: 0; color: var(--color-text-muted); }
#mobile-page-filters-slot:not(:empty) + .mobile-no-filters { display: none; }

/* Mobiilis peidame parempoolse kasutaja dropdowni nupu + dropdowni */
a.btn.username-btn,
#user-dropdown{
  display: none !important;
}

/* ...AGA vasakus menüüs lubame username real nähtav olla */
#left-sidebar a.btn.username-btn.sidebar-username{
  display: inline-flex !important;
}

/* ========== 4) SIDEBAR (hamburger menüü) ========== */
#left-sidebar {
  background-color: var(--color-sidebar); /* mandatory */
  display: none;             /* JS toggle */
  text-align: center;
}

/* üldlink sidebaris */
#left-sidebar a {
  color: white;
  padding: 12px 16px;
  text-decoration: none;
  font-size: 15px;     /* mobiilis mõistlik */
  display: block;
  border-top: 1px solid #D5D6D5;
}

#left-sidebar label {
  color: white;
  font-size: 15px;
}

#left-sidebar a:hover {
  background-color: #D5D6D5;
  color: black;
  font-weight: bold;
}

#selected a { font-weight: bold; }

/* Sektsioonide struktuur */
#left-sidebar .menu-section { padding: 0; }

/* Sektsiooni pealkiri (Kasutaja / Otsingud) */
#left-sidebar .menu-section-title{
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 16px;
  margin: 0;

  font-weight: 800;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.6px;

  color: white;
  background: rgba(0, 0, 0, 0.18);
  border-top: 1px solid rgba(255,255,255,0.18);
  border-bottom: 1px solid rgba(255,255,255,0.18);
}

#left-sidebar .menu-section-title i{
  width: 18px;
  text-align: center;
}

/* Kasutaja sektsioon: õrn eristus */
#left-sidebar .user-section{
  background: rgba(204, 0, 0, 0.10);
  border-bottom: 1px solid rgba(255,255,255,0.18);
}

/* Ikoonide joondus sidebar linkidel */
#left-sidebar a i{
  width: 18px;
  margin-right: 10px;
  text-align: center;
}

/* Sidebaris username rida (informatiivne) */
#left-sidebar a.sidebar-username{
  margin: 8px 12px 10px 12px;
  width: auto;
  max-width: calc(100% - 24px);

  border-color: rgba(255,255,255,0.35);
  color: white;
}

#left-sidebar a.sidebar-username:hover{
  background-color: rgba(255,255,255,0.08);
  color: white;
}

/* username nupu sees olev tekst ellipsiseks */
#left-sidebar a.sidebar-username .username-text{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== 5) MAIN / LAYOUT ========== */
#main {
  background-color: var(--color-surface);
  padding: 10px;
  margin: 0 auto;
  overflow-x: auto;
}

#sidebar-toggle-container { display: none; } /* desktop feature off */

#main-content-area {
  flex: 1; /* this allows it to take the remaining space */
}

#main-content-area canvas {
  width: 100% !important;
  height: auto !important;
}

.chart-container {
  min-height: 300px;
  margin-bottom: 30px;
}

/* ========== 6) SPINNER ========== */
.spinner {
  margin: 0 auto;
  width: 40px;
  height: 40px;
  border: 5px solid #ccc;
  border-top: 5px solid #CC0000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========== 7) FOOTER ========== */
.footer {
  padding: 10px;
  text-align: center;
  background: #181818;
  margin: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.16), 0 2px 10px rgba(0,0,0,0.12);
  transition: all 0.3s;
}

.footer:hover {
  box-shadow: 0 8px 17px rgba(0,0,0,0.2), 0 6px 20px rgba(0,0,0,0.19);
}

.footer .row {
  width: 100%;
  margin: 1% 0;
  padding: 0.6% 0;
  color: gray;
  font-size: 0.8em;
}

.footer .row a {
  text-decoration: none;
  color: gray;
  transition: 0.5s;
}

.footer .row a:hover { color: #fff; }

.footer .row a i {
  font-size: 2em;
  margin: 0 1%;
}

/* ========== 8) PAGINATION ========== */
.pagination {
  text-align: center;
  padding: 10px;
  margin-top: 20px;
  font-size: 14px;
}

.pagination a {
  margin: 0 5px;
  padding: 5px 10px;
  border: 1px solid #d9d9d9;
  text-decoration: none;
  color: #515151;
  transition: all 0.3s ease;
}

.pagination a:hover {
  border: 1px solid #aedaa6;
  color: #aedaa6;
}

.pagination .page-current {
  font-weight: bold;
  margin: 0 10px;
}

/* ========== 9) ROUND BUTTON (admin add) ========== */
.round-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background-color: red;
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-size: 28px;
  text-decoration: none;
  z-index: 1000;
  transition: background-color 0.3s ease;
}

.round-button:hover { background-color: #CC0000; }

/* ========== 10) KASUTUSJUHEND ICON LINK ========== */
.kasutusjuhend-container { margin-left: auto; }

.kasutusjuhend-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.kasutusjuhend-text {
  font-size: 12px;
  color: #727272;
  font-weight: bold;
}

.pdf-icon { color: #d32f2f; font-size: 20px; }
.puudub-icon { color: #727272; font-size: 20px; }

/* ========== 11) CARDS (mobiilis kitsam) ========== */
.card {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  margin: 14px auto;
  width: 96%;
  background: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.10), 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.3s;
}

.card:hover {
  box-shadow: 0 8px 17px rgba(0,0,0,0.12), 0 6px 20px rgba(0,0,0,0.10);
}

.card nav {
  display: flex;
  align-items: center;
  width: 100%;
  color: #727272;
  text-transform: uppercase;
  padding: 14px 0 8px 4px;
  border-bottom: 2px solid #efefef;
  font-size: 12px;
}

/* "Tagasi seadmete nimekirja" link vasakule */
.card nav a.header{
  flex: 1;
  min-width: 0;
}

/* Südamed paremale */
.card nav > a:not(.header){
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.card nav a { text-decoration: none; color: #727272; }

.card .photo {
  padding: 16px;
  width: 100%;
  text-align: center;
}

.card .photo img {
  height: auto;
  max-width: 100%;
  max-height: 300px;
}

.card .description {
  padding: 10px 14px 14px 14px;
  width: 100%;
  border-left: 2px solid #efefef;
}

.card .whole_width {
  width: 100%;
  box-sizing: border-box;
  border-top: 2px solid #efefef;
}

.card .description h2,
.card .description h3,
.card .description h4,
.card .description h5,
.card .description p { margin: 0; }

.card .description h2 {
  color: #515151;
  text-transform: uppercase;
  font-weight: 500;
  font-size: 18px;
}

.card .description h3 {
  color: #515151;
  font-size: 15px;
  font-weight: 300;
  padding-top: 6px;
}

.card .description p {
  font-size: 12px;
  line-height: 18px;
  color: #727272;
  padding: 12px 0;
}

/* ========== 12) SEADMETE LIST (mobiilis kompaktne) ========== */
/* Eesmärk: pilt vasakul, info paremal, lisainfo all, väga kompaktne */

.list-row{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;            /* header + bottom lähevad alla */
  align-items: flex-start;

  width: 96%;
  margin: 8px auto;
  background: white;
  box-shadow: none;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 8px;
  overflow: hidden;
}

/* header täislaiuses */
.list-row .header{
  width: 100%;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.03);
  box-sizing: border-box;
}

/* pealkiri kompaktseks */
.list-row .header a{
  padding: 0;
  margin: 0;
  font-size: 14px;
  line-height: 18px;
  color: #515151;
  text-decoration: none;
}

/* südamed väiksemaks */
.heart{
  height: 18px;
  width: 18px;
  float: none;
  margin: 00;
  vertical-align: middle;
  cursor: pointer;
}

/* pilt vasakule (fix) */
.list-row .picture{
  flex: 0 0 92px;
  width: 92px;
  min-width: 92px;

  margin: 0;
  text-align: left;
  float: none;
  box-sizing: border-box;
}

.list-row .picture img{
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 4px;
  margin: 0;
  max-width: none;
  max-height: none;
}

/* joonda pilt ja tekst samale algusjoonele */
.list-row .picture{ padding: 8px 8px 0 10px;}
.list-row .left{ padding-top: 0; }


.list-row .left{
  box-sizing: border-box;
}

.list-row .content{
  display: contents;
}

/* eemalda mullid ja tee üheks veeruks */
.list-row .flex-container{ display: block; }

.list-row .left,
.list-row .right{
  background: transparent;
  box-shadow: none;
  margin: 0;
  padding: 0;
}

/* väga kompaktne: peida parempoolne info plokk */
.list-row .right{ display: none; }

.list-row{
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}

/* pilt vasakul */
.list-row .picture{
  flex: 0 0 72px;
  padding: 8px 8px 0 10px;
  box-sizing: border-box;
}

/* vasak info pildi kõrval */
.list-row .left{
  flex: 1;
  min-width: 0;
  padding: 8px 8px 0px 2px;
  box-sizing: border-box;
  font-size: 12px;
}


/* lisainfo alla täislaiuses */
.list-row .bottom{
  flex: 0 0 100%;
  width: 100%;

  padding: 0px 10px 8px 10px;
  margin-top: 0;
  border-top: 1px solid rgba(0,0,0,0.08);

  display: flex;
  align-items: center;
}
.list-row .bottom > div:first-child{
  flex: 1;
}
.list-row .bottom > div:last-child{
  margin-left: auto;
}


/* Lisainfo tekst max 2 rida */
.list-row .bottom a{
  font-size: 12px;
  line-height: 12px;

  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}



/* Seadmete listi info tekst – tagasi halliks */
.list-row .left a,
.list-row .bottom a{
  color: #6f6f6f;
}

/* admin "Muuda" nupp väikseks */
.list-row .bottom .btn{
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
  margin-right: 0;
}

/* ========== 13) TABLE (mobiilis) ========== */
#tööde-tabel {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  line-height: 18px;
  color: #727272;
}

#tööde-tabel td,
#tööde-tabel th {
  border: 1px solid #ddd;
  padding: 6px;
}

#tööde-tabel tr:nth-child(even) { background-color: #f2f2f2; }
#tööde-tabel tr:hover { background-color: #ddd; }

#tööde-tabel th {
  text-align: center;
  background-color: #181818;
  color: white;
  text-transform: uppercase;
  font-weight: 700;
}

#tööde-tabel a {
  text-decoration: none;
  color: #515151;
  transition: 0.5s;
}

#tööde-tabel button,
#tööde-tabel #button {
  font-size: 13px;
  outline: 0;
  border: 1px solid #d9d9d9;
  background: none;
  padding: 4px;
  color: #515151;
  text-transform: uppercase;
  width: 75px;
  font-family: inherit;
  transition: all 0.3s ease;
  font-weight: 500;
  text-align: center;
}

#tööde-tabel button:hover,
#tööde-tabel #button:hover {
  border: 1px solid #aedaa6;
  color: #aedaa6;
  cursor: pointer;
}


/* Header: nimi vasakul, südamed paremal */
.list-row .header{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

/* Nimi: võib võtta kogu ülejäänud ruumi */
.list-row .header > a:first-child{
  flex: 1;
  min-width: 0;
}

/* Südamed: lükka paremale */
.list-row .header > a:nth-child(2){
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0;     /* et ei lisaks suurt paddingut */
}

/* Südame ikoonid ühte ritta */
.list-row .header .heart{
  width: 18px;
  height: 18px;
  margin: 0;
  vertical-align: middle;
}



/* 6) Lisainfo alati 100% ja pildi alla */
.list-row .bottom{
  flex: 0 0 100%;
  width: 100%;

  padding: 6px 10px 8px 10px;
  margin-top: 4px;
  border-top: 1px solid rgba(0,0,0,0.08);
  box-sizing: border-box;

  display: flex;              /* et “Muuda” saaks paremale */
  align-items: center;
  gap: 10px;
}

/* Lisainfo tekst võtab ruumi, nupp lükatakse paremale */
.list-row .bottom > div:first-child{
  flex: 1;
  min-width: 0;
}

/* Muuda nupp paremale (sinu inline-style margin-left:auto toimib ka, see on lisakaitse) */
.list-row .bottom > div:last-child{
  margin-left: auto;
}



.card nav svg.arrow {
  float: left;
  height: 15px;
  width: 15px;
  margin-right: 0;
}

.card nav a.header{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1;
}

.card nav svg.arrow{
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}


/* =========================================================
   FORMS – mobile-friendly + matches base.css look
   ========================================================= */

/* Üldine vormi “typography” ja spacing */
form{
  color: #515151;
}

label{
  display: block;
  margin: 10px 0 6px;
  font-weight: 600;
  font-size: 14px;
  color: #515151;
}

/* Kõik sisendid ühtseks */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="url"],
select,
textarea{
  width: 100%;
  box-sizing: border-box;

  font-family: inherit;
  font-size: 16px;            /* iOS zoom fix */
  line-height: 1.2;

  padding: 10px 12px;
  min-height: 44px;           /* thumb-friendly */
  border-radius: 4px;

  border: 1px solid #d9d9d9;
  background: #fff;
  color: #515151;

  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}


/* Textarea käitumine */
textarea{
  min-height: 110px;
  resize: vertical;
}

/* Focus sama “aedaa6” loogikaga */
input:focus,
select:focus,
textarea:focus{
  border-color: #aedaa6;
  box-shadow: 0 0 0 3px rgba(174, 218, 166, 0.35);
}

/* Placeholder natuke pehmem */
::placeholder{
  color: rgba(81, 81, 81, 0.55);
}

/* Checkbox / radio – jäta normaalseks, aga joonda */
input[type="checkbox"],
input[type="radio"]{
  transform: scale(1.15);
  margin-right: 8px;
}

/* Formi read/vahed (nt sinu .filter-form) */
.filter-form,
.form,
.default-form,
form .form-row{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Kui sul on forms sees <p> wrapperid (Django default) */
form p{
  margin: 0 0 10px;
}

/* Django helptext */
.helptext{
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #727272;
}

/* Veateated ja errorlist */
.errorlist{
  list-style: none;
  padding: 0;
  margin: 6px 0 10px;
  color: #b00020;
  font-size: 13px;
}

/* Sinu olemasolev .field-error jääb tööle, aga teeme veel selgemaks */
.field-error input,
.field-error select,
.field-error textarea{
  border-color: #b00020;
  box-shadow: 0 0 0 3px rgba(176, 0, 32, 0.15);
}

/* Nupud: ühtlusta base.css “btn” tunnetusega, mobiilis veidi suurem */
button,
input[type="submit"],
input[type="button"],
a.btn{
  min-height: 10px;
  border-radius: 2px;
}

/* Kui sul on <button class="btn ...">, siis see ühtlustab */
button.btn,
input.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 10px 14px;
  border: 1px solid #d9d9d9;
  background: none;
  color: #515151;
  font-family: inherit;
  text-transform: uppercase;
  font-weight: 500;
  transition: all .2s ease;
}

/* Hover/active sama mis base.css */
button.btn:hover,
input.btn:hover,
input[type="submit"]:hover,
button:hover{
  border-color: #aedaa6;
  color: #aedaa6;
  cursor: pointer;
}

/* Väiksed selecti nooled jms – parem “native” tunne */
select{
  appearance: auto;
}

/* Kui form on kaardi sees ja tundub “kitsas”, siis korrigeeri */
#main form{
  max-width: 100%;
}

/* =========================================================
   FORCE UNIFIED BUTTON STYLE (desktop + mobile)
   ========================================================= */

button,
input[type="submit"],
input[type="button"],
.btn,
.btn-outline-primary,
.btn-primary{
  background: none !important;
  color: #515151 !important;
  border: 1px solid #d9d9d9 !important;

  font-family: inherit;
  font-weight: 500;
  text-transform: uppercase;

  border-radius: 6px;
  padding: 8px 14px;
  min-height: 40px;

  box-shadow: none !important;
}


/* Hover – sama roheline nagu mujal */
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
.btn:hover,
.btn-outline-primary:hover,
.btn-primary:hover{
  border-color: #aedaa6 !important;
  color: #aedaa6 !important;
  background: none !important;
  cursor: pointer;
}

.filter-btn {
  color: #fff !important;
  border-color: #fff;
}

/* Focus – viisakas, mitte sinine */
button:focus,
input:focus,
.btn:focus{
  outline: none;
  box-shadow: 0 0 0 3px rgba(174, 218, 166, 0.35) !important;
}

/* Date/Time kipuvad overflowima – tee neile eraldi fix */
input[type="date"],
input[type="time"]{
  display: block;
  max-width: 92%;
  min-width: 0;
  box-sizing: border-box;
}


/* ===== FIX Chart.js canvas sizing on mobile ===== */
/* Ära lase globaalne "height:auto" Chart.js-i lõhkuda */
#main-content-area .card_chart canvas{
  height: 260px !important;   /* vali 240–360px, mis sulle sobib */
  width: 100% !important;
  display: block;
}

/* Ja containerile kindel raam */
#main-content-area .card_chart{
  width: 96% !important;
  max-width: 100% !important;
  box-sizing: border-box;
  overflow: hidden;
}

#tööde-tabel .col-aeg {
  min-width: 60px;
  white-space: nowrap;
}

#tööde-tabel .col-info {
  min-width: 150px;
  white-space: nowrap;
}

#tööde-tabel .col-hinnang {
  min-width: 80px;
  white-space: nowrap;
}

.user-menu-wrapper {
  position: relative;
  display: inline-block;
  margin-right: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 42px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-nav-text);
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover,
.theme-toggle:focus {
  border-color: var(--color-accent);
  color: var(--color-accent);
  outline: none;
}

.theme-toggle-header {
  margin-right: 5px;
}

#left-sidebar .theme-toggle-sidebar {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(255,255,255,0.18);
  color: var(--color-nav-text);
  justify-content: center;
  text-transform: none;
}

#user-dropdown a.dropdown-link {
  width: auto;
  margin: 0;
  text-align: left;
}

/* Theme-aware component layer */
.card,
.card_chart,
.list-row,
#main,
.login-container,
.chart-custom-legend button {
  background: var(--color-surface);
  color: var(--color-text);
}

.list-row .left,
.list-row .right,
.list-row .bottom {
  background-color: var(--color-surface-muted);
}

.card,
.card_chart,
.list-row {
  box-shadow: 0 2px 5px var(--color-shadow), 0 2px 10px rgba(0,0,0,0.08);
}

.card:hover,
.card_chart:hover,
.list-row:hover {
  box-shadow: 0 8px 17px var(--color-shadow-strong), 0 6px 20px rgba(0,0,0,0.10);
}

.card nav,
.list-row .header,
.list-row .bottom {
  color: var(--color-text-muted);
  border-color: var(--color-border-soft);
}

.list-row .header {
  background: var(--color-surface-muted);
}

.card nav a,
.list-row .header a,
.list-row .content a,
.list-row .left a,
.list-row .bottom a,
.card .description p,
.card .description h4,
.card .description h5,
.kasutusjuhend-text,
.puudub-icon,
.rating-star.empty,
.pagination a,
#tööde-tabel,
#tööde-tabel a,
.helptext {
  color: var(--color-text-muted);
}

.list-row .content h3,
.card .description h2,
.card .description h3,
form,
label,
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-heading);
}

.card .description,
.card .whole_width {
  border-color: var(--color-border-soft);
}

#tööde-tabel td,
#tööde-tabel th,
.pagination a,
#tööde-tabel button,
#tööde-tabel #button,
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  border-color: var(--color-border);
}

#tööde-tabel th {
  background-color: var(--color-nav);
  color: var(--color-nav-text);
}

#tööde-tabel tr:nth-child(even) {
  background-color: var(--color-surface-muted);
}

#tööde-tabel tr:hover {
  background-color: var(--color-surface-strong);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  background: var(--color-surface);
  color: var(--color-text);
}

button,
input[type="submit"],
input[type="button"],
.btn,
.btn-outline-primary,
.btn-primary {
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

#user-dropdown {
  background-color: var(--color-surface-muted);
  border-color: var(--color-border);
}

.messages li.success {
  background-color: var(--color-success-bg);
  color: var(--color-success-text);
}

.messages li.error {
  background-color: var(--color-error-bg);
  color: var(--color-error-text);
}

html[data-theme="dark"] .heart[stroke="#727272"],
html[data-theme="dark"] svg.arrow polygon,
html[data-theme="dark"] polygon[stroke="#727272"] {
  stroke: var(--color-text-muted);
}

html[data-theme="dark"] polygon[fill="#727272"] {
  fill: var(--color-text-muted);
}

.dashboard-filter-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

.dashboard-filter-form label {
  font-weight: bold;
}

.dashboard-filter-form input,
.dashboard-filter-form select {
  padding: 5px;
  font-size: 16px;
}

.filter-btn {
  padding: 10px;
  border: 0;
  font-weight: bold;
}

.filter-btn-primary {
  margin-top: 10px;
  background-color: var(--color-brand);
  color: white !important;
}

.filter-btn-secondary {
  background-color: var(--color-surface-strong);
  color: var(--color-heading) !important;
}

.loading-indicator {
  display: none;
  text-align: center;
  margin: 20px;
}

.theme-toggle,
.theme-toggle-header {
  color: var(--color-nav-text) !important;
}

.theme-toggle:hover,
.theme-toggle:focus {
  color: var(--color-accent) !important;
}

#left-sidebar .theme-toggle-sidebar {
  border: 0 !important;
  border-top: 1px solid rgba(255,255,255,0.18) !important;
  color: var(--color-nav-text) !important;
}

.table-actions {
  text-align: right;
  margin-bottom: 10px;
}

.excel-export-icon {
  color: #2f9e41;
}

.excel-export-icon:hover {
  color: #37b24d;
}

.work-info-link {
  color: var(--color-text);
  font-weight: 600;
  text-decoration: none;
}

.work-info-link:hover {
  color: var(--color-brand);
  text-decoration: underline;
}

.work-edit-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.work-edit-title {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.work-edit-device-link {
  display: block;
  color: var(--color-heading);
  text-decoration: none;
}

.work-edit-device-link h2,
.work-edit-device-link h3 {
  margin-top: 0;
}

.work-edit-device-link:hover h2,
.work-edit-device-link:hover h3 {
  color: var(--color-brand-hover);
  text-decoration: underline;
}

.work-status-pill {
  align-self: flex-start;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  color: var(--color-heading);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.work-status-pill.status-o { border-color: #eed58c; background: #fff1c7; color: #785700; }
.work-status-pill.status-t { border-color: #b8d7f8; background: #dcecff; color: #164d87; }
.work-status-pill.status-k { border-color: #b8dcbf; background: #dcefdc; color: #205f2d; }

.work-meta-grid,
.form-grid,
.form-grid-costs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.work-meta-grid div {
  padding: 10px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface-muted);
  border-radius: 4px;
}

.work-meta-grid h4,
.work-meta-grid p {
  margin: 0;
}

.work-meta-grid p {
  padding: 6px 0 0 0;
}

.work-edit-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-section {
  padding: 12px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface);
  border-radius: 4px;
}

.form-section h3 {
  margin: 0 0 12px 0;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.work-edit-form input,
.work-edit-form select,
.work-edit-form textarea {
  width: 100%;
  box-sizing: border-box;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary-action,
.btn-danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 4px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary-action,
.btn-complete-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 4px;
  font: inherit;
  font-weight: 700;
}
.btn-secondary-action { border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-heading); }
.btn-complete-action { border: 1px solid #25813a; background: #25813a; color: #fff; }
.invoice-completion-section.is-actionable { border-color: #d6a700; box-shadow: inset 4px 0 0 #d6a700; }
.invoice-section-heading { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.invoice-section-heading h3, .invoice-section-heading p { margin: 0; }
.invoice-section-heading p { padding-top: 5px; color: var(--color-text-muted); }
.invoice-total { align-self: flex-start; padding: 8px 10px; border-radius: 4px; background: var(--color-surface-muted); }
.invoice-quick-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.currency-input { position: relative; }
.currency-input input { padding-right: 30px; }
.currency-input span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); }
.existing-costs { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.existing-costs > span { padding: 7px 9px; border: 1px solid var(--color-border-soft); border-radius: 4px; background: var(--color-surface-muted); }
.cost-breakdown { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--color-border-soft); }
.cost-breakdown summary { font-weight: 700; cursor: pointer; }
.work-history-section { border-top: 1px solid var(--color-border-soft); }
.work-history-heading h3, .work-history-heading p { margin: 0; }
.work-history-heading p { padding-top: 5px; color: var(--color-text-muted); }
.work-history { margin: 18px 0 0 7px; padding-left: 21px; border-left: 2px solid var(--color-border); list-style: none; }
.work-history > li { position: relative; padding: 0 0 20px 7px; }
.work-history-dot { position: absolute; left: -30px; top: 3px; width: 15px; height: 15px; border: 3px solid var(--color-surface); border-radius: 50%; background: var(--color-text-muted); }
.work-history-dot.action-completed { background: #25813a; }
.work-history-dot.action-ordered { background: #2878bd; }
.work-history-dot.action-created { background: var(--color-brand); }
.work-history-meta { display: flex; flex-direction: column; gap: 3px; }
.work-history-meta time, .work-history-user { color: var(--color-text-muted); font-size: 12px; }
.work-history-changes { margin: 8px 0 0; }
.work-history-changes > div { padding: 5px 0; border-top: 1px solid var(--color-border-soft); }
.work-history-changes dt { font-weight: 700; }
.work-history-changes dd { margin: 3px 0 0; overflow-wrap: anywhere; }

.btn-primary-action {
  border: 1px solid var(--color-brand) !important;
  background: var(--color-brand) !important;
  color: white !important;
}

.btn-danger-action {
  border: 1px solid #b00020 !important;
  background: transparent !important;
  color: #ff8a9a !important;
}

.btn-danger-action:hover {
  background: #b00020 !important;
  color: white !important;
}

html[data-theme="dark"] .btn-secondary-action {
  border-color: #7e8a95 !important;
  background: #323941 !important;
  color: #fff !important;
}

html[data-theme="dark"] .btn-secondary-action:hover {
  border-color: #aab4bd !important;
  background: #414a54 !important;
}

html[data-theme="dark"] .btn-danger-action {
  border-color: #ff6b7a !important;
  background: #4d1820 !important;
  color: #ffd8dd !important;
}

html[data-theme="dark"] .btn-danger-action:hover {
  border-color: #ff8a96 !important;
  background: #a51d32 !important;
  color: #fff !important;
}

.works-table {
  border-collapse: separate;
  border-spacing: 0 12px;
}

.works-table thead {
  display: none;
}

.works-table,
.works-table tbody,
.works-table tr,
.works-table td {
  display: block;
  width: 100%;
}

.works-table tr {
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  box-shadow: 0 2px 8px var(--color-shadow);
}

#tööde-tabel.works-table tr:nth-child(even),
#tööde-tabel.works-table tr:hover {
  background: var(--color-surface);
}

.works-table tr.form-error {
  border-color: #b00020;
}

.works-table td,
#tööde-tabel.works-table td {
  display: grid;
  grid-template-columns: minmax(86px, 34%) minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  box-sizing: border-box;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--color-border-soft);
  text-align: left;
  font-size: 13px;
  line-height: 1.35;
}

.works-table td:last-child {
  border-bottom: 0;
}

.works-table td[data-label]::before {
  content: attr(data-label);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
  text-transform: uppercase;
}

.works-table td.hidden {
  display: none !important;
}

.works-table input:not([type="checkbox"]):not([type="radio"]),
.works-table select,
.works-table textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.works-table .cost-input,
.cost-input {
  max-width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.equipment-cost-panel {
  margin: 0 0 18px 0;
  padding: 12px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface);
  border-radius: 6px;
}

.equipment-cost-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.equipment-cost-header h3,
.equipment-cost-header p {
  margin: 0;
}

.equipment-cost-header p {
  padding: 6px 0 0 0;
  color: var(--color-text-muted);
}

.equipment-cost-total,
.equipment-cost-insights div {
  padding: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  border-radius: 6px;
}

.equipment-cost-total span,
.equipment-cost-insights span {
  display: block;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.equipment-cost-total strong {
  display: block;
  padding-top: 4px;
  color: var(--color-heading);
  font-size: 22px;
}

.equipment-cost-insights {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.equipment-cost-insights strong {
  display: block;
  padding-top: 4px;
  color: var(--color-heading);
}

.equipment-cost-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.equipment-cost-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
}

.equipment-cost-row-label span,
.equipment-cost-row-label strong {
  display: block;
}

.equipment-cost-row-label span {
  color: var(--color-heading);
  font-weight: 700;
}

.equipment-cost-row-label strong {
  padding-top: 2px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.equipment-cost-track {
  grid-column: 1 / -1;
  height: 14px;
  overflow: hidden;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border-soft);
  border-radius: 999px;
}

.equipment-cost-fill {
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: #2f9e41;
}

.equipment-cost-percent {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.equipment-cost-row-parandus .equipment-cost-fill { background: #e03131; }
.equipment-cost-row-hooldus_kuluosad .equipment-cost-fill { background: #2f9e41; }
.equipment-cost-row-lõhkumine .equipment-cost-fill { background: #f08c00; }
.equipment-cost-row-täiendused .equipment-cost-fill { background: #1971c2; }
.equipment-cost-row-rent .equipment-cost-fill { background: #7048e8; }
.equipment-cost-row-liising .equipment-cost-fill { background: #0ca678; }
.equipment-cost-row-ost .equipment-cost-fill { background: #c2255c; }

.equipment-cost-empty {
  padding: 12px;
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border-radius: 6px;
  text-align: center;
}

.equipment-cost-panel.compact {
  margin: 14px 0 0 0;
  padding: 10px;
}

.equipment-cost-panel.compact .equipment-cost-header {
  gap: 8px;
  margin-bottom: 10px;
}

.equipment-cost-panel.compact .equipment-cost-header h3 {
  font-size: 16px;
}

.equipment-cost-panel.compact .equipment-cost-header p {
  font-size: 12px;
  line-height: 1.3;
}

.equipment-cost-panel.compact .equipment-cost-total {
  padding: 8px 9px;
}

.equipment-cost-panel.compact .equipment-cost-total strong {
  font-size: 20px;
}

.equipment-cost-panel.compact .equipment-cost-bars {
  gap: 9px;
}

.equipment-cost-panel.compact .equipment-cost-row {
  gap: 4px 8px;
}

.equipment-cost-panel.compact .equipment-cost-track {
  height: 10px;
}

.equipment-actions-cost-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.equipment-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.equipment-action-buttons .btn {
  width: auto;
  flex: 1 1 110px;
}

.equipment-cost-panel.compact.donut {
  margin: 0;
}

.equipment-cost-donut-layout {
  display: flex;
  align-items: center;
  gap: 12px;
}

.equipment-cost-donut {
  position: relative;
  flex: 0 0 118px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--color-border-soft);
}

.equipment-cost-donut::after {
  content: "";
  position: absolute;
  inset: 21px;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border-soft);
}

.equipment-cost-donut-center {
  position: absolute;
  inset: 28px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.equipment-cost-donut-center span {
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.equipment-cost-donut-center strong {
  color: var(--color-heading);
  font-size: 14px;
  line-height: 1.1;
}

.equipment-cost-legend {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.equipment-cost-legend-item {
  display: grid;
  grid-template-columns: 9px minmax(52px, 1fr) auto;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.equipment-cost-legend-item strong {
  color: var(--color-heading);
  font-weight: 700;
  white-space: nowrap;
}

.equipment-cost-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.equipment-service-cost-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.equipment-service-actions {
  width: 100%;
}

.equipment-cost-compact {
  width: 100%;
}

.equipment-cost-compact .equipment-cost-empty {
  width: auto;
}

.works-table textarea {
  min-height: 84px;
}

.works-table .works-row-actions,
#tööde-tabel.works-table .works-row-actions {
  display: block;
  padding-top: 10px;
}

.works-table .works-row-actions::before {
  content: none;
}

.works-table #keskel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.works-table #keskel button,
.works-table #keskel #button,
.works-table .works-row-actions > button {
  width: 100%;
  min-height: 40px;
  margin: 0;
}

.works-table #button a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 10px;
}

.works-edit-table tr {
  margin-bottom: 12px;
}
