:root {
  --bg: #0a0c10;
  --bg-elevated: #11151c;
  --bg-soft: #181d27;
  --bg-card: rgba(20, 25, 34, 0.94);
  --bg-body: radial-gradient(circle at top right, rgba(107, 154, 196, 0.14), transparent 34%),
    radial-gradient(circle at bottom left, rgba(61, 90, 120, 0.18), transparent 30%),
    linear-gradient(160deg, #07090d 0%, #11151c 55%, #0a0c10 100%);
  --bg-topbar: rgba(12, 17, 23, 0.88);
  --bg-sidebar: rgba(10, 14, 20, 0.96);
  --bg-input: rgba(11, 15, 20, 0.75);
  --bg-input-focus: rgba(11, 15, 20, 0.95);
  --bg-panel: #121820;
  --border: rgba(107, 154, 196, 0.18);
  --border-strong: rgba(107, 154, 196, 0.42);
  --border-input: rgba(255, 255, 255, 0.08);
  --border-table: rgba(255, 255, 255, 0.06);
  --text: #ffffff;
  --text-muted: #9aa3b2;
  --text-label: #d7dde5;
  --primary: #6b9ac4;
  --primary-strong: #3d6f9a;
  --primary-soft: rgba(107, 154, 196, 0.14);
  --accent: #8eb4d4;
  --accent-strong: #4f7cac;
  --accent-soft: rgba(142, 180, 212, 0.14);
  --success: #7aafd4;
  --danger: #e57373;
  --info: #6b9ac4;
  --warning: #a8c5dd;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.42), 0 0 36px rgba(107, 154, 196, 0.06);
  --link-hover: #a8c5dd;
  --radius: 18px;
  --radius-sm: 12px;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-elevated: #ffffff;
  --bg-soft: #e7eef5;
  --bg-card: #ffffff;
  --bg-body: linear-gradient(180deg, #f7fafc 0%, #eef3f8 55%, #f4f7fb 100%);
  --bg-topbar: rgba(255, 255, 255, 0.92);
  --bg-sidebar: #ffffff;
  --bg-input: #ffffff;
  --bg-input-focus: #ffffff;
  --bg-panel: #ffffff;
  --border: rgba(61, 111, 154, 0.2);
  --border-strong: rgba(61, 111, 154, 0.4);
  --border-input: rgba(26, 35, 48, 0.14);
  --border-table: rgba(26, 35, 48, 0.08);
  --text: #1a2330;
  --text-muted: #5c6b7c;
  --text-label: #334155;
  --primary: #3d6f9a;
  --primary-strong: #2f5878;
  --primary-soft: rgba(61, 111, 154, 0.12);
  --accent: #3d6f9a;
  --accent-strong: #2f5878;
  --accent-soft: rgba(61, 111, 154, 0.1);
  --success: #2f6f8f;
  --danger: #c44747;
  --info: #3d6f9a;
  --warning: #3d6f9a;
  --shadow: 0 12px 32px rgba(26, 45, 64, 0.08);
  --link-hover: #2f5878;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  background: var(--bg-body);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
}

img {
  max-width: 100%;
  display: block;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(100%, 420px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  justify-content: center;
}

.brand img {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(61, 111, 154, 0.22);
}

.brand-copy h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.brand-copy p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 28px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.card .subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  line-height: 1.5;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  color: var(--text-label);
  font-weight: 600;
}

.form-control {
  width: 100%;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font: inherit;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.form-control:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px var(--primary-soft);
  background: var(--bg-input-focus);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
  transform: none;
}

[hidden] {
  display: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(61, 111, 154, 0.28);
}

.btn-primary:hover {
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(61, 111, 154, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-input);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.12);
  color: #ff8e8e;
  border: 1px solid rgba(255, 107, 107, 0.25);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.2);
}

.auth-links {
  margin-top: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.92rem;
  line-height: 1.4;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(107, 154, 196, 0.12);
  border-color: rgba(107, 154, 196, 0.28);
  color: #a8c5dd;
}

.alert-error {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.28);
  color: #ef9a9a;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.theme-toggle-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.theme-toggle-icon svg {
  width: 18px;
  height: 18px;
  display: none;
}

