.tbv-app {
  --tbv-primary: #1f5c52;
  --tbv-primary-dark: #17463f;
  --tbv-ink: #17201e;
  --tbv-muted: #64716e;
  --tbv-line: #dce4e1;
  --tbv-bg: #f5f8f7;
  --tbv-card: #fff;
  --tbv-danger: #b42318;
  --tbv-danger-bg: #fff0ee;
  --tbv-warning: #8a4b0f;
  --tbv-warning-bg: #fff7df;
  color: var(--tbv-ink);
  font-size: 15px;
  line-height: 1.45;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
}

.tbv-app *, .tbv-app *::before, .tbv-app *::after { box-sizing: border-box; }
.tbv-app h1 { font-size: clamp(25px, 4vw, 38px); line-height: 1.15; margin: 7px 0; color: var(--tbv-ink); }
.tbv-app h2 { font-size: 22px; margin: 0 0 6px; color: var(--tbv-ink); }
.tbv-app h3 { color: var(--tbv-ink); }
.tbv-app a { color: var(--tbv-primary); text-decoration: none; }
.tbv-app a:hover { color: var(--tbv-primary-dark); }
.tbv-muted { color: var(--tbv-muted); }

.tbv-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--tbv-line);
  padding: 0 0 14px;
  margin-bottom: 24px;
}
.tbv-brand { color: var(--tbv-ink) !important; font-size: 18px; font-weight: 800; }
.tbv-user { display: flex; gap: 14px; align-items: center; color: var(--tbv-muted); }
.tbv-user a { font-weight: 700; }

.tbv-heading-row, .tbv-case-header, .tbv-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}
.tbv-back { display: inline-block; font-weight: 700; margin-bottom: 8px; }
.tbv-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.tbv-case-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.tbv-case-buttons form { margin: 0; }

