:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-soft: #f9fbfd;
  --line: #dfe5ee;
  --text: #172033;
  --muted: #6a7487;
  --accent: #db0814;
  --accent-dark: #ab0610;
  --accent-soft: #fff0f1;
  --brand: #121a29;
  --brand-dark: #0b1020;
  --brand-soft: #f4f6fa;
  --danger: #c2410c;
  --success: #0f766e;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --work: #e7f7ed;
  --off: #f8e9e9;
  --shadow: 0 14px 32px rgba(26, 32, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Arial, Helvetica, sans-serif;
}

html {
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 36px;
  padding: 7px 13px;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 14px rgba(23, 32, 51, 0.08);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-dark);
}

button.danger {
  background: #fff7ed;
  border-color: #fed7aa;
  color: var(--danger);
}

button.danger:hover {
  border-color: var(--danger);
  background: #ffedd5;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 36px;
  padding: 7px 10px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(219, 8, 20, 0.5);
  box-shadow: 0 0 0 3px rgba(219, 8, 20, 0.08);
  outline: none;
}

textarea {
  resize: vertical;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.period-panel {
  display: grid;
  grid-template-columns: 96px 150px 96px 86px 68px 76px 68px;
  gap: 8px;
  align-items: end;
  min-width: 708px;
}

.period-panel label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.nav-link,
.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  color: var(--muted);
  text-decoration: none;
}

.nav-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.nav-link:hover,
.logout-link:hover {
  color: var(--accent);
}

.vat-nav {
  display: grid;
  grid-template-columns: 100px 76px 68px;
  gap: 8px;
  align-items: end;
  justify-self: end;
}

.admin-nav {
  grid-template-columns: 100px 76px 68px;
}

.auth-page {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 28%, rgba(219, 8, 20, 0.08) 0 1px, transparent 1px 68px),
    radial-gradient(circle at 17% 24%, transparent 0 120px, rgba(219, 8, 20, 0.08) 121px 122px, transparent 123px 185px, rgba(219, 8, 20, 0.06) 186px 187px, transparent 188px 250px),
    #fef9f9;
  color: #121a29;
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(460px, 760px) minmax(420px, 570px);
  gap: clamp(48px, 7vw, 100px);
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 5vw, 80px);
}

.auth-marketing {
  position: relative;
  min-height: 820px;
  display: grid;
  justify-items: center;
  align-content: start;
  text-align: center;
  overflow: hidden;
}

.auth-rings {
  position: absolute;
  top: -122px;
  left: 50%;
  width: 740px;
  height: 740px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 55px, rgba(219, 8, 20, 0.09) 56px 57px, transparent 58px 108px);
}

