:root {
    --red: #d10000;
    --red-dark: #a30000;
    --bg: #f9f9f9;
    --card: #fff;
    --border: #e9e9e9;
    --text: #1a1a1a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Poppins", "Montserrat", system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.container {
    width: 95%;
    max-width: 980px;
    background: var(--card);
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
    padding: 24px;
}

h1 {
    color: var(--red);
    text-align: center;
    margin: 0 0 20px;
    font-weight: 800;
}

form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 18px;
}

form .full {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

input[type="text"],
input[type="date"],
input[type="number"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    font-size: 14px;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.btn {
    background: var(--red);
    color: #fff;
    border: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: .2s;
}

.btn:hover {
    background: var(--red-dark);
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    background: #fff;
}

.nav {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
}

.nav .tab {
    background: #eee;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
}

.nav .active {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}

.table th,
.table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    font-size: 14px;
}

.table th {
    background: #fafafa;
    font-weight: 800;
}

.list .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.list .item:last-child {
    border-bottom: none;
}

@media (max-width: 720px) {
    form {
        grid-template-columns: 1fr;
    }
}

/* ====== LOGIN PAGE BEAUTY ====== */
.login-body {
    --red: #d10000;
    --red-dark: #a30000;
    --yellow: #ffd500;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(209, 0, 0, 0.10), transparent),
        radial-gradient(900px 500px at 110% 10%, rgba(255, 213, 0, 0.15), transparent),
        linear-gradient(180deg, #f9f9f9, #f1f1f1);
    min-height: 100dvh;
    margin: 0;
    background: var(--bg-grad);
    display: grid;
    place-items: center;
    color: #1a1a1a;
    font-family: "Poppins", "Montserrat", system-ui, -apple-system, Arial, sans-serif;
}

.login-wrap {
    width: 95%;
    max-width: 900px;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 24px;
    align-items: center;
}

.brand {
    padding: 24px;
    border-radius: 16px;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid #ececec;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .06);
}

.brand-title {
    text-align: left;
    font-weight: 900;
    font-size: clamp(48px, 8vw, 80px);
    letter-spacing: 2px;
    color: var(--red);
    line-height: .9;
}

.brand-bar {
    height: 6px;
    width: clamp(180px, 40%, 280px);
    background: var(--yellow);
    margin-top: 8px;
    border-radius: 999px;
}

.brand-sub {
    margin-top: 10px;
    font-weight: 700;
    opacity: .85;
}

.login-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .08);
    transition: transform .15s ease, box-shadow .2s ease;
}

.login-card h1 {
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .2px;
}

.login-card .login-meta {
    margin-top: 12px;
}

.login-card .hint {
    font-size: 12px;
    opacity: .7;
}

.login-card.shake {
    animation: shake .3s ease-in-out;
}

@keyframes shake {

    10%,
    90% {
        transform: translateX(-2px);
    }

    20%,
    80% {
        transform: translateX(4px);
    }

    30%,
    70% {
        transform: translateX(-6px);
    }

    40%,
    60% {
        transform: translateX(6px);
    }

    50% {
        transform: translateX(0);
    }
}

.login-form {
    display: grid;
    gap: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon input {
    width: 100%;
    padding: 12px 44px 12px 14px;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
    background: #fff;
}

.input-with-icon input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 4px rgba(209, 0, 0, .08);
}

.toggle-pass {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    outline: none;
    display: grid;
    place-items: center;
    cursor: pointer;
    background: #f6f6f6;
    transition: background .2s;
}

.toggle-pass:hover {
    background: #eee;
}

.icon-eye {
    width: 20px;
    height: 20px;
    fill: #666;
}

.caps-warning {
    margin-top: 6px;
    font-size: 12px;
    color: #b00000;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.caps-warning::before {
    content: "⇪";
    font-weight: 900;
}

.error-box {
    background: #ffe8e8;
    border: 1px solid #ffcdcd;
    color: #a10000;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 700;
}

.btn-primary {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    transition: background .2s, transform .06s;
}

.btn-primary:hover {
    background: var(--red-dark);
}

.btn-primary:active {
    transform: translateY(1px);
}

.login-footer {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 10px;
    font-size: 12px;
    opacity: .7;
}

@media (max-width: 860px) {
    .login-wrap {
        grid-template-columns: 1fr;
    }

    .brand {
        order: -1;
        text-align: center;
    }

    .brand-title {
        text-align: center;
    }

    .brand-bar {
        margin-left: auto;
        margin-right: auto;
    }
}

.login-wrap {
  grid-template-columns: repeat(2, 1fr);
  align-items: stretch;
}