html:not([data-theme="light"]) .theme-toggle .icon-sun {
  display: block;
}

html[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.theme-toggle-auth {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
}

.topbar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(107, 154, 196, 0.55);
  background: #1a222d;
  flex-shrink: 0;
}

.welcome-text {
  min-width: 0;
}

.welcome-text-right {
  text-align: right;
  margin-right: 4px;
}

.welcome-text .hello {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.welcome-text .name {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 1;
  min-width: 0;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid var(--border-input);
  color: var(--text);
}

.profile-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.profile-trigger img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-trigger span {
  font-size: 0.92rem;
  font-weight: 600;
}

.app-main {
  flex: 1;
  padding: 24px 20px 40px;
  width: min(1100px, 100%);
  margin: 0 auto;
}

.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-state .badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: clamp(1.4rem, 2vw, 1.9rem);
}

.empty-state p {
  margin: 0 auto;
  max-width: 520px;
  color: var(--text-muted);
  line-height: 1.6;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h2 {
  margin: 0;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.profile-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
}

.avatar-panel {
  text-align: center;
}

.avatar-preview {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 16px;
  border: 3px solid rgba(107, 154, 196, 0.45);
  background: #1a222d;
}

.company-logo-preview {
  width: 170px;
  height: 170px;
  border-radius: 24px;
  object-fit: contain;
  margin: 0 auto 16px;
  padding: 14px;
  border: 2px solid rgba(107, 154, 196, 0.35);
  background: rgba(11, 15, 20, 0.75);
}

.section-title {
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 4px 0 16px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

.section-title:not(:first-child) {
  margin-top: 22px;
}

.state-control {
  max-width: 120px;
}

.company-actions {
  flex-direction: row;
  margin-top: 20px;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 10px;
}

.app-shell.has-sidebar {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(107, 154, 196, 0.4) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(107, 154, 196, 0.35);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 154, 196, 0.55);
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
  padding: 4px 8px;
}

.sidebar-brand > div {
  min-width: 0;
  flex: 1;
}

.sidebar-brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.95rem;
}

