/* Kyosun brand — fialová #522583, zelená #8D9968 */
:root {
  --purple: #522583;
  --purple-dark: #3D1B62;
  --purple-light: #A684C4;
  --purple-lighter: #E9DDF3;
  --purple-bg: #F7F2FB;
  --green: #8D9968;
  --green-light: #C2CAA7;
  --green-bg: #F4F6EC;
  --gray: #555;
  --gray-light: #999;
  --border: #E0DAE8;
  --bg: #FAFAFC;
  --white: #FFFFFF;
  --shadow: 0 2px 8px rgba(82, 37, 131, 0.08);
  --shadow-lg: 0 8px 32px rgba(82, 37, 131, 0.12);
}

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

html {
  font-size: 16px;
}

body {
  font-family: 'Quicksand', 'Aller', -apple-system, BlinkMacSystemFont,
    'Segoe UI', sans-serif;
  color: #222;
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== LOGIN PAGE ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card img.logo {
  width: 120px;
  height: auto;
  margin-bottom: 1.5rem;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 0.3rem;
}

.login-card p.sub {
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.login-card label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 0.3rem;
  display: block;
}

.login-card input[type="email"],
.login-card input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
}

.login-card input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-lighter);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--purple);
  color: white;
  box-shadow: 0 2px 6px rgba(82, 37, 131, 0.25);
}

.btn-primary:hover {
  background: var(--purple-dark);
  box-shadow: 0 4px 12px rgba(82, 37, 131, 0.3);
}

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

.btn-secondary {
  background: var(--green);
  color: white;
}

.btn-secondary:hover {
  background: #74804F;
}

.btn-ghost {
  background: transparent;
  color: var(--purple);
  border: 1.5px solid var(--purple);
}

.btn-ghost:hover {
  background: var(--purple-lighter);
}

