:root {
  --paper:   #f4efe6;   /* warm background */
  --card:    #fbf8f2;   /* table surface   */
  --ink:     #221e18;   /* near-black warm  */
  --ink-soft:#7a7266;   /* secondary text   */
  --line:    #e4dccd;   /* hairline         */
  --accent:  #bc4b28;   /* terracotta       */
  --accent-tint: rgba(188, 75, 40, .06);
  --sage:    #5e7350;   /* visited          */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  /* faint paper grain for atmosphere */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 15px; transform: translateY(1px); }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.brand-sub { font-family: var(--serif); font-style: italic; font-weight: 500; color: var(--ink-soft); font-size: 14px; }
.topnav { display: flex; align-items: center; gap: 18px; font-size: 13px; }
.topnav a, .linkbtn { color: var(--ink-soft); }
.topnav a:hover, .linkbtn:hover { color: var(--accent); text-decoration: none; }
.inline-form { display: inline; margin: 0; }
.linkbtn { background: none; border: none; cursor: pointer; font: inherit; padding: 0; }

main { padding: 22px 28px 40px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.count { font-family: var(--serif); font-size: 20px; letter-spacing: -.01em; }
.tools { display: flex; align-items: center; gap: 8px; }
.sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

.btn {
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  color: var(--ink); background: var(--card); border: 1px solid var(--line);
  transition: border-color .15s, color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Table ---------- */
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 190px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 18px 40px -32px rgba(60,40,20,.35);
}

table { border-collapse: collapse; width: 100%; }

th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Header labels */
thead th { position: sticky; z-index: 10; background: var(--card); }
.head-labels th {
  top: 0;
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft);
  white-space: nowrap; border-bottom: 1px solid var(--ink);
  position: sticky; cursor: pointer; user-select: none;
}
.head-labels th:hover { color: var(--ink); }
.head-labels th.sort-asc, .head-labels th.sort-desc { color: var(--accent); }
.head-labels th.sort-asc::after { content: "▲"; font-size: 8px; margin-left: 6px; }
.head-labels th.sort-desc::after { content: "▼"; font-size: 8px; margin-left: 6px; }

/* Eye toggle — quiet, appears on header hover */
.eye {
  width: 14px; height: 14px; margin-left: 8px; padding: 0; border: none; cursor: pointer;
  vertical-align: -2px; opacity: 0; transition: opacity .15s, background-color .15s;
  background-color: var(--ink-soft);
  -webkit-mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
          mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}
.head-labels th:hover .eye { opacity: .45; }
.eye:hover { opacity: 1; background-color: var(--accent); }

/* Filter row — hidden until toggled */
.filters-off .head-filters { display: none; }
.head-filters th { top: 39px; background: #f6f2ea; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.head-filters input, .head-filters select {
  width: 100%; min-width: 62px; font: inherit; font-size: 12.5px;
  padding: 5px 8px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
.head-filters input:focus, .head-filters select:focus { outline: none; border-color: var(--accent); }
.head-filters input::placeholder { color: #b7ad9c; }
.range { display: flex; gap: 4px; }
.range input { min-width: 44px; text-align: right; }

/* Body cells */
tbody tr.rowmain { transition: background .12s; }
tbody tr.rowmain:hover { background: var(--accent-tint); }

/* Row color by "Já fui?" — set manually, kept as history */
tbody tr.rowmain[data-visited="yes"] { background: rgba(94, 115, 80, .15); }
tbody tr.rowmain[data-visited="yes"]:hover { background: rgba(94, 115, 80, .22); }
tbody tr.rowmain[data-visited="no"] { background: rgba(188, 75, 40, .09); }
tbody tr.rowmain[data-visited="no"]:hover { background: rgba(188, 75, 40, .15); }
td.soft { color: var(--ink-soft); }
td:last-child, th:last-child { padding-right: 20px; }

.cell-name { min-width: 210px; max-width: 320px; font-weight: 600; }
.cell-name a { color: var(--ink); }
.cell-name a:hover { color: var(--accent); }
.cell-address { min-width: 230px; max-width: 340px; font-size: 13px; }

/* Editable planning columns — a calm tinted zone, controls feel like plain text */
.col-edit { background: rgba(94, 115, 80, .045); }
thead .col-edit { background: rgba(94, 115, 80, .07); }
.col-edit select, .col-edit input {
  width: 100%; font: inherit; color: inherit;
  padding: 5px 7px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.col-edit select:hover, .col-edit input:hover { border-color: var(--line); background: #fff; }
.col-edit select:focus, .col-edit input:focus { outline: none; border-color: var(--accent); background: #fff; cursor: text; }
.col-edit input[type=date] { cursor: text; }
.col-edit input::placeholder { color: #c3baa9; }

/* Status dot */
.cell-status { }
.cell-status { display: flex; align-items: center; gap: 4px; }
.cell-status .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); background: transparent; }
.cell-status[data-status="want"] .dot { background: var(--accent); box-shadow: none; }
.cell-status[data-status="visited"] .dot { background: var(--sage); box-shadow: none; }
.cell-status[data-status="not_interested"] .dot { background: #cfc7b8; box-shadow: none; }

/* Priority weight cue */
.cell-priority[data-priority="high"] select { color: var(--accent); font-weight: 600; }
.cell-priority[data-priority="low"] select { color: var(--ink-soft); }

/* Save flash */
td.saved { animation: flash 1.1s ease; }
@keyframes flash {
  0% { background: rgba(94,115,80,.30); }
  100% { background: transparent; }
}
.col-edit.saved { animation: flashEdit 1.1s ease; }
@keyframes flashEdit {
  0% { background: rgba(94,115,80,.30); }
  100% { background: rgba(94,115,80,.045); }
}

/* Collapsed column: a thin strip; click its header to expand it back */
.col-collapsed {
  width: 28px !important; min-width: 28px !important; max-width: 28px !important;
  padding-left: 0 !important; padding-right: 0 !important; overflow: hidden;
}
td.col-collapsed, .head-filters th.col-collapsed { font-size: 0; }
.col-collapsed :is(input, select, a, span, .dot) { display: none !important; }
.head-labels th.col-collapsed {
  cursor: pointer; text-align: center; vertical-align: top;
  writing-mode: vertical-rl; text-orientation: mixed;
  font-size: 9px; letter-spacing: .05em; color: var(--ink-soft);
  white-space: nowrap; background: #efeadf;
}
.head-labels th.col-collapsed:hover { color: var(--accent); background: var(--accent-tint); }
.head-labels th.col-collapsed .eye { display: none; }
.head-labels th.col-collapsed.sort-asc::after,
.head-labels th.col-collapsed.sort-desc::after { content: none !important; } /* no sort arrow while collapsed */

/* Staggered entrance */
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
tbody tr.rowmain { animation: rise .45s cubic-bezier(.2,.7,.3,1) backwards; }

/* Scrollbar */
.table-wrap::-webkit-scrollbar { width: 11px; height: 11px; }
.table-wrap::-webkit-scrollbar-thumb { background: #ddd3c2; border-radius: 8px; border: 3px solid var(--card); }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #cdbfa8; }

/* ---------- Login ---------- */
.login-card {
  max-width: 340px; margin: 9vh auto; background: var(--card);
  padding: 34px 32px; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 50px -34px rgba(60,40,20,.4);
}
.login-card h1 { font-family: var(--serif); font-weight: 600; margin: 0 0 4px; font-size: 30px; letter-spacing: -.02em; }
.login-lede { color: var(--ink-soft); margin: 0 0 22px; font-family: var(--serif); font-style: italic; }
.login-card label { display: block; margin-bottom: 16px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.login-card input { width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 15px; background: #fff; color: var(--ink); }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { width: 100%; margin-top: 6px; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; letter-spacing: .02em; transition: background .15s; }
.login-card button:hover { background: #a53f20; }
.error { color: var(--accent); font-size: 13px; margin: 0 0 14px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}