.sidebar-brand span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.sidebar-close:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-backdrop {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-group {
  margin: 16px 8px 6px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-accordion {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.sidebar-accordion-toggle:hover {
  color: var(--text);
  background: rgba(107, 154, 196, 0.12);
  border-color: var(--border);
}

.sidebar-accordion.is-open > .sidebar-accordion-toggle {
  color: var(--primary);
}

.sidebar-accordion-caret {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.7;
  transition: transform .2s ease;
  flex-shrink: 0;
}

.sidebar-accordion.is-open .sidebar-accordion-caret {
  transform: rotate(-135deg);
  margin-top: 4px;
}

.sidebar-accordion-panel {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 8px;
  margin-left: 8px;
  border-left: 1px solid var(--border);
}

.sidebar-accordion.is-open > .sidebar-accordion-panel {
  display: flex;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.sidebar-nav > a {
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
}

.sidebar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-accordion-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-accordion-panel a {
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 500;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
  color: var(--text);
  background: var(--primary-soft);
  border-color: var(--border);
}

.app-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-shell.has-sidebar .app-main {
  width: 100%;
  max-width: none;
}

.system-footer {
  padding: 18px 20px 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.system-footer a {
  color: var(--primary);
  font-weight: 700;
}

.footer-heart {
  display: inline-block;
  color: #ff6b6b;
  margin: 0 3px;
  animation: heart-beat 1.6s ease-in-out infinite;
}

.auth-footer {
  padding: 18px 0 0;
}

@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.18); }
  28% { transform: scale(1); }
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.hr-event-filter {
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0;
}

.hr-event-filter .competence-picker {
  flex: 1;
  min-width: 280px;
}

.btn-ghost.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.toolbar .form-control {
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-table);
  vertical-align: middle;
}

.table th {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

.table .actions form {
  margin: 0;
}

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 10px !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-success {
  background: rgba(107, 154, 196, 0.14);
  color: #a8c5dd;
}

.badge-muted {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.badge-info {
  background: rgba(77, 171, 247, 0.14);
  color: #9ed0ff;
}

.badge-warning {
  background: rgba(107, 154, 196, 0.16);
  color: #c5d7e8;
}

.badge-danger {
  background: rgba(255, 107, 107, 0.16);
  color: #ef9a9a;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card span {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 1.15rem;
}

.stat-card.danger strong { color: #ef9a9a; }
.stat-card.warning strong { color: #c5d7e8; }
.stat-card.success strong { color: #a8c5dd; }

.finance-filters {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr minmax(180px, 1.2fr) 0.9fr 0.85fr 0.85fr auto auto;
  gap: 10px;
  margin-bottom: 18px;
  align-items: start;
}

.finance-party-filter {
  min-width: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-card {
  margin-bottom: 18px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.finance-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-list span {
  color: var(--text-muted);
}

.payment-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(11, 15, 20, 0.55);
  border: 1px solid var(--border);
}

.payment-preview > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.payment-preview span {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chip,
.attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
}

.attachment-file-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-file.is-compact {
  flex-wrap: wrap;
  padding: 6px 8px;
}

.attachment-file.is-compact .attachment-file-name {
  max-width: 140px;
}

.attachment-file .btn {
  flex: 0 0 auto;
}

.cancel-box {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(107, 154, 196, 0.15);
}

.row-voided td {
  opacity: 0.65;
  text-decoration: line-through;
}

.row-voided.notes-row td {
  text-decoration: none;
}

.notes-row td {
  padding-top: 0 !important;
  border-bottom-width: 2px;
}

.payroll-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.payroll-summary > div {
  padding: 14px;
  border-radius: 14px;
  background: rgba(11, 15, 20, 0.55);
  border: 1px solid var(--border);
}

.payroll-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.payroll-summary strong {
  color: var(--primary);
}

.payroll-table .form-control {
  min-width: 115px;
  padding: 10px;
}

.payroll-table td:last-child .form-control {
  min-width: 180px;
}

.payroll-row-disabled {
  opacity: 0.48;
}

.payroll-warning {
  color: #ef9a9a;
  font-size: 0.76rem;
  margin-top: 4px;
}

.payroll-empty-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.payroll-empty-alert p {
  margin: 5px 0 0;
}

.payroll-top-actions {
  flex-direction: row;
  margin-top: -6px;
}

.competence-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.competence-picker .form-control {
  min-height: 44px;
}

.competence-picker [data-competence-month] {
  flex: 1.4;
}

.competence-picker [data-competence-year] {
  flex: 0.9;
  min-width: 90px;
}

.competence-nav {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.payroll-run-meta {
  grid-template-columns: repeat(4, 1fr);
  display: grid;
  gap: 14px;
}

.payroll-run-meta > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

@media (max-width: 1100px) {
  .stats-grid,
  .finance-detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .finance-filters {
    grid-template-columns: 1fr 1fr;
  }

  .payroll-summary,
  .payroll-run-meta {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .stats-grid,
  .finance-detail-grid,
  .payment-preview,
  .finance-filters {
    grid-template-columns: 1fr;
  }

  .payroll-summary,
  .payroll-run-meta {
    grid-template-columns: 1fr;
  }

  .payroll-empty-alert {
    align-items: stretch;
    flex-direction: column;
  }
}

.btn-sm {
  padding: 8px 10px;
  font-size: 0.85rem;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.input-with-action {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.input-with-action .form-control {
  flex: 1;
  min-width: 0;
}

.btn-icon-plus {
  min-width: 46px;
  padding-left: 0;
  padding-right: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.field-label-row label {
  margin-bottom: 0;
}

.btn-plus-accent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(61, 111, 154, 0.38);
}

.btn-plus-accent:hover {
  filter: brightness(1.08);
  box-shadow: 0 10px 22px rgba(61, 111, 154, 0.5);
}

.search-select {
  position: relative;
  flex: 1;
  min-width: 0;
  scroll-margin-bottom: 160px;
}

@keyframes weighing-attention {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(107, 154, 196, 0);
  }
  40% {
    box-shadow: 0 0 0 6px rgba(107, 154, 196, 0.55);
  }
}

.search-select.is-attention .form-control {
  border-color: var(--primary);
  animation: weighing-attention .55s ease-in-out 2;
}

.search-select-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}

.search-select-option,
.search-select-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.search-select-option:hover,
.search-select-option.is-active {
  background: var(--primary-soft);
}

.search-select-empty {
  color: var(--text-muted);
  cursor: default;
}

.search-select-option small.search-select-stock {
  display: inline;
  flex-shrink: 0;
  font-weight: 700;
  color: #a8c5dd;
}

.search-select-option small.search-select-stock.is-empty,
.sale-stock-hint.is-empty {
  color: #ef9a9a;
}

.sale-stock-hint {
  margin: 8px 0 0;
  color: #a8c5dd;
  font-size: 0.84rem;
  font-weight: 700;
}

.form-entry-modal .system-modal-dialog {
  width: min(560px, 100%);
  max-height: min(92vh, 760px);
  overflow-y: auto;
}

.check-line-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.quick-card {
  display: block;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color .2s ease, transform .15s ease;
}

.quick-card:hover {
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-2px);
}

.quick-card strong {
  display: block;
  margin-bottom: 6px;
}

.quick-card span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sidebar-toggle {
  display: none;
  min-width: 42px;
  padding-left: 10px;
  padding-right: 10px;
}

textarea.form-control {
  resize: vertical;
  min-height: 96px;
}

select.form-control {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #9aa6b2 50%), linear-gradient(135deg, #9aa6b2 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.lookup-field {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.lookup-field .form-control {
  max-width: 240px;
}

.lookup-status-success {
  color: #72d69b;
}

.lookup-status-error {
  color: #ef9a9a;
}

body.modal-open {
  overflow: hidden;
}

.system-modal[hidden] {
  display: none !important;
}

.system-modal {
  --modal-color: var(--primary);
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  opacity: 0;
  transition: opacity .18s ease;
}

.system-modal.is-open {
  opacity: 1;
}

.system-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 10, .78);
  backdrop-filter: blur(8px);
}

.system-modal-dialog {
  position: relative;
  width: min(520px, 100%);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--modal-color) 45%, transparent);
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--modal-color) 12%, transparent), transparent 38%),
    linear-gradient(145deg, #1a222d, #10161e);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .64);
  transform: translateY(18px) scale(.97);
  transition: transform .2s ease;
}

.system-modal.is-open .system-modal-dialog {
  transform: translateY(0) scale(1);
}

.system-modal-accent {
  height: 5px;
  background: linear-gradient(90deg, var(--modal-color), var(--primary-strong));
}

.system-modal-body {
  display: flex;
  gap: 18px;
  padding: 28px 28px 20px;
}

.system-modal-icon {
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--modal-color) 55%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--modal-color) 15%, transparent);
  color: var(--modal-color);
  font-size: 1.55rem;
  font-weight: 800;
}

