:root {
  --accent: #1d6f5c;
  --accent-dark: #155a49;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e3e3e0;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --danger: #b3402f;
  --radius: 14px;
  --max-width: 780px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
}

button,
input {
  font-family: inherit;
  font-size: 1rem;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* -------- Header -------- */

.app-header {
  padding-top: 8px;
}

.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.status-dot {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eee;
  color: var(--text-muted);
}
.status-dot.online {
  background: #e5f3ef;
  color: var(--accent-dark);
}
.status-dot.offline {
  background: #fbeeee;
  color: var(--danger);
}

.lang-switch {
  display: flex;
  gap: 6px;
}
.lang-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.app-title {
  font-size: 1.7rem;
  font-weight: 700;
  text-align: center;
  margin: 4px 0 12px;
}

.role-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}
.role-badge {
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: #eee;
  color: var(--text-muted);
}
.role-badge.admin {
  background: #fff2df;
  color: #8a5a00;
}

/* -------- Nav -------- */

.app-nav {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.nav-btn {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  white-space: nowrap;
}
@media (max-width: 420px) {
  .nav-btn {
    padding: 8px 8px;
    font-size: 0.82rem;
  }
}
.nav-btn.active {
  color: var(--accent-dark);
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
}
.nav-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 1px 7px;
}

/* -------- Search -------- */

.search-wrap {
  margin: 8px 0 20px;
}
.search-input {
  width: 100%;
  padding: 18px 20px;
  font-size: 1.25rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-height: 60px;
}
.search-input:focus {
  outline: 3px solid #cfe8e0;
}
.search-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 8px;
  text-align: center;
}

.results-count {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.list-export-bar {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.hide-name-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hide-name-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 320px;
}
.hide-name-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.hide-name-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* -------- Cards -------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-field {
  margin-bottom: 14px;
}
.card-field:last-of-type {
  margin-bottom: 0;
}
.field-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.field-value {
  font-size: 1.15rem;
  font-weight: 600;
}
.supplier-name {
  font-size: 1.35rem;
  font-weight: 700;
}

.codes-list,
.brands-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.code-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: #eef6f4;
  border: 1px solid #d7ebe5;
  color: var(--accent-dark);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 1.15rem;
}
.code-chip-city {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.brand-chip {
  background: #f1f1ee;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* -------- Buttons -------- */

.btn {
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
  border: 2px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
}
.btn-secondary {
  background: #eee;
  color: var(--text);
}
.btn-outline {
  background: var(--surface);
  color: var(--accent-dark);
  border-color: var(--accent);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-link {
  background: transparent;
  color: var(--accent-dark);
  border: none;
  text-decoration: underline;
  padding: 8px 4px;
  min-height: auto;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: 8px;
}
.icon-btn:hover {
  background: #eee;
}

/* -------- Empty state -------- */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
}
.empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.empty-hint {
  margin-top: 6px;
}

/* -------- Forms -------- */

.view-title {
  font-size: 1.3rem;
  margin: 6px 0 16px;
}
.section-title {
  font-size: 1.05rem;
  margin: 22px 0 10px;
}

.form-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.actor-name-field {
  margin-bottom: 16px;
}

.name-hidden-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -6px;
  margin-bottom: 8px;
}

.form-label {
  display: block;
  font-weight: 700;
  margin: 16px 0 8px;
}
.form-label:first-child {
  margin-top: 0;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  min-height: 46px;
}
.input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.dynamic-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.dynamic-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.dynamic-row .input {
  flex: 1;
}
.input-code {
  flex: 0 0 40% !important;
}

.form-error {
  color: var(--danger);
  font-weight: 600;
  margin-top: 10px;
}

.form-actions {
  margin-top: 20px;
}
.form-actions .btn {
  width: 100%;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.hidden-file-input {
  display: none;
}

/* -------- Review / diff -------- */

.request-card {
  position: relative;
}
.request-type-badge {
  display: inline-block;
  background: #eef6f4;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.request-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.diff-table {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.diff-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.diff-label {
  font-weight: 700;
  margin-bottom: 6px;
}
.diff-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.diff-old,
.diff-new {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.diff-old {
  color: var(--text-muted);
  text-decoration: line-through;
}
.diff-new {
  color: var(--accent-dark);
  font-weight: 600;
}
.diff-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  background: #eee;
  border-radius: 6px;
  padding: 1px 6px;
}
.diff-empty {
  color: var(--text-muted);
}

/* -------- Modal / toast -------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  z-index: 1000;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: var(--surface);
  width: 100%;
  max-width: var(--max-width);
  border-radius: 18px 18px 0 0;
  padding: 20px;
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }
  .modal-box {
    border-radius: var(--radius);
  }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header h2 {
  font-size: 1.15rem;
  margin: 0;
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.warning-text {
  margin: 0;
  color: var(--text-muted);
}
.warning-supplier {
  margin: 0;
  font-weight: 700;
  font-size: 1.1rem;
}
.modal-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.modal-footer .btn {
  flex: 1;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 0 16px;
}
.toast {
  background: #222;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 100%;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* -------- RTL/LTR helpers -------- */

[dir='ltr'] .diff-old,
[dir='ltr'] .diff-new {
  flex-direction: row;
}

@media (max-width: 420px) {
  .app-title {
    font-size: 1.4rem;
  }
  .search-input {
    font-size: 1.05rem;
    padding: 14px 16px;
  }
  .modal-footer {
    flex-direction: column;
  }
}