.tbv-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 15px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none !important;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.tbv-button-primary { background: var(--tbv-primary); color: #fff !important; border-color: var(--tbv-primary); }
.tbv-button-primary:hover { background: var(--tbv-primary-dark); color: #fff !important; }
.tbv-button-light { background: #fff; color: var(--tbv-ink) !important; border-color: var(--tbv-line); }
.tbv-button-light:hover { border-color: var(--tbv-primary); color: var(--tbv-primary) !important; }

.tbv-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.tbv-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  background: var(--tbv-card);
  border: 1px solid var(--tbv-line);
  border-radius: 12px;
  padding: 15px 17px;
  color: var(--tbv-ink) !important;
  box-shadow: 0 3px 14px rgba(23,32,30,.04);
}
.tbv-stat span { color: var(--tbv-muted); font-weight: 700; }
.tbv-stat strong { font-size: 27px; }
.tbv-stat-danger { border-color: #f4bbb6; background: var(--tbv-danger-bg); }
.tbv-stat-danger strong { color: var(--tbv-danger); }
.tbv-stat-warning { border-color: #ead49a; background: var(--tbv-warning-bg); }
.tbv-stat-warning strong { color: var(--tbv-warning); }

.tbv-filter, .tbv-panel, .tbv-info-grid, .tbv-table-wrap {
  background: var(--tbv-card);
  border: 1px solid var(--tbv-line);
  border-radius: 12px;
  box-shadow: 0 3px 14px rgba(23,32,30,.04);
}
.tbv-filter {
  display: grid;
  grid-template-columns: 2fr repeat(5, minmax(130px, 1fr));
  gap: 12px;
  padding: 15px;
  margin-bottom: 16px;
}
.tbv-filter label, .tbv-field label { display: block; color: #3e4b48; font-size: 13px; font-weight: 800; margin: 0 0 5px; }
.tbv-filter input, .tbv-filter select, .tbv-field input, .tbv-field select, .tbv-field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c8d3cf;
  border-radius: 7px;
  background: #fff;
  color: var(--tbv-ink);
  font: inherit;
  padding: 8px 10px;
}
.tbv-field textarea { min-height: 120px; resize: vertical; }
.tbv-filter input:focus, .tbv-filter select:focus, .tbv-field input:focus, .tbv-field select:focus, .tbv-field textarea:focus {
  outline: 3px solid rgba(31,92,82,.13);
  border-color: var(--tbv-primary);
}
.tbv-filter-actions { display: flex; gap: 8px; grid-column: 1 / -1; justify-content: flex-end; }

.tbv-table-wrap { overflow-x: auto; }
.tbv-table { width: 100%; border-collapse: collapse; min-width: 1050px; margin: 0; }
.tbv-table th { background: var(--tbv-bg); color: #4b5855; font-size: 12px; letter-spacing: .035em; text-transform: uppercase; text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--tbv-line); }
.tbv-table td { padding: 14px; border-bottom: 1px solid #e9eeec; vertical-align: top; }
.tbv-table tbody tr:last-child td { border-bottom: 0; }
.tbv-table tbody tr:hover { background: #fbfdfc; }
.tbv-case-link { display: block; font-weight: 850; color: var(--tbv-ink) !important; }
.tbv-table small { display: block; color: var(--tbv-muted); margin-top: 3px; }
.tbv-row-archived { opacity: .62; }
.tbv-mobile-cards { display: none; }

.tbv-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf3f1;
  color: #36504a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}
.tbv-status-nauja { background: #e9f2ff; color: #184f91; }
.tbv-status-laukiama_duomenu, .tbv-status-laukiama_kliento, .tbv-status-laukiama_kitos_salies, .tbv-status-laukiama_institucijos { background: #fff3d4; color: #80510c; }
.tbv-status-vykdoma, .tbv-status-ruosiama_sutartis { background: #e9f6f3; color: #156052; }
.tbv-status-paruosta { background: #f0eaff; color: #57408c; }
.tbv-status-uzbaigta { background: #e9f7eb; color: #276734; }

.tbv-due { display: inline-flex; color: #43514e; font-weight: 750; white-space: nowrap; }
.tbv-due.is-overdue { color: var(--tbv-danger); }
.tbv-due.is-soon { color: var(--tbv-warning); background: var(--tbv-warning-bg); padding: 2px 6px; border-radius: 5px; }
.tbv-due.is-done { color: var(--tbv-muted); text-decoration: line-through; }

.tbv-panel { padding: 20px; margin: 0 0 18px; }
.tbv-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.tbv-span-2 { grid-column: 1 / -1; }
.tbv-form-buttons { display: flex; gap: 9px; justify-content: flex-end; padding-top: 18px; }
.tbv-preline { white-space: pre-line; }

.tbv-info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; margin-bottom: 18px; }
.tbv-info-item { padding: 15px 17px; border-right: 1px solid var(--tbv-line); border-bottom: 1px solid var(--tbv-line); min-width: 0; }
.tbv-info-item:nth-child(4n) { border-right: 0; }
.tbv-info-item:nth-last-child(-n+4) { border-bottom: 0; }
.tbv-info-item span { display: block; color: var(--tbv-muted); font-size: 12px; font-weight: 800; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.tbv-info-item strong { display: block; overflow-wrap: anywhere; }

.tbv-inline-form { display: grid; grid-template-columns: minmax(260px, 2fr) 150px 120px 170px; gap: 10px; align-items: end; padding: 14px; border-radius: 10px; background: var(--tbv-bg); margin: 15px 0; }
.tbv-action-notes { grid-column: 1 / -2; }
.tbv-action-submit { grid-column: -2 / -1; }
.tbv-actions-list { border-top: 1px solid var(--tbv-line); }
.tbv-action-item { display: flex; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--tbv-line); }
.tbv-action-item:last-child { border-bottom: 0; padding-bottom: 0; }
.tbv-action-item.is-done { opacity: .68; }
.tbv-action-item.is-done .tbv-action-body > strong { text-decoration: line-through; }
.tbv-action-toggle { flex: 0 0 auto; margin: 0; }
.tbv-action-toggle button { width: 27px; height: 27px; border: 2px solid #9aaba6; background: #fff; color: #fff; border-radius: 50%; font-size: 17px; line-height: 1; padding: 0; cursor: pointer; }
.tbv-action-item.is-done .tbv-action-toggle button { background: var(--tbv-primary); border-color: var(--tbv-primary); }
.tbv-action-body { flex: 1; min-width: 0; }
.tbv-action-body > strong { font-size: 16px; }
.tbv-action-body > p { margin: 7px 0 0; color: #4e5c58; }
.tbv-action-meta, .tbv-file-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; color: var(--tbv-muted); font-size: 12px; margin-top: 5px; }
.tbv-edit-action { margin-top: 7px; }
.tbv-edit-action summary { color: var(--tbv-primary); cursor: pointer; font-size: 13px; font-weight: 800; }
.tbv-inline-form-edit { margin-bottom: 0; }

.tbv-file-form { display: grid; grid-template-columns: 2fr 1fr 2fr auto; gap: 10px; align-items: end; padding: 14px; border-radius: 10px; background: var(--tbv-bg); margin: 15px 0; }
.tbv-file-form input[type=file] { padding: 6px; }
.tbv-files-list { border-top: 1px solid var(--tbv-line); }
.tbv-file-item { display: flex; align-items: flex-start; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--tbv-line); }
.tbv-file-item:last-child { border-bottom: 0; padding-bottom: 0; }
.tbv-file-icon { display: grid; place-items: center; flex: 0 0 46px; height: 46px; border-radius: 8px; background: #eaf1ef; color: var(--tbv-primary); font-size: 11px; font-weight: 900; }
.tbv-file-body { flex: 1; min-width: 0; }
.tbv-file-body > a { display: inline-block; max-width: 100%; font-weight: 850; overflow-wrap: anywhere; }
.tbv-file-body p { margin: 7px 0 0; color: #4e5c58; }
.tbv-link-danger { background: none; border: 0; color: var(--tbv-danger); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; padding: 3px; }

.tbv-timeline { position: relative; }
.tbv-timeline-item { display: flex; gap: 12px; padding: 9px 0; }
.tbv-timeline-dot { flex: 0 0 9px; height: 9px; border-radius: 50%; background: var(--tbv-primary); margin-top: 6px; }
.tbv-timeline-item strong { display: block; font-size: 14px; }
.tbv-timeline-item small { display: block; color: var(--tbv-muted); margin-top: 2px; }

.tbv-alert { border: 1px solid; border-radius: 9px; padding: 12px 14px; margin: 0 0 16px; font-weight: 750; }
.tbv-alert-success { border-color: #a8d5bc; color: #215c38; background: #edf9f2; }
.tbv-alert-error { border-color: #efb5b0; color: var(--tbv-danger); background: var(--tbv-danger-bg); }
.tbv-empty { text-align: center; padding: 50px 20px; border: 1px dashed #b9c8c3; border-radius: 12px; background: #fbfdfc; }
.tbv-empty h3 { margin: 0 0 6px; }
.tbv-empty p { margin: 0; color: var(--tbv-muted); }
.tbv-empty-small { padding: 22px; }

.tbv-login-wrap { max-width: 480px; padding-top: 50px; }
.tbv-login-card { background: #fff; border: 1px solid var(--tbv-line); border-radius: 14px; padding: 25px; box-shadow: 0 12px 36px rgba(23,32,30,.09); }
.tbv-login-card label { display: block; font-weight: 800; margin-bottom: 5px; }
.tbv-login-card input[type=text], .tbv-login-card input[type=password] { width: 100%; min-height: 44px; border: 1px solid #c8d3cf; border-radius: 7px; padding: 8px 10px; }
.tbv-login-card .login-submit input { min-height: 42px; border: 0; border-radius: 8px; padding: 8px 16px; color: #fff; background: var(--tbv-primary); font-weight: 800; cursor: pointer; }

@media (max-width: 1100px) {
  .tbv-filter { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tbv-filter-search { grid-column: 1 / -1; }
  .tbv-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbv-info-item:nth-child(4n) { border-right: 1px solid var(--tbv-line); }
  .tbv-info-item:nth-child(2n) { border-right: 0; }
  .tbv-info-item:nth-last-child(-n+4) { border-bottom: 1px solid var(--tbv-line); }
  .tbv-info-item:nth-last-child(-n+2) { border-bottom: 0; }
  .tbv-inline-form { grid-template-columns: 2fr 1fr 1fr; }
  .tbv-inline-form .tbv-action-main { grid-column: 1 / -1; }
  .tbv-action-notes { grid-column: 1 / -2; }
  .tbv-action-submit { grid-column: -2 / -1; }
  .tbv-file-form { grid-template-columns: 1fr 1fr; }
  .tbv-file-description { grid-column: 1 / -1; }
  .tbv-file-submit { grid-column: 2 / -1; justify-self: end; }
}

@media (max-width: 760px) {
  .tbv-app { padding: 12px; font-size: 14px; }
  .tbv-topbar, .tbv-heading-row, .tbv-case-header { align-items: stretch; }
  .tbv-topbar { gap: 8px; }
  .tbv-brand { font-size: 15px; }
  .tbv-user span { display: none; }
  .tbv-heading-row, .tbv-case-header { flex-direction: column; }
  .tbv-heading-row .tbv-button-primary { width: 100%; }
  .tbv-case-buttons { width: 100%; }
  .tbv-case-buttons > * { flex: 1; }
  .tbv-case-buttons form .tbv-button { width: 100%; }
  .tbv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbv-stat { padding: 12px; align-items: flex-end; }
  .tbv-stat span { font-size: 12px; }
  .tbv-stat strong { font-size: 23px; }
  .tbv-filter { grid-template-columns: 1fr 1fr; }
  .tbv-filter-search, .tbv-filter-actions { grid-column: 1 / -1; }
  .tbv-filter-actions .tbv-button { flex: 1; }
  .tbv-table-wrap { display: none; }
  .tbv-mobile-cards { display: grid; gap: 10px; }
  .tbv-mobile-card { display: block; color: var(--tbv-ink) !important; background: #fff; border: 1px solid var(--tbv-line); border-radius: 11px; padding: 14px; box-shadow: 0 3px 14px rgba(23,32,30,.04); }
  .tbv-mobile-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
  .tbv-mobile-card-head strong { font-size: 16px; }
  .tbv-mobile-card small { display: block; color: var(--tbv-muted); margin-top: 2px; }
  .tbv-mobile-card p { margin: 13px 0; }
  .tbv-mobile-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--tbv-muted); font-size: 12px; }
  .tbv-form-grid, .tbv-info-grid { grid-template-columns: 1fr; }
  .tbv-span-2 { grid-column: auto; }
  .tbv-info-item, .tbv-info-item:nth-child(2n), .tbv-info-item:nth-child(4n) { border-right: 0; border-bottom: 1px solid var(--tbv-line); }
  .tbv-info-item:nth-last-child(-n+2) { border-bottom: 1px solid var(--tbv-line); }
  .tbv-info-item:last-child { border-bottom: 0; }
  .tbv-form-buttons .tbv-button { flex: 1; }
  .tbv-inline-form, .tbv-file-form { grid-template-columns: 1fr; }
  .tbv-inline-form .tbv-action-main, .tbv-action-notes, .tbv-action-submit, .tbv-file-description, .tbv-file-submit { grid-column: auto; }
  .tbv-inline-form .tbv-button, .tbv-file-form .tbv-button { width: 100%; }
  .tbv-file-submit { justify-self: stretch; }
  .tbv-file-item { flex-wrap: wrap; }
  .tbv-file-item form { margin-left: 58px; }
  .tbv-panel { padding: 15px; }
}

@media (max-width: 430px) {
  .tbv-filter { grid-template-columns: 1fr; }
  .tbv-filter-search, .tbv-filter-actions { grid-column: auto; }
  .tbv-stats { gap: 8px; }
  .tbv-stat { flex-direction: column; align-items: flex-start; gap: 2px; }
}