.system-modal-copy {
  min-width: 0;
}

.system-modal-label {
  display: block;
  margin-bottom: 6px;
  color: var(--modal-color);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.system-modal-copy h3 {
  margin: 0 0 9px;
  color: #fff;
  font-size: 1.32rem;
  line-height: 1.25;
}

.system-modal-copy p {
  margin: 0;
  color: #c4cdd6;
  font-size: .98rem;
  line-height: 1.6;
  white-space: pre-line;
}

.system-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 28px 24px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  background: rgba(5, 8, 12, .22);
}

.system-modal-actions .btn {
  min-width: 112px;
}

.modal-success {
  --modal-color: var(--success);
}

.modal-error,
.modal-danger {
  --modal-color: var(--danger);
}

.modal-danger [data-modal-confirm],
.modal-error [data-modal-confirm] {
  border-color: var(--danger);
  background: var(--danger);
  color: #14181d;
}

.batch-payment-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 8px 0 20px;
}

.batch-payment-summary > div {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(107, 154, 196, .07);
}

.batch-payment-summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: .82rem;
}

.batch-payment-summary strong {
  color: var(--primary);
  font-size: 1.15rem;
}

.check-line.compact {
  margin: 0;
}

.batch-history-card {
  padding: 17px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.batch-history-card:last-child {
  border-bottom: 0;
}

.batch-history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.batch-history-head p {
  margin: 5px 0 0;
  color: var(--text-muted);
}

.batch-void-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
}

.batch-void-form .form-control {
  max-width: 440px;
}