.auth-logo-large {
  position: relative;
  z-index: 1;
  width: 120px;
  height: 120px;
  display: grid;
  place-items: center;
  margin-top: 4px;
  border-radius: 22px;
  background: linear-gradient(180deg, #db0814, #99030a);
  box-shadow: 0 18px 28px rgba(128, 0, 8, 0.28);
  color: #fff;
  font-size: 48px;
  line-height: 1;
}

.auth-marketing h1 {
  position: relative;
  z-index: 1;
  margin: 28px 0 8px;
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.12;
}

.auth-marketing p {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0;
  color: #616b80;
  font-size: 20px;
  line-height: 1.45;
}

.auth-features {
  position: relative;
  z-index: 1;
  width: min(100%, 716px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.auth-features div {
  min-height: 106px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 7px;
  padding: 14px 10px;
  border: 1px solid #e0e3eb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(26, 26, 38, 0.07);
}

.auth-features b {
  color: #db0814;
  font-size: 24px;
  line-height: 1;
}

.auth-features strong {
  font-size: 13px;
}

.auth-features span {
  color: #616b80;
  font-size: 11px;
  line-height: 1.45;
}

.auth-illustration {
  position: relative;
  z-index: 1;
  width: min(520px, 82%);
  margin-top: 32px;
}

.auth-secure {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  color: #8c94a3;
  font-size: 13px;
}

.auth-card {
  position: relative;
  z-index: 2;
  width: min(570px, 100%);
  min-height: 720px;
  display: block;
  background: #fff;
  border: 1px solid rgba(224, 227, 235, 0.28);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 38px rgba(20, 20, 31, 0.1);
}

.auth-form-panel {
  min-height: 720px;
  padding: clamp(34px, 5vw, 55px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-card h2 {
  margin: 0 0 10px;
  color: #121a29;
  font-size: 34px;
  line-height: 1.18;
  text-align: center;
}

.auth-card p {
  max-width: 340px;
  margin: 0 auto 32px;
  color: #616b80;
  line-height: 1.45;
  text-align: center;
}

.auth-form {
  display: grid;
  gap: 20px;
}

.auth-form button.primary {
  min-height: 58px;
  margin-top: 8px;
  border-radius: 12px;
  background: linear-gradient(180deg, #db0814, #b8030a);
  border-color: #db0814;
  font-size: 18px;
  font-weight: 700;
}

.auth-form button.primary:hover {
  filter: brightness(0.95);
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: #121a29;
  font-size: 13px;
  font-weight: 700;
}

.auth-form input:not([type="checkbox"]) {
  min-height: 56px;
  border: 1px solid #e0e3eb;
  border-radius: 12px;
  color: #121a29;
}

.auth-form input::placeholder {
  color: #8c919e;
}

.auth-form small {
  color: #8c94a3;
  font-weight: 400;
}

.auth-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

.auth-remember {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  color: #121a29 !important;
  font-weight: 400 !important;
}

.auth-remember input {
  width: 18px;
  height: 18px;
  accent-color: #db0814;
}

.auth-muted-link {
  color: #db0814;
  font-size: 13px;
  font-weight: 700;
}

.auth-error {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.auth-message {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.auth-link {
  color: #db0814;
  font-weight: 700;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-switch {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 34px;
  padding-top: 30px;
  border-top: 1px solid #e0e3eb;
  color: #616b80;
  font-size: 15px;
}

.auth-terms {
  margin: 34px auto 0 !important;
  color: #999eab !important;
  font-size: 12px;
  line-height: 1.5 !important;
}

.app-body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, #fafbfe 0, var(--bg) 280px);
  background-color: var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 22px 16px;
  background: #111827;
  color: #fff;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
}

.brand-block span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  font-weight: 800;
}

.brand-block strong {
  font-size: 17px;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.side-nav a,
.side-logout {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 9px;
  color: #cbd5e1;
  text-decoration: none;
}

.side-nav a:hover,
.side-nav a.active,
.side-logout:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.side-nav a.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.app-main {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 34px) 34px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 2px 0 0;
  color: var(--brand);
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.page-actions,
.period-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: end;
}

.period-panel {
  min-width: 0;
}

.period-panel label {
  width: 120px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.05);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  color: var(--brand);
  font-size: 25px;
  line-height: 1;
}

.metric-card.accent {
  border-color: #ffd2d6;
  background: var(--accent-soft);
}

.metric-card.success {
  border-color: #b7eadf;
  background: var(--success-soft);
}

.metric-card.warning {
  border-color: #fde68a;
  background: var(--warning-soft);
}

.profile-summary .metric-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 18px;
  min-width: 0;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.profile-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.profile-form .wide {
  grid-column: 1 / -1;
}

#profileStatus,
#passwordStatus {
  color: var(--success);
}

#profileStatus.error,
#passwordStatus.error {
  color: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.sidebar,
.workspace {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.05);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
  color: var(--brand);
  font-size: 17px;
}

.section-title span {
  color: var(--muted);
}

.stacked {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.stacked label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.vat-upload {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 120px 90px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.vat-status {
  min-height: 20px;
  margin: -4px 0 12px;
  color: var(--muted);
}

.vat-status.error {
  color: var(--danger);
}

.vat-page {
  display: grid;
  gap: 16px;
  padding: 0;
  min-width: 0;
}

.vat-client-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.vat-client-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.vat-client-grid .wide {
  grid-column: span 2;
}

.vat-client-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-self: end;
}

.vat-period-grid,
.vat-history-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.vat-history-filters {
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(110px, 1fr)) auto auto;
}

.vat-period-grid label,
.vat-history-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.vat-source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.vat-subject {
  display: grid;
  gap: 6px;
  max-width: 520px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.vat-subject span {
  font-weight: 700;
  color: var(--text);
}

.file-panel {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 112px;
  align-content: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.file-panel:hover {
  border-color: rgba(219, 8, 20, 0.45);
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.06);
}

.file-panel span {
  font-weight: 700;
}

.file-panel small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.file-panel input {
  border-style: dashed;
  background: #fff;
}

.vat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.vat-warnings {
  display: grid;
  gap: 6px;
}

.vat-warnings div {
  padding: 8px 10px;
  border: 1px solid #f1d29a;
  border-radius: 8px;
  background: #fff8e8;
  color: #8a5a12;
}

.cell-input {
  width: 130px;
  min-width: 0;
  text-align: right;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: #374151;
  font-weight: 700;
  text-align: left;
}

tbody tr:hover {
  background: #fbfcff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: right;
  white-space: nowrap;
}

td.center,
th.center {
  text-align: center;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.total td,
tr.total {
  background: #eef5ff;
  font-weight: 700;
}

#employeesTable input {
  min-width: 92px;
}

#employeesTable input[name="full_name"] {
  min-width: 180px;
}

#employeesTable input[type="checkbox"] {
  width: 22px;
  min-width: 22px;
}

.actions {
  white-space: nowrap;
}

.actions button {
  width: 32px;
  padding: 0;
  margin-left: 4px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(64px, 1fr));
  gap: 8px;
}

.day {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 8px;
  border-color: transparent;
  text-align: left;
}

.day span {
  font-size: 12px;
  color: var(--muted);
}

.day b {
  font-size: 16px;
}

.day.work {
  background: var(--work);
}

.day.off {
  background: var(--off);
}

.day.manual {
  outline: 2px solid #f59e0b;
}

.print-page {
  background: #fff;
}

.print-page main {
  max-width: 1180px;
  margin: 0 auto;
}

.sheet {
  padding: 22px;
  page-break-after: always;
}

.sheet h1 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 20px;
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.sheet p {
  margin: 6px 0 12px;
}

.sheet table {
  border-collapse: collapse;
  margin-top: 10px;
}

.sheet th,
.sheet td {
  border: 1px solid #111827;
  border-color: #111827;
  padding: 5px 6px;
}

.sheet .tiny {
  font-size: 11px;
}

.sheet .tiny th,
.sheet .tiny td {
  padding: 3px 4px;
}

.statement-table {
  width: 100%;
  table-layout: fixed;
  font-size: 10px;
}

.statement-table th,
.statement-table td {
  padding: 3px 4px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.statement-table .st-no {
  width: 4%;
}

.statement-table .st-tab {
  width: 6%;
}

.statement-table .st-position {
  width: 13%;
}

.statement-table .st-money {
  width: 10%;
}

.statement-table .st-days {
  width: 7%;
}

.statement-table .st-receipt {
  width: 30%;
}

.center {
  text-align: center;
}

.line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0;
}

.payslip {
  break-inside: avoid;
  margin-bottom: 24px;
}

.form-code {
  text-align: right;
  font-size: 12px;
}

.signature {
  display: flex;
  justify-content: flex-end;
  gap: 80px;
  margin-top: 32px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
    padding: 14px;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .side-nav a,
  .side-logout {
    justify-content: center;
  }

  .app-main {
    padding: 18px 14px 24px;
  }

  .page-header,
  .layout,
  .profile-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .page-actions,
  .period-panel {
    justify-content: stretch;
  }

  .period-panel label,
  .period-panel button,
  .page-actions button {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vat-nav,
  .vat-source-grid,
  .vat-client-grid,
  .vat-period-grid,
  .vat-history-filters {
    grid-template-columns: 1fr;
    justify-self: stretch;
  }

  .vat-client-grid .wide {
    grid-column: auto;
  }

  .calendar-grid {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
  }

  .auth-card {
    width: min(570px, 100%);
    min-height: 0;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px;
  }

  .auth-marketing {
    min-height: auto;
    padding-top: 8px;
  }

  .auth-logo-large {
    width: 92px;
    height: 92px;
    border-radius: 18px;
    font-size: 38px;
  }

  .auth-marketing h1 {
    margin-top: 18px;
  }

  .auth-marketing p {
    font-size: 16px;
  }

  .auth-features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-illustration {
    width: min(380px, 78vw);
    margin-top: 20px;
  }

  .auth-form-panel {
    min-height: 0;
    padding: 26px;
  }
}

@media (max-width: 620px) {
  .side-nav {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .vat-source-grid,
  .vat-client-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  .vat-client-actions {
    grid-template-columns: 1fr;
  }

  .profile-form {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
    font-size: 11px;
  }

  .print-page main {
    max-width: none;
    width: 100%;
  }

  .sheet {
    padding: 0;
  }

  .sheet.wide {
    overflow: visible;
  }

  .statement-table {
    font-size: 8.5px;
  }

  .statement-table th,
  .statement-table td {
    padding: 2px 3px;
  }

  .wide {
    page: landscape;
  }

  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  @page landscape {
    size: A4 landscape;
    margin: 8mm;
  }
}
