:root {
  --ink: #203c35;
  --ink-2: #35564d;
  --cream: #f4f0e7;
  --paper: #fffdf8;
  --line: #ded8cc;
  --muted: #766f66;
  --sage: #769889;
  --sage-soft: #dce7e0;
  --amber: #d39a49;
  --amber-soft: #f5e4c7;
  --blue: #5e8191;
  --blue-soft: #dce9ed;
  --plum: #85677d;
  --plum-soft: #e8dfe6;
  --danger: #a54a42;
  --shadow: 0 12px 35px rgba(43, 54, 48, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 28px 20px;
  background: var(--ink);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 38px;
  color: white;
  text-decoration: none;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 50% 50% 42% 42%;
  display: grid;
  place-items: center;
  font: italic 700 22px Georgia, serif;
}
.brand strong { display: block; font: 600 21px Georgia, serif; letter-spacing: .3px; }
.brand small { display: block; margin-top: 3px; color: #b8c8c1; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
nav { display: grid; gap: 7px; }
.nav-item {
  border: 0;
  border-radius: 9px;
  padding: 12px 14px;
  background: transparent;
  color: #c7d4ce;
  text-align: left;
  transition: .2s;
}
.nav-item span { display: inline-block; width: 25px; font-size: 18px; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.11); color: white; }
.sidebar-note {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px;
  background: rgba(255,255,255,.055);
}
.note-icon { color: #e9bd79; }
.sidebar-note strong { display: block; margin-top: 10px; }
.sidebar-note p { margin: 6px 0 13px; color: #b8c8c1; font-size: 12px; line-height: 1.5; }
.sidebar-note small { color: #c9d5cf; font-size: 10px; }
.mini-progress { height: 4px; margin-bottom: 7px; overflow: hidden; border-radius: 9px; background: rgba(255,255,255,.16); }
.mini-progress i { display: block; width: 0; height: 100%; background: #e9bd79; transition: width .4s; }
.settings-link { margin-top: 12px; }

main { margin-left: 248px; min-height: 100vh; }
.topbar {
  min-height: 92px;
  padding: 20px clamp(24px, 4vw, 58px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
}
.topbar h1 { margin: 2px 0 0; font: 600 23px Georgia, serif; }
.eyebrow { margin: 0; color: var(--sage); font-size: 10px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; }
.topbar .primary-button { margin-left: auto; }
.menu-button { display: none; border: 0; background: transparent; color: var(--ink); font-size: 24px; }
.primary-button, .secondary-button {
  border-radius: 9px;
  padding: 11px 17px;
  font-weight: 700;
  transition: transform .15s, box-shadow .15s;
}
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; box-shadow: 0 6px 16px rgba(32,60,53,.17); }
.secondary-button { border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(32,60,53,.15); }
.full-button { width: 100%; margin-top: 18px; }

.view { display: none; padding: 34px clamp(24px, 4vw, 58px) 60px; }
.view.active { display: block; animation: reveal .25s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.welcome {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 28px;
}
.welcome h2, .section-heading h2 { margin: 6px 0 0; font: 500 clamp(27px, 3vw, 38px)/1.16 Georgia, serif; }
.quote { padding-left: 35px; border-left: 1px solid #c9c1b4; color: #625c54; font: italic 15px/1.55 Georgia, serif; }
.quote span { color: var(--sage); }

.kpi-grid { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 14px; margin-bottom: 17px; }
.goal-card, .metric-card, .panel {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,253,248,.78);
  box-shadow: var(--shadow);
}
.goal-card, .metric-card { min-height: 142px; padding: 20px; display: flex; align-items: center; }
.goal-card { gap: 20px; }
.goal-ring {
  --progress: 0deg;
  width: 94px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--sage) var(--progress), #dfe1d9 0);
  position: relative;
}
.goal-ring::before { content: ""; position: absolute; width: 72px; aspect-ratio: 1; border-radius: 50%; background: var(--paper); }
.goal-ring div { position: relative; text-align: center; }
.goal-ring strong, .goal-ring small { display: block; }
.goal-ring strong { font: 600 22px Georgia, serif; }
.goal-ring small { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.card-label { color: var(--sage); font-size: 9px; font-weight: 800; letter-spacing: 1.35px; }
.goal-copy h3, .metric-card h3 { margin: 7px 0 3px; font: 600 25px Georgia, serif; }
.goal-copy p, .metric-card p { margin: 0; color: var(--muted); font-size: 11px; }
.metric-card { gap: 14px; }
.metric-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; font-size: 18px; }
.metric-icon.amber { background: var(--amber-soft); color: #a96f25; }
.metric-icon.blue { background: var(--blue-soft); color: var(--blue); }
.metric-icon.green { background: var(--sage-soft); color: var(--ink-2); }

.dashboard-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 17px; margin-bottom: 17px; }
.panel { padding: 23px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.panel-header h3 { margin: 5px 0 0; font: 600 20px Georgia, serif; }
.legend { color: var(--muted); font-size: 10px; }
.legend i { display: inline-block; width: 12px; border-top: 1px dashed var(--amber); margin-right: 5px; vertical-align: middle; }
.text-button { border: 0; background: transparent; color: var(--sage); font-size: 11px; font-weight: 700; }
.bar-chart {
  height: 228px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(8px, 2vw, 21px);
  align-items: end;
  padding: 12px 10px 0;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to bottom, transparent 24.8%, rgba(118,111,102,.09) 25%, transparent 25.4%, transparent 49.8%, rgba(118,111,102,.09) 50%, transparent 50.4%, transparent 74.8%, rgba(118,111,102,.09) 75%, transparent 75.4%);
  position: relative;
}
.goal-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--amber); z-index: 1; }
.chart-column { height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; position: relative; z-index: 2; }
.chart-value { color: var(--ink-2); font-size: 9px; min-height: 12px; }
.bar { width: min(35px, 70%); min-height: 2px; border-radius: 5px 5px 0 0; background: var(--sage); transition: height .35s; }
.bar.today { background: var(--ink); }
.chart-label { height: 19px; color: var(--muted); font-size: 9px; text-transform: uppercase; }

.current-books { display: grid; gap: 12px; }
.current-book { display: grid; grid-template-columns: 39px 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 9px; background: #f7f3eb; }
.book-spine { width: 34px; height: 45px; border-radius: 2px 5px 5px 2px; display: grid; place-items: center; color: white; font: 700 15px Georgia, serif; box-shadow: 3px 3px 7px rgba(0,0,0,.12); }
.book-spine.sage { background: var(--sage); }.book-spine.amber { background: var(--amber); }.book-spine.blue { background: var(--blue); }.book-spine.plum { background: var(--plum); }
.current-book strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13px Georgia, serif; }
.current-book small { color: var(--muted); font-size: 10px; }
.progress { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 5px; background: #dedbd4; }
.progress i { display: block; height: 100%; background: var(--sage); }
.book-percent { font-size: 11px; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); text-align: left; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; }
td { padding: 14px 12px; border-bottom: 1px solid #e7e1d7; color: #4f4a44; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.book-cell { color: var(--ink); font: 600 13px Georgia, serif; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 20px; background: var(--sage-soft); color: var(--ink-2); font-size: 9px; font-weight: 700; }
.status-pill.goal { background: var(--amber-soft); color: #895c20; }
.delete-button, .edit-button { border: 0; background: transparent; color: var(--muted); font-size: 15px; }
.delete-button:hover { color: var(--danger); }
.row-actions { white-space: nowrap; }
.edit-record-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 700;
}
.edit-record-button:hover { border-color: var(--sage); background: var(--sage-soft); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 25px; margin-bottom: 26px; }
.section-heading > div > p:last-child { color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 10px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfc8bb;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffefb;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(118,152,137,.13); }
.filters input { min-width: 230px; }
.empty-state { display: none; padding: 50px; color: var(--muted); text-align: center; }

.books-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 17px; }
.book-card { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: var(--shadow); }
.book-card-top { height: 8px; }
.book-card-top.sage { background: var(--sage); }.book-card-top.amber { background: var(--amber); }.book-card-top.blue { background: var(--blue); }.book-card-top.plum { background: var(--plum); }
.book-card-body { padding: 22px; }
.book-card h3 { min-height: 48px; margin: 8px 0 3px; font: 600 20px/1.2 Georgia, serif; }
.book-card .author { min-height: 18px; margin: 0 0 19px; color: var(--muted); font-size: 11px; }
.book-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 17px; }
.book-meta div { padding: 10px; border-radius: 8px; background: #f5f1e9; }
.book-meta small, .book-meta strong { display: block; }
.book-meta small { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.book-meta strong { margin-top: 4px; font-size: 12px; }
.book-card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.book-card-actions button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--ink); font-size: 10px; }
.book-card-actions .danger-button { margin-right: auto; color: var(--danger); }
.welcome-card {
  grid-column: 1 / -1;
  max-width: 620px;
  margin: 20px auto;
  padding: 48px 36px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}
.welcome-card h3 { margin: 8px 0 10px; font: 600 28px Georgia, serif; }
.welcome-card > p:not(.eyebrow) { max-width: 480px; margin: 0 auto 24px; color: var(--muted); line-height: 1.65; }
.welcome-symbol {
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sage-soft);
  color: var(--ink);
  font-size: 28px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(20,38,34,.62);
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: grid; }
.modal {
  position: relative;
  width: min(570px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 31px;
  border-radius: 15px;
  background: var(--cream);
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.modal h2 { margin: 6px 0 24px; font: 600 28px Georgia, serif; }
.modal-close { position: absolute; top: 16px; right: 18px; border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid label { display: grid; gap: 7px; color: #4f4a44; font-size: 11px; font-weight: 700; }
.form-grid .full { grid-column: 1 / -1; }
textarea { resize: vertical; }
.calculation-preview { margin-top: 16px; padding: 12px; border-radius: 8px; background: var(--sage-soft); color: var(--ink-2); font-size: 11px; text-align: center; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; padding: 13px 18px; border-radius: 8px; background: var(--ink); color: white; font-size: 12px; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .books-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 850px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: 15px 0 35px rgba(0,0,0,.18); }
  .sidebar.open { transform: none; }
  main { margin-left: 0; }
  .menu-button { display: block; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .welcome .quote { display: none; }
}
@media (max-width: 620px) {
  .topbar { min-height: 76px; padding: 14px 17px; }
  .topbar h1 { font-size: 19px; }
  .topbar .eyebrow { display: none; }
  .topbar .primary-button { padding: 10px 12px; font-size: 0; }
  .topbar .primary-button::after { content: "＋ Leitura"; font-size: 12px; }
  .view { padding: 25px 16px 45px; }
  .welcome h2 { font-size: 27px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .goal-card, .metric-card { min-height: 112px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .filters { flex-direction: column; }
  .filters input { min-width: 0; }
  .books-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .modal { padding: 26px 20px; }
}