.stock-item-card {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(7, 11, 16, .35);
}

.stock-item-head,
.tare-editor-head,
.stock-action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stock-item-head {
  margin-bottom: 16px;
}

.tare-editor {
  margin: 6px 0 16px;
  padding: 15px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(107, 154, 196, .04);
}

.tare-editor-head {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: .86rem;
  font-weight: 700;
}

.tare-row {
  display: grid;
  grid-template-columns: minmax(190px, 2fr) 90px minmax(130px, 1fr) 120px 42px;
  align-items: center;
  gap: 9px;
  margin-top: 9px;
}

.tare-row > strong {
  color: var(--primary);
  text-align: right;
  white-space: nowrap;
}

.stock-weight-result {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
}

.stock-weight-result span {
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text-muted);
}

.stock-weight-result strong {
  margin-left: 4px;
  color: var(--text);
}

.stock-weight-result span:last-child {
  background: rgba(107, 154, 196, .11);
}

.stock-weight-result span:last-child strong {
  color: #a8c5dd;
}

.stock-weight-error {
  color: var(--danger) !important;
}

.negative-override-box {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid rgba(255, 107, 107, .28);
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 107, .06);
}

.negative-override-box .form-control {
  margin-top: 10px;
}

.stock-form-actions {
  flex-direction: row;
  flex-wrap: wrap;
}

.stock-action-panel {
  margin-top: 22px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}

.stock-action-panel p {
  margin: 5px 0 0;
  color: var(--text-muted);
}

.stock-negative-row td {
  background: rgba(255, 107, 107, .06);
}

.stock-negative-row strong {
  color: var(--danger);
}

.tare-detail + .tare-detail {
  margin-top: 7px;
}

.receipt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.receipt-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
}

.receipt-card-main {
  display: block;
  color: inherit;
}

.receipt-card:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.receipt-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.receipt-card-head,
.mobile-operation-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.receipt-card h3 {
  margin: 15px 0;
}

.receipt-card-data {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.receipt-card-data span {
  color: var(--text-muted);
  font-size: .78rem;
}

.receipt-card-data strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: .92rem;
}

.operation-step {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.mobile-operation-header {
  margin-bottom: 18px;
}

.mobile-operation-header h2 {
  margin: 0 0 5px;
}

.mobile-operation-header p {
  margin: 0;
  color: var(--text-muted);
}

.mobile-control {
  min-height: 50px;
}

.plate-input {
  text-transform: uppercase;
}

.mobile-sticky-action {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.receipt-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.receipt-progress > div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: .78rem;
  text-align: center;
}

.receipt-progress span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  margin-right: 6px;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-soft);
}

.receipt-progress .current {
  border-color: var(--primary);
  color: var(--primary);
}

.receipt-progress .done {
  border-color: rgba(107, 154, 196, .35);
  color: var(--success);
}

