:root {
  --zm-navy: #111d34;
  --zm-navy-08: rgba(17, 29, 52, 0.07);
  --zm-navy-14: rgba(17, 29, 52, 0.14);
  --zm-red: #b3261e;
  --zm-gray: #6b7280;
  --zm-border: rgba(17, 29, 52, 0.12);
  --zm-bg: #f5f6f9;
  --radius: 12px;
  --shadow-card: 0 1px 2px rgba(17, 29, 52, 0.04), 0 4px 16px rgba(17, 29, 52, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--zm-bg);
  color: #16213a;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: var(--zm-navy);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #fff;
}

.topbar img {
  height: 52px;
  width: 52px;
  display: block;
  border-radius: 8px;
}

.topbar h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.topbar p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #aab6cc;
}

.app-layout {
  display: flex;
  align-items: flex-start;
}

main {
  max-width: 900px;
  flex: 1;
  margin: 0 auto;
  padding: 24px 16px 90px;
}

.auth-screen {
  min-height: calc(100vh - 84px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  background: #fff;
  border: 1px solid var(--zm-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px 26px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  color: var(--zm-navy);
}

.auth-error {
  background: #fbe9e7;
  color: var(--zm-red);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.auth-toggle {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--zm-gray);
  text-align: center;
}

.auth-toggle a {
  color: var(--zm-navy);
  font-weight: 600;
  text-decoration: none;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--zm-border);
  min-height: calc(100vh - 84px);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.folders-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder {
  border-radius: 8px;
}

.folder summary {
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--zm-navy);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.folder summary::-webkit-details-marker {
  display: none;
}

.folder summary::before {
  content: '📁';
  font-size: 0.8rem;
}

.folder[open] summary::before {
  content: '📂';
}

.folder summary:hover {
  background: var(--zm-navy-08);
}

.folder-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 3px;
}

.folder-quotes {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 20px;
}

.folder-quote-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0;
}

.folder-quote {
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #16213a;
}

.folder-quote:hover {
  background: var(--zm-navy-08);
}

.folder-quote.active {
  background: var(--zm-navy);
  color: #fff;
}

.folder-quote.destacado {
  font-weight: 700;
}

.icon-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--zm-border);
  cursor: pointer;
  color: var(--zm-gray);
  font-size: 0.68rem;
  padding: 3px 4px;
  border-radius: 5px;
  line-height: 1.3;
}

.icon-btn:hover {
  background: var(--zm-navy-08);
  color: var(--zm-navy);
}

.icon-btn.danger:hover {
  background: #fbe9e7;
  color: var(--zm-red);
}

.icon-btn.starred {
  color: #b7791f;
  border-color: #f0dca3;
  background: #fdf6e3;
}

.sidebar-footer {
  border-top: 1px solid var(--zm-border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer span {
  font-size: 0.72rem;
  color: var(--zm-gray);
  word-break: break-all;
}

.card {
  background: #fff;
  border: 1px solid var(--zm-border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}

.card h2 {
  font-size: 0.82rem;
  color: var(--zm-navy);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--zm-border);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 18px;
}

.fixed-info {
  font-size: 0.85rem;
  color: var(--zm-gray);
  background: var(--zm-navy-08);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.fixed-info strong {
  color: var(--zm-navy);
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.76rem;
  color: var(--zm-gray);
  gap: 5px;
  font-weight: 600;
}

input, select {
  font-size: 0.95rem;
  padding: 9px 11px;
  border: 1px solid var(--zm-border);
  border-radius: 8px;
  color: #16213a;
  background: #fbfcfe;
  font-weight: 400;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  font-variant-numeric: tabular-nums;
}

input:hover, select:hover {
  border-color: #c7d1e2;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--zm-navy);
  background: #fff;
  box-shadow: 0 0 0 3px var(--zm-navy-14);
}

input:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--zm-gray);
  cursor: default;
}

.align-right {
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  background: var(--zm-navy-08);
  color: var(--zm-navy);
  text-align: left;
  padding: 9px 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

th:first-child { border-radius: 6px 0 0 6px; }
th:last-child { border-radius: 0 6px 6px 0; }

td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--zm-border);
  vertical-align: middle;
}

tbody tr:hover td {
  background: #fafbfd;
}

td input {
  min-width: 90px;
}

td.desc input {
  min-width: 180px;
}

.row-total {
  white-space: nowrap;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.05s;
}

.btn:hover {
  opacity: 0.88;
}

.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--zm-navy-08);
  color: var(--zm-navy);
}

.btn-danger {
  background: #fbe9e7;
  color: var(--zm-red);
  padding: 6px 10px;
}

.btn-primary {
  background: var(--zm-navy);
  color: #fff;
  font-size: 0.95rem;
  padding: 13px 24px;
  box-shadow: 0 2px 10px rgba(17, 29, 52, 0.25);
}

.actions-row {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.summary {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 7px;
  font-size: 0.9rem;
}

.summary .label {
  color: var(--zm-gray);
}

.summary .value {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary hr {
  grid-column: 1 / -1;
  border: none;
  border-top: 1px solid var(--zm-border);
  margin: 8px 0;
}

.result-box {
  grid-column: 1 / -1;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.result-box.costo {
  background: var(--zm-navy);
  color: #fff;
}

.result-box.costo .rb-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #aab6cc;
  font-weight: 700;
}

.result-box.costo .rb-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tax-table td:nth-child(2) {
  width: 90px;
}

.footer-actions {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--zm-border);
  padding: 14px 16px;
  display: flex;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 -4px 16px rgba(17, 29, 52, 0.07);
}

@media (max-width: 600px) {
  .topbar h1 { font-size: 1rem; }
  main { padding: 16px 10px 100px; }
  .card { padding: 16px; }
  .result-box { flex-direction: column; align-items: flex-start; gap: 4px; }
  .result-box .rb-value { align-self: flex-end; }
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; border-right: none; border-bottom: 1px solid var(--zm-border); }
  .folders-list { max-height: 220px; }
}
