:root {
  --primary: #2f6f4f;
  --primary-dark: #234f38;
  --bg: #f4f6f5;
  --card-bg: #ffffff;
  --border: #d9dfdc;
  --text: #1f2a24;
  --error-bg: #fdecea;
  --error-text: #b3261e;
  --success-bg: #e7f5ec;
  --success-text: #1e7a44;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--primary-dark);
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  font-size: 18px;
  margin: 0 0 24px;
}

.sidebar nav {
  flex: 1;
}

.nav-link {
  display: block;
  color: #fff;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
}

.nav-link.active,
.nav-link:hover {
  background: var(--primary);
}

.version-footer {
  margin-top: auto;
  font-size: 11px;
  color: #9fb3a8;
  padding: 0 12px;
}

.logout-form {
  margin-top: 4px;
}

.link-button {
  background: none;
  border: none;
  color: #d9dfdc;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 14px;
}

.link-button:hover {
  color: #fff;
}

.content {
  flex: 1;
  padding: 32px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 24px;
  width: fit-content;
}

.topbar label {
  margin: 0;
  white-space: nowrap;
}

.topbar select {
  min-width: 220px;
}

.content.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  max-width: 520px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 40px 36px;
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.08);
  text-align: center;
  animation: login-card-in 0.35s ease-out;
}

.login-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card .brand {
  font-size: 24px;
  margin: 0 0 8px;
  color: var(--text);
}

.login-form {
  text-align: left;
}

.login-form label {
  display: block;
}

.login-form textarea {
  width: 100%;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 96px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form textarea::placeholder {
  color: #97a19c;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

.login-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 79, 0.18);
}

.login-form .field-hint {
  text-align: left;
  margin-bottom: 20px;
}

.btn-block {
  width: 100%;
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn-block:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(47, 111, 79, 0.3);
}

.btn-block:active {
  transform: translateY(0);
}

@keyframes login-card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .content.centered {
    padding: 16px;
  }

  .login-card {
    padding: 28px 20px;
    border-radius: 12px;
  }
}

.subtitle {
  color: #566;
  margin-top: 0;
}

.form-fornecedor {
  max-width: 640px;
}

.form-row {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

label {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

input, select, textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}

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

.alert {
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.field-hint {
  font-size: 12px;
  margin-top: 4px;
  color: #566;
}

.field-hint.error {
  color: var(--error-text);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.list-header h2 {
  margin: 0;
}

.search-row {
  margin-bottom: 16px;
}

.search-row input {
  width: 100%;
  max-width: 480px;
}

.table-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.fornecedores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.fornecedores-table thead th {
  background: #ece9e4;
  text-align: left;
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.fornecedores-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.fornecedores-table tbody tr:nth-child(even) {
  background: #f8f4fb;
}

.fornecedores-table tbody tr:hover {
  background: #efe7f5;
}

.fornecedores-table tbody tr:last-child td {
  border-bottom: none;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn-view {
  background: #d6ecfb;
  color: #1f6fa8;
}

.icon-btn-edit {
  background: #fbe8cf;
  color: #b5690a;
}

.icon-btn-delete {
  background: #fbdcd9;
  color: #b3261e;
}

.icon-btn:hover {
  filter: brightness(0.95);
}

.badge {
  background: var(--success-bg);
  color: var(--success-text);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
}

.empty-state,
.loading-state {
  text-align: center;
  color: #667;
  padding: 20px 0;
}

.loading-state[hidden],
.empty-state[hidden] {
  display: none;
}

#fornecedores-sentinel {
  height: 1px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 24px;
  max-width: 640px;
  width: 100%;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
}

.modal-header .link-button {
  color: #566;
}