.receipt-next-action {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.mobile-weighing-form {
  padding-bottom: 95px;
}

.mobile-weight-input {
  min-height: 62px;
  color: var(--primary);
  font-size: 1.45rem;
  font-weight: 800;
  text-align: center;
}

.mobile-add-material {
  width: 100%;
  min-height: 52px;
}

.weighing-head {
  margin-bottom: 0;
  gap: 8px;
}

.weighing-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.weighing-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.weighing-toggle-copy small {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weighing-caret {
  width: 0.55rem;
  height: 0.55rem;
  flex-shrink: 0;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: rotate(45deg);
  transition: transform .18s ease;
  margin-top: -2px;
}

.mobile-weighing-card.is-open .weighing-caret {
  transform: rotate(-135deg);
  margin-top: 4px;
}

.mobile-weighing-card {
  position: relative;
  scroll-margin-top: 12px;
  scroll-margin-bottom: 160px;
}

.mobile-weighing-card.is-collapsed .weighing-body {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.mobile-weighing-card.is-open .weighing-body {
  margin-top: 14px;
}

.mobile-weighing-card.is-collapsed {
  padding-top: 12px;
  padding-bottom: 12px;
}

.weighing-actions {
  position: sticky;
  z-index: 15;
  bottom: 0;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.weighing-actions > div {
  margin-right: auto;
  color: var(--text-muted);
}

.weighing-actions > div strong {
  display: block;
  color: var(--success);
  font-size: 1.15rem;
}

.adjustment-preview-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--text);
}

.adjustment-preview-list li {
  line-height: 1.4;
}

.purchase-table td {
  vertical-align: top;
}

[data-adjustment-form] .table-wrap {
  overflow: visible;
}

[data-adjustment-form] .search-select {
  z-index: 2;
}

[data-adjustment-form] tr:has(.search-select-list:not([hidden])) {
  position: relative;
  z-index: 8;
}

[data-adjustment-form] .search-select-list {
  z-index: 80;
  min-width: 280px;
}

.purchase-price-cell {
  min-width: 260px;
}

.purchase-price-cell .form-control {
  max-width: 160px;
}

.price-history {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.price-history-group {
  display: grid;
  gap: 4px;
}

.price-history-label {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.price-history-empty {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.price-history-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
}

.price-history-item strong {
  color: var(--primary);
  font-size: 0.82rem;
}

.price-history-item span {
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-history-item time {
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

button.price-history-item {
  cursor: pointer;
}

button.price-history-item:hover,
button.price-history-item:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: none;
}

.purchase-total-box {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  margin: 18px 0;
  padding: 17px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}

.purchase-total-box span {
  color: var(--text-muted);
}

.purchase-total-box strong {
  display: block;
  margin-top: 4px;
  color: var(--primary);
  font-size: 1.2rem;
}

.pay-now-box {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sale-tabs {
  margin-bottom: 18px;
}

.sale-pay-card {
  margin-top: 18px;
  padding: 18px;
}

.sale-pay-card h3 {
  margin: 0 0 6px;
}

.sale-pay-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

.sale-pay-count,
.sale-pay-entry {
  width: 110px;
}

.sale-pay-lines {
  display: grid;
  gap: 8px;
}

.sale-pay-line {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr minmax(90px, 1fr) minmax(110px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.sale-pay-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.sale-pay-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
}

.weighing-head-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  align-items: center;
}

.sale-material-summary {
  margin: 16px 0;
  padding: 16px 18px;
}

.sale-material-summary h3 {
  margin: 0 0 4px;
}

.sale-material-summary-list,
[data-sale-material-summary-list] {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.sale-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
  align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.sale-summary-row strong {
  color: var(--text);
}

.weighing-summary-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.weighing-summary-totals strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1.05rem;
}

.material-margin-line {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--text);
  font-weight: 700;
}

.material-margin-line.is-negative,
.material-margin-value.is-negative {
  color: #f0a0a0;
}

.material-margin-value.is-positive {
  color: var(--success);
}

.material-history-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.material-history-block h3 {
  margin: 0 0 4px;
}

.finance-flow-block {
  margin: 0 0 20px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border);
}

.finance-flow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.finance-flow-step span {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.finance-flow-step strong {
  font-size: 0.95rem;
}

.finance-installments {
  margin: 0 0 16px;
  padding: 16px 18px;
}

.finance-installments-fields {
  margin-top: 12px;
}

.finance-installments-preview {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  margin-top: 4px;
  padding: 4px 0;
}

.finance-installment-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.finance-installment-row.is-editable {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(130px, 150px) minmax(110px, 130px) minmax(110px, 150px);
  align-items: center;
}

.finance-installment-row strong {
  color: var(--text);
  font-size: 0.88rem;
}

.statement-lines {
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
}

.statement-lines th,
.statement-lines td {
  font-size: 0.82rem;
}

.statement-lines-row td {
  padding-top: 0;
  border-top: 0;
}

.statement-report td {
  vertical-align: top;
}

.statement-report .num {
  text-align: right;
  white-space: nowrap;
}

.statement-report .statement-op td {
  border-top-width: 2px;
}

.statement-report .statement-line td {
  color: var(--text-muted);
}

.statement-report .statement-line td:nth-child(3),
.statement-report .statement-line td:nth-child(4),
.statement-report .statement-line td:nth-child(5) {
  color: var(--text);
}

.statement-report .statement-total td {
  font-size: 0.9rem;
}

.statement-footer {
  margin-top: 16px;
}

.statement-footer p {
  margin: 0 0 6px;
}

@media (max-width: 768px) {
  .finance-installment-row.is-editable {
    grid-template-columns: 1fr;
  }
}

.btn.is-disabled {
  opacity: 0.55;
}

@media (max-width: 768px) {
  .sale-pay-line {
    grid-template-columns: 1fr 1fr;
  }

  .sale-summary-row {
    grid-template-columns: 1fr 1fr;
  }
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 18px;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(107, 154, 196, 0.12), transparent 45%),
    linear-gradient(225deg, rgba(107, 154, 196, 0.12), transparent 40%),
    var(--bg-card);
  box-shadow: var(--shadow);
}

.dashboard-kicker {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.dashboard-hero h2 {
  margin: 0 0 6px;
  font-size: 1.7rem;
}

.dashboard-hero p {
  margin: 0;
  color: var(--text-muted);
}

.dashboard-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

a.dashboard-kpi {
  color: inherit;
  text-decoration: none;
  transition: border-color .2s ease, transform .15s ease, box-shadow .2s ease;
}

a.dashboard-kpi:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28), 0 0 24px rgba(107, 154, 196, 0.12);
  color: inherit;
}

.dashboard-kpi em {
  display: block;
  margin-top: 8px;
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.dashboard-kpi .kpi-alert {
  color: #ef9a9a;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-panel {
  margin-bottom: 16px;
}

.dashboard-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.dashboard-panel-head h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.dashboard-panel-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.dashboard-panel-head a,
.dashboard-panel-links a {
  color: var(--primary);
  font-size: 0.88rem;
  white-space: nowrap;
}

.dashboard-panel-links {
  display: flex;
  gap: 12px;
}

.dashboard-callout {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(107, 154, 196, 0.35);
  background: rgba(107, 154, 196, 0.1);
}

.dashboard-callout strong {
  font-size: 0.92rem;
}

.dashboard-empty {
  color: var(--text-muted);
  padding: 18px 4px;
  font-size: 0.92rem;
}

.dashboard-empty a {
  margin-left: 8px;
}

.dashboard-list {
  display: grid;
  gap: 8px;
}

.dashboard-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  transition: border-color .15s ease, background .15s ease;
}

.dashboard-list-item:hover {
  border-color: var(--border-strong);
  background: rgba(107, 154, 196, 0.06);
  color: inherit;
}

.dashboard-list-item strong {
  display: block;
  margin-bottom: 2px;
}

.dashboard-list-item span {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.dashboard-list-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.dashboard-stock-list {
  display: grid;
  gap: 14px;
}

.dashboard-stock-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
}

.dashboard-stock-copy strong {
  display: block;
}

.dashboard-stock-copy span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.dashboard-stock-qty {
  color: var(--success);
}

.dashboard-stock-bar {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.dashboard-stock-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.dashboard-drafts {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.dashboard-payroll-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: end;
}

.dashboard-payroll-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.dashboard-payroll-grid strong {
  font-size: 1.15rem;
}

.dashboard-shortcuts {
  margin-top: 4px;
  margin-bottom: 8px;
}

@media (max-width: 1100px) {
  .quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-columns,
  .dashboard-payroll-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .dashboard-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid.dashboard-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 12px 14px;
    gap: 8px;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar .theme-toggle {
    min-width: 42px;
    padding: 8px;
    justify-content: center;
  }

  .topbar .theme-toggle-text {
    display: none;
  }

  .profile-trigger span {
    display: none;
  }

  .welcome-text .name {
    font-size: 0.98rem;
    max-width: 120px;
  }

  .stats-grid.dashboard-kpis,
  .quick-grid,
  .dashboard-shortcuts {
    grid-template-columns: 1fr;
  }

  .welcome-text-right .hello {
    display: none;
  }

  .profile-grid,
  .grid-2,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .app-main {
    padding: 18px 14px 32px;
  }

  .card {
    padding: 20px;
  }

  .app-shell.has-sidebar {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .input-with-action {
    flex-direction: column;
  }

  .lookup-field {
    flex-direction: column;
  }

  .lookup-field .form-control {
    max-width: none;
  }

  .system-modal {
    padding: 14px;
  }

  .system-modal-body {
    gap: 14px;
    padding: 23px 20px 17px;
  }

  .system-modal-icon {
    flex-basis: 46px;
    width: 46px;
    height: 46px;
  }

  .system-modal-actions {
    padding: 16px 20px 20px;
  }

  .batch-payment-summary {
    grid-template-columns: 1fr;
  }

  .batch-history-head,
  .batch-void-form {
    align-items: stretch;
    flex-direction: column;
  }

  .batch-void-form .form-control {
    max-width: none;
  }

  .tare-row {
    grid-template-columns: 1fr 80px;
  }

  .tare-row > strong {
    text-align: left;
  }

  .stock-item-head,
  .stock-action-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .weighing-head {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .weighing-head-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .receipt-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .mobile-operation-form,
  .mobile-weighing-card {
    padding: 15px;
  }

  .mobile-operation-header {
    align-items: stretch;
    flex-direction: column;
  }

  .receipt-progress {
    grid-template-columns: repeat(3, 1fr);
  }

  .receipt-card-data {
    grid-template-columns: 1fr;
  }

  .weighing-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .weighing-actions > div {
    margin: 0;
    text-align: center;
  }

  .purchase-total-box {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .welcome-text {
    display: none;
  }

  .topbar-right form .btn {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media print {
  .sidebar,
  .topbar,
  .system-footer,
  .header-actions,
  .receipt-next-action,
  .cancel-box,
  .theme-toggle {
    display: none !important;
  }

  .app-shell.has-sidebar {
    display: block;
  }

  .app-main {
    padding: 0;
  }
}

html[data-theme="light"] .topbar-avatar,
html[data-theme="light"] .empty-illustration {
  background: #e8eef5;
}

html[data-theme="light"] .system-modal-dialog {
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--modal-color) 12%, transparent), transparent 38%),
    linear-gradient(145deg, #ffffff, #f3f6fa);
  box-shadow: 0 28px 90px rgba(26, 45, 64, .18);
}

html[data-theme="light"] .meta-chip,
html[data-theme="light"] .sidebar-close {
  background: var(--bg-soft);
  border-color: var(--border);
}

html[data-theme="light"] .material-margin-line.is-negative,
html[data-theme="light"] .material-margin-value.is-negative {
  color: #b42323;
}

html[data-theme="light"] .btn-danger {
  background: rgba(196, 71, 71, 0.1);
  color: #b42323;
  border-color: rgba(196, 71, 71, 0.28);
}

.treasury-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.treasury-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.treasury-card strong {
  font-size: 1.05rem;
}

.treasury-card em {
  font-style: normal;
  font-size: 1.35rem;
  font-weight: 800;
}

.treasury-card.is-inactive {
  opacity: 0.55;
}

.sale-pay-line [data-pay-treasury].is-hidden {
  display: none;
}

.offset-box {
  margin: 16px 0;
}

.offset-lead {
  margin: 0 0 12px;
}

.offset-preview {
  margin-top: 12px;
}

.advance-credit-banner {
  margin: 0 0 14px;
}

[data-sale-advance-host] {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header > .btn {
    width: 100%;
    justify-content: center;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar .form-control {
    min-width: 0;
    flex: 1 1 100%;
  }

  .sale-tabs .btn {
    flex: 1;
    justify-content: center;
  }

  .table-stack-card {
    padding: 0;
    border: 0;
    background: transparent;
  }

  .table-stack-card .table-wrap {
    overflow: visible;
  }

  .table-stack thead {
    display: none;
  }

  .table-stack tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
  }

  .table-stack tbody tr:last-child {
    margin-bottom: 0;
  }

  .table-stack tbody td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) 1fr;
    gap: 10px;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-table);
  }

  .table-stack tbody td:last-child {
    border-bottom: 0;
  }

  .table-stack tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .table-stack tbody td.empty-row {
    display: block;
    padding: 18px 4px;
    text-align: center;
  }

  .table-stack tbody td.empty-row::before {
    content: none;
  }

  .table-stack tbody td.actions {
    grid-template-columns: 1fr;
    padding-top: 12px;
  }

  .table-stack tbody td.actions::before {
    content: none;
  }

  .table-stack tbody td.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .table-stack tbody td.actions .btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }
}