.brand,
.login-card {
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.login-card .login-form {
  overflow: auto;
}

@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .brand,
  .login-card { aspect-ratio: auto; }
}

/* === Fancy select: płatność / VAT === */
select[name="platnosc"],
select[name="vat"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  width: 100%;
  padding: 10px 44px 10px 12px;      /* miejsce na strzałkę po prawej */
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: #fff;

  /* Własna strzałka (SVG inline) */
  background-image:
    url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'>\
<path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;

  font-size: 14px;
  color: #1a1a1a;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
  cursor: pointer;
}

/* Hover */
select[name="platnosc"]:hover,
select[name="vat"]:hover {
  border-color: #ddd;
  background-color: #fcfcfc;
}

/* Focus (akcent czerwony) */
select[name="platnosc"]:focus,
select[name="vat"]:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(209,0,0,.10);
}

/* Disabled */
select[name="platnosc"]:disabled,
select[name="vat"]:disabled {
  cursor: not-allowed;
  background-color: #f5f5f5;
  color: #999;
}

/* Dla bardzo wąskich ekranów: zapewnij dotykowy komfort */
@media (max-width: 480px) {
  select[name="platnosc"],
  select[name="vat"] {
    font-size: 16px;  /* unika zoomu na iOS */
    padding: 12px 44px 12px 12px;
  }
}

/* IE/legacy (ukrycie natywnej strzałki) */
select[name="platnosc"]::-ms-expand,
select[name="vat"]::-ms-expand { display: none; }

/* === Fancy radio (np. dla odbiorca_typ) === */
/* działa z istniejącym HTML: <label><input type="radio" name="odbiorca_typ"> Tekst</label> */
.row label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 32px;                 /* miejsce na kółko */
  cursor: pointer;
  user-select: none;
}

/* ukryj natywny wygląd guzika, ale pozostaw fokus/klikalność */
.row label input[type="radio"][name="odbiorca_typ"] {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  width: 20px;
  height: 20px;
  margin: 0;
}

/* kółko zewnętrzne */
.row label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--border);
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

/* kropka wewnętrzna (gdy zaznaczone) */
.row label::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  transform: translateY(-50%) scale(0);
  transition: transform .15s ease;
}

/* stan :checked */
.row label:has(input[type="radio"][name="odbiorca_typ"]:checked)::before {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(209,0,0,.10);
}
.row label:has(input[type="radio"][name="odbiorca_typ"]:checked)::after {
  transform: translateY(-50%) scale(1);
}

/* hover/focus/disabled */
.row label:hover::before {
  border-color: #d5d5d5;
}
.row label:has(input[type="radio"][name="odbiorca_typ"]:focus-visible)::before {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.row label:has(input[type="radio"][name="odbiorca_typ"]:disabled) {
  cursor: not-allowed;
  opacity: .6;
}

/* większy komfort na mobile */
@media (max-width: 480px) {
  .row label { padding-left: 36px; }
  .row label::before { width: 22px; height: 22px; }
  .row label::after { left: 6px; width: 10px; height: 10px; }
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    vertical-align: middle;
}

.badge--oczekuje {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.badge--opłacona {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.badge--przeterminowana {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

input.readonly {
    background: #f9f9f9;
    color: #888;
}

/* === Fancy select: Status płatności === */
select[name="status"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    width: 100%;
    padding: 10px 44px 10px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background-color: #fff;

    /* strzałka */
    background-image:
        url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'>\
<path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px 18px;

    font-size: 14px;
    color: #1a1a1a;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
    cursor: pointer;
}

select[name="status"]:hover {
    border-color: #ddd;
    background-color: #fcfcfc;
}

select[name="status"]:focus {
    outline: none;
    border-color: #d10000;
    box-shadow: 0 0 0 4px rgba(209, 0, 0, .10);
}

select[name="status"]:disabled {
    cursor: not-allowed;
    background-color: #f5f5f5;
    color: #999;
}

/* Kolorystyka wg statusu (klasy nadawane JS-em) */
select[name="status"].is-oczekuje {
    background-color: #fff8e1;
    /* jasny żółty */
    border-color: #ffe199;
}

select[name="status"].is-opłacona {
    background-color: #eaf7ee;
    /* jasny zielony */
    border-color: #bfe6c9;
}

select[name="status"].is-przeterminowana {
    background-color: #fdecec;
    /* jasny czerwony */
    border-color: #f5bcbc;
}

/* Mobile komfort */
@media (max-width: 480px) {
    select[name="status"] {
        font-size: 16px;
        padding: 12px 44px 12px 12px;
    }
}