.error {
  background: #FEE;
  color: #C33;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* ===== APP LAYOUT ===== */
.topbar {
  background: white;
  border-bottom: 3px solid var(--purple);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar .brand img {
  width: 48px;
  height: auto;
}

.topbar .brand-text {
  display: flex;
  flex-direction: column;
}

.topbar .brand-text strong {
  color: var(--purple);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar .brand-text span {
  color: var(--gray);
  font-size: 0.8rem;
}

.topbar .user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--gray);
}

.topbar .user a {
  color: var(--purple);
  text-decoration: none;
  font-weight: 600;
}

.topbar .user a:hover {
  text-decoration: underline;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

h1.page-title {
  color: var(--purple);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

p.lead {
  color: var(--gray);
  margin-bottom: 2rem;
}

/* ===== UPLOAD ===== */
.upload-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.dropzone {
  border: 2.5px dashed var(--purple-light);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--purple-bg);
}

.dropzone:hover, .dropzone.dragover {
  background: var(--purple-lighter);
  border-color: var(--purple);
  border-style: solid;
}

.dropzone .upload-icon {
  font-size: 3rem;
  color: var(--purple);
  margin-bottom: 0.5rem;
}

.dropzone h3 {
  color: var(--purple);
  margin-bottom: 0.3rem;
  font-weight: 700;
}

.dropzone p {
  color: var(--gray);
  font-size: 0.9rem;
}

.dropzone input[type="file"] {
  display: none;
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.dropzone.has-file {
  background: var(--green-bg);
  border-color: var(--green);
  border-style: solid;
}

.dropzone.has-file h3 {
  color: var(--green);
}

/* ===== PROGRESS / STATUS ===== */
.status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.status.info {
  background: var(--purple-bg);
  color: var(--purple-dark);
}

.status.error {
  background: #FEE;
  color: #C33;
}

.status.success {
  background: var(--green-bg);
  color: #4A5534;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--purple-lighter);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

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

/* ===== RESULTS ===== */
.results-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.results-header h2 {
  color: var(--purple);
  font-size: 1.3rem;
  margin-bottom: 0.2rem;
}

.results-meta {
  color: var(--gray);
  font-size: 0.85rem;
}

.results-actions {
  display: flex;
  gap: 0.5rem;
}

table.results {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
}

table.results thead th {
  background: var(--purple);
  color: white;
  font-weight: 700;
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  letter-spacing: 0.3px;
}

table.results thead th:first-child { border-top-left-radius: 10px; }
table.results thead th:last-child { border-top-right-radius: 10px; }

table.results thead th.num {
  text-align: right;
}

table.results tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

table.results tbody tr:nth-child(even) {
  background: var(--purple-bg);
}

table.results tbody tr:hover {
  background: var(--purple-lighter);
}

table.results tbody td.code {
  font-weight: 700;
  color: var(--purple);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

table.results tbody td.batch {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  color: var(--gray);
}

table.results tbody td.qty {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

table.results tbody td.unit {
  color: var(--gray);
  font-size: 0.85rem;
}

.results-summary {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--green-bg);
  border-radius: 10px;
  color: #4A5534;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ===== MANUÁLNÍ POŽADAVKY ===== */
.section-divider {
  display: flex;
  align-items: center;
  margin: 3rem 0 2rem;
  color: var(--gray-light);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-divider span {
  padding: 0 1.25rem;
}

.manual-section h2.page-title {
  font-size: 1.4rem;
  color: var(--purple);
  margin-bottom: 0.25rem;
}

.manual-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.manual-form .form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-field-wide {
  grid-column: span 2;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray);
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-field textarea {
  resize: vertical;
  min-height: 50px;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-lighter);
}

.input-with-unit {
  display: flex;
  gap: 0.5rem;
}

.input-with-unit input {
  flex: 1;
}

.input-with-unit select {
  width: 80px;
  flex-shrink: 0;
}

.yield-display-field .yield-display {
  background: var(--green-bg);
  border: 1.5px solid var(--green-light);
  border-radius: 9px;
  padding: 0.65rem 0.85rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #4A5534;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-height: 44px;
}

.yield-display .yield-num {
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  color: var(--purple);
}

.yield-display .yield-unit-label {
  font-size: 0.95rem;
  color: var(--gray);
  font-weight: 500;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

#manualStatus {
  margin-top: 1rem;
}

/* ===== HISTORIE ===== */
.manual-history {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.history-header h3 {
  color: var(--purple);
  font-size: 1.15rem;
  font-weight: 700;
}

.history-count {
  background: var(--purple-lighter);
  color: var(--purple);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.history-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--gray-light);
  font-size: 0.95rem;
  background: var(--bg);
  border-radius: 10px;
}

.history-table .batch-sub {
  font-size: 0.78rem;
  color: var(--gray-light);
  margin-top: 2px;
}

.history-table .meta-cell {
  font-size: 0.85rem;
  color: var(--gray);
}

.history-table .unit-small {
  font-weight: 500;
  color: var(--gray);
  font-size: 0.8rem;
}

.history-table .actions-cell {
  white-space: nowrap;
  text-align: right;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  margin-left: 0.25rem;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--purple-lighter);
  border-color: var(--purple);
}

.icon-btn-danger:hover {
  background: #FEE;
  border-color: #C33;
}

.icon-btn-success:hover {
  background: var(--green-bg);
  border-color: var(--green);
}

.icon-btn-warn:hover {
  background: #FFF4D6;
  border-color: #D89B00;
}

/* ===== BADGE + STAV ===== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-open {
  background: #FFF4D6;
  color: #8A5A00;
  border: 1px solid #F0D68C;
}

.badge-completed {
  background: var(--green);
  color: white;
}

/* Splněné řádky — tlumené, ne přeškrtnuté */
.history-table tr.row-completed td {
  background: var(--green-bg) !important;
  color: #6B7A52;
}

.history-table tr.row-completed td.code {
  color: #7A8564;
}

.history-table tr.row-completed td.qty {
  color: #6B7A52;
}

.history-table tr.row-completed:hover td {
  background: #E8EEDC !important;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  main { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; }
  .topbar .brand-text span { display: none; }
  .upload-card, .results-card, .manual-card, .manual-history { padding: 1.25rem; }
  .results-actions { width: 100%; }
  .results-actions .btn { flex: 1; }
  h1.page-title { font-size: 1.4rem; }
  table.results { font-size: 0.85rem; }
  table.results thead th, table.results tbody td { padding: 0.5rem 0.6rem; }
  .manual-form .form-grid { grid-template-columns: 1fr; }
  .form-field-wide { grid-column: span 1; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .history-table .actions-cell { text-align: left; }
}

/* ===== PRINT ===== */
@media print {
  body { background: white; }
  .topbar, .upload-card, .results-actions, .status,
  .manual-section, .section-divider { display: none !important; }
  main { max-width: none; padding: 0; }
  .results-card { box-shadow: none; padding: 0; border-radius: 0; }
  table.results thead th { background: var(--purple) !important; color: white !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.results tbody tr:nth-child(even) { background: #F0E6F5 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
