@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:      #0d1b2e;
  --navy-mid:  #162540;
  --blue:      #1a6fc4;
  --blue-lt:   #2a85e0;
  --blue-pale: #e8f2fc;
  --accent:    #f0a500;
  --danger:    #c0392b;
  --success:   #1a7a3c;
  --gray-50:   #f7f9fc;
  --gray-100:  #edf1f7;
  --gray-200:  #d4dce9;
  --gray-400:  #8a9ab5;
  --gray-600:  #4a5a72;
  --text:      #1a2333;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(13,27,46,.10);
  --shadow-lg: 0 8px 32px rgba(13,27,46,.16);
  --header-h:  60px;
}

html { font-size: 15px; }

body {
  font-family: 'Sora', sans-serif;
  background: var(--gray-50);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,.25);
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.app-header .logo-mark {
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  letter-spacing: .5px;
  flex-shrink: 0;
}

.app-header .logo-text {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .3px;
}

.app-header .logo-sub {
  font-size: 11px;
  font-weight: 300;
  color: var(--gray-400);
  letter-spacing: .5px;
}

.header-spacer { flex: 1; }

.header-user {
  display: flex; align-items: center; gap: 10px;
}

.header-user .user-badge {
  font-size: 12px;
  color: var(--gray-400);
  background: var(--navy-mid);
  border: 1px solid rgba(255,255,255,.08);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.header-user .user-badge span {
  color: var(--accent);
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--gray-400);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: 'Sora', sans-serif;
  cursor: pointer;
  transition: all .2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
  border-color: rgba(255,255,255,.3);
}

/* ── Page Wrapper ── */
.page {
  padding-top: calc(var(--header-h) + 32px);
  padding-bottom: 48px;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 28px;
}

.container.narrow {
  max-width: 440px;
}

/* ── Page Title Bar ── */
.page-title-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.page-title-bar h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
}

.breadcrumb {
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 6px;
  font-weight: 400;
}

