*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1d4ed8;
  --blue-hover: #1e40af;
  --blue-light: #eff6ff;
  --green: #15803d;
  --green-light: #f0fdf4;
  --red: #b91c1c;
  --red-light: #fef2f2;
  --orange: #c2410c;
  --orange-light: #fff7ed;
  --bg: #f1f5f9;
  --white: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ── */
.container { max-width: 900px; margin: 0 auto; padding: 0 16px; }
.container-lg { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.page { padding: 20px 0 48px; }

/* ── Header ── */
.header {
  background: var(--blue);
  color: white;
  padding: 12px 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.header-brand-group { display: flex; align-items: center; gap: 10px; }
.header-logo { border-radius: 50%; flex-shrink: 0; }
.header-brand { font-weight: 700; font-size: 17px; letter-spacing: -.2px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 13px; opacity: .85; }
.btn-logout {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: white; padding: 5px 13px;
  border-radius: 6px; cursor: pointer;
  font-size: 13px; transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.card-header {
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 600; font-size: 15px;
}
.card-body { padding: 16px 18px; }

/* ── Date display ── */
.date-big { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1.2; }
.date-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .5px;
}
.form-input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px; color: var(--text);
  background: white; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.form-input[readonly], .form-input:disabled { background: #f8fafc; color: var(--muted); cursor: default; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px; cursor: pointer;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: all .15s; white-space: nowrap;
  font-family: inherit; line-height: 1;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover:not(:disabled) { background: #166534; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover:not(:disabled) { background: #991b1b; }
.btn-warning { background: #d97706; color: white; }
.btn-outline { background: white; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 5px; }
.btn-icon { padding: 5px; width: 28px; height: 28px; justify-content: center; border-radius: 5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-locked { background: #dcfce7; color: #166534; }
.badge-fine { background: var(--red-light); color: var(--red); }
.badge-bonus { background: var(--green-light); color: var(--green); }
.badge-advance { background: var(--orange-light); color: var(--orange); }
.badge-envelope { background: var(--blue-light); color: var(--blue); }

/* ── Мгновенный тултип (без задержки нативного title) ── */
.tooltip-wrap { position: relative; cursor: default; }
.tooltip-wrap .tooltip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  width: max-content;
  max-width: min(220px, 70vw);
  white-space: normal;
  z-index: 200;
  box-shadow: var(--shadow);
}
.tooltip-wrap:hover .tooltip-text { display: block; }

/* ── Alerts ── */
.alert {
  padding: 11px 15px; border-radius: var(--radius);
  margin-bottom: 14px; font-size: 14px;
}
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.alert-info { background: var(--blue-light); color: var(--blue); border: 1px solid #bfdbfe; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 9px 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted);
  border-bottom: 2px solid var(--border); white-space: nowrap;
  background: #f8fafc;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.table-compact td { padding: 8px 12px; }
tr.row-expanded td { background: var(--blue-light); }

/* ── Tabs ── */
.tabs {
  display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 10px 22px; cursor: pointer; font-weight: 500; font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s; user-select: none;
  flex-shrink: 0; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ── Collections ── */
.coll-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px;
}
.coll-row:last-child { border: none; }

/* ── Salary расчетный лист ── */
.salary-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden;
  background: white;
  transition: box-shadow .15s, border-color .15s;
}
.salary-card-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-light), var(--shadow);
}
.salary-card-head {
  padding: 14px 18px; display: flex;
  justify-content: space-between; align-items: center;
  cursor: pointer; transition: background .15s;
}
.salary-card-head:hover { background: #f8fafc; }
.salary-card-active .salary-card-head { background: var(--blue-light); }
.salary-name { font-weight: 700; font-size: 16px; }
.salary-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.salary-total-big { font-size: 24px; font-weight: 800; color: var(--green); }

.salary-body { border-top: 1px solid var(--border); }
.salary-cols { display: grid; grid-template-columns: 1fr 1fr; }
.salary-col { padding: 14px 18px; display: flex; flex-direction: column; }
.salary-col + .salary-col { border-left: 1px solid var(--border); }
.salary-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted); margin-bottom: 10px;
}
.salary-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.salary-line-total {
  display: flex; justify-content: space-between; padding: 8px 0 5px;
  font-size: 15px; font-weight: 700;
  border-top: 2px solid var(--border); margin-top: 4px;
}
.salary-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.salary-amount-pos { color: var(--green); }
.salary-amount-neg { color: var(--red); }

.salary-shifts { padding: 14px 18px; border-top: 1px solid var(--border); }
.salary-shifts table th { padding: 5px 10px; }
.salary-shifts table td { padding: 2px 10px; }

.table-tight table th { padding: 4px 8px; }
.table-tight table td { padding: 4px 8px; line-height: 1.3; }

.dds-table-compact table { width: auto; min-width: 100%; }
.dds-table-compact table th, .dds-table-compact table td { white-space: nowrap; }
.dds-table-compact table th { padding: 4px 8px; }
.dds-table-compact table td { padding: 4px 8px; line-height: 1.6; }
.dds-table-compact table th:first-child,
.dds-table-compact table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--white);
  border-right: 1px solid var(--border);
}
.dds-table-compact table th:not(:first-child),
.dds-table-compact table td:not(:first-child) {
  border-left: 1px solid var(--border);
}

.mobile-cards .dds-table-compact table th:first-child,
.mobile-cards .dds-table-compact table td:first-child {
  white-space: normal;
  max-width: 120px;
}

/* ── Filters ── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: flex-end; margin-bottom: 16px;
  padding: 14px 18px; background: white;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-bar .form-group { margin: 0; }
.filter-bar .form-input { font-size: 14px; padding: 8px 10px; min-width: 130px; }
.filter-bar .form-label { font-size: 10px; }

/* ── Spinner ── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: white;
  border-radius: 50%; animation: spin .6s linear infinite; flex-shrink: 0;
}
.spinner-dark { border-color: var(--border); border-top-color: var(--blue); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading overlay ── */
.loading-center { text-align: center; padding: 48px 0; }

/* ── Amount formatting ── */
.amount { font-variant-numeric: tabular-nums; }
.amount-pos { color: var(--green); font-weight: 600; }
.amount-neg { color: var(--red); font-weight: 600; }

/* ── Expanded shift detail in admin ── */
.shift-detail {
  background: var(--blue-light);
  padding: 14px 18px;
  border-top: 1px solid #bfdbfe;
}

/* ── Mobile shift cards (admin journal) ── */
.mobile-cards { display: none; }
.mobile-shift-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .mobile-cards  { display: block; }
  .desktop-only  { display: none !important; }
  .filter-bar    { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .header-inner  { flex-wrap: wrap; gap: 8px; }
  .header-right  { flex-wrap: wrap; justify-content: flex-start; gap: 8px 10px; }
  .header-brand  { font-size: 15px; }
}

@media (max-width: 640px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .date-big { font-size: 22px; }
  .salary-cols { grid-template-columns: 1fr; }
  .salary-col + .salary-col { border-left: none; border-top: 1px solid var(--border); }
  th, td { padding: 8px 8px; }
  .tab { padding: 9px 14px; font-size: 13px; }
}