.breadcrumb a { color: var(--blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Card ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

/* ── Auth Pages (login/register) ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, #0f2340 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-header {
  background: var(--navy);
  padding: 28px 32px 24px;
  text-align: center;
}

.auth-logo-mark {
  width: 48px; height: 48px;
  background: var(--blue);
  border-radius: 12px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  margin-bottom: 12px;
}

.auth-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.auth-header p {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 300;
}

.auth-body {
  padding: 28px 32px 32px;
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'Sora', sans-serif;
  color: var(--text);
  background: var(--gray-50);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26,111,196,.12);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a9ab5' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  width: 100%;
  padding: 12px;
}

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

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
  background: var(--success);
  color: #fff;
  padding: 5px 12px;
  font-size: 12px;
}

.btn-success:hover { background: #145f2e; }
.btn-success:disabled { opacity: .35; cursor: default; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  padding: 5px 12px;
  font-size: 12px;
}

.btn-danger:hover { background: #9b2d22; }
.btn-danger:disabled { opacity: .35; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-weight: 500;
  font-size: 13px;
}

.btn-ghost:hover { text-decoration: underline; }

.auth-footer {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
  margin-top: 4px;
  font-size: 13px;
  color: var(--gray-400);
}

.auth-footer a { color: var(--blue); text-decoration: none; font-weight: 500; }

/* ── Alert / Status ── */
.alert {
  display: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert.show { display: flex; align-items: center; gap: 8px; }
.alert-error   { background: #fdecea; color: var(--danger);  border: 1px solid #f5c6cb; }
.alert-success { background: #e6f4ea; color: var(--success); border: 1px solid #b7dfbf; }
.alert-info    { background: #fff3cd; color: #856404;        border: 1px solid #ffc107; }

/* ── Dashboard List Cards ── */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.list-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  margin: 28px 0 12px;
}

.list-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all .2s;
  box-shadow: var(--shadow);
}

.list-card:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 20px rgba(26,111,196,.15);
  transform: translateY(-1px);
}

.list-card .list-icon {
  width: 40px; height: 40px;
  background: var(--blue-pale);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.list-card .list-info { flex: 1; }

.list-card .list-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 3px;
}

.list-card .list-site {
  font-size: 11px;
  color: var(--gray-400);
  font-family: 'DM Mono', monospace;
}

.list-card .list-arrow {
  color: var(--gray-400);
  font-size: 16px;
  transition: transform .2s;
}

.list-card:hover .list-arrow { transform: translateX(4px); color: var(--blue); }

/* ── Table ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}

.table-wrap::-webkit-scrollbar { height: 6px; width: 6px; }
.table-wrap::-webkit-scrollbar-track { background: var(--gray-100); }
.table-wrap::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 3px; }
.table-wrap::-webkit-scrollbar-corner { background: var(--gray-100); }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}

thead th {
  background: var(--navy);
  color: rgba(255,255,255,.85);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 11px 14px;
  border: none;
  position: sticky;
  top: 0;
  z-index: 3;
}

tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--text);
  vertical-align: middle;
}

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

tbody tr:hover td { background: var(--blue-pale); }

tbody tr.modificado td:first-child {
  border-left: 3px solid var(--accent);
}

/* editable cells */
td.editavel { cursor: text; }

td.editavel:hover { background: #f0f7ff !important; }

td input.cell-input {
  width: 100%;
  min-width: 120px;
  box-sizing: border-box;
  border: 1.5px solid var(--blue);
  padding: 4px 8px;
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  color: var(--text);
  background: #f0f7ff;
  border-radius: 5px;
  outline: none;
}

td input.cell-input:focus {
  box-shadow: 0 0 0 3px rgba(26,111,196,.15);
}

td.acoes { white-space: nowrap; }

/* ── Status bar (lista page) ── */
#status {
  display: none;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
}

#status.ok       { display:inline-flex; background:#e6f4ea; color:var(--success); border:1px solid #b7dfbf; }
#status.erro     { display:inline-flex; background:#fdecea; color:var(--danger);  border:1px solid #f5c6cb; }
#status.salvando { display:inline-flex; background:#fff3cd; color:#856404;        border:1px solid #ffc107; }

/* ── Loading ── */
.loading-row td {
  text-align: center;
  padding: 32px;
  color: var(--gray-400);
  font-size: 13px;
}

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* ── Modal de Anexos ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,27,46,.55);
  backdrop-filter: blur(3px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn .18s ease;
}

@keyframes modalIn {
  from { opacity:0; transform:translateY(12px) scale(.97); }
  to   { opacity:1; transform:none; }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.modal-header h3 {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

.modal-header .modal-subtitle {
  font-size: 11px;
  color: var(--gray-400);
  font-family: 'DM Mono', monospace;
  font-weight: 400;
  margin-top: 2px;
}

.btn-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all .15s;
}

.btn-modal-close:hover { background: var(--gray-100); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}

.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 20px;
  background: var(--gray-50);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-pale);
}

.upload-zone input[type=file] { display: none; }

.upload-zone .upload-icon { font-size: 26px; margin-bottom: 6px; }

.upload-zone .upload-label {
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 500;
}

.upload-zone .upload-label span { color: var(--blue); text-decoration: underline; cursor: pointer; }

.upload-zone .upload-hint {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

.upload-progress {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--blue-pale);
  border: 1px solid #bee3f8;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--blue);
  font-weight: 500;
  margin-bottom: 16px;
}

.upload-progress.show { display: flex; }

/* Anexo lista */
.attach-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--gray-400);
  margin-bottom: 10px;
}

.attach-empty {
  text-align: center;
  padding: 24px 0;
  color: var(--gray-400);
  font-size: 13px;
}

.attach-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  transition: border-color .15s;
}

.attach-item:hover { border-color: var(--blue); }

.attach-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.attach-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.attach-actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn-attach-download {
  background: var(--blue-pale);
  color: var(--blue);
  border: 1px solid #bee3f8;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-attach-download:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

.btn-attach-delete {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6cb;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.btn-attach-delete:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* badge de anexos na coluna Ações */
.badge-attach {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--blue-pale);
  color: var(--blue);
  border: 1px solid #bee3f8;
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.badge-attach:hover { background: var(--blue); color: #fff; }

/* ── Botão Exportar Excel ── */
.btn-excel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: #1a7a3c;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}

.btn-excel:hover:not(:disabled) { background: #145f2e; }
.btn-excel:disabled { opacity: .4; cursor: default; }