/* nothing fancy. system fonts, keep it quick */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, system-ui, sans-serif;
  max-width: 640px;
  margin: 40px auto;
  padding: 0 16px;
  color: #111;
}

h1 { font-size: 1.4rem; margin: 0; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

form#newLink {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

input, button {
  font-size: 1rem;
  padding: 8px 10px;
}

button { cursor: pointer; }

#msg { min-height: 1.2em; margin: 0 0 16px; color: #666; font-size: .9rem; }

ul#links { list-style: none; padding: 0; margin: 0; }

ul#links li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid #eee;
  font-size: .9rem;
}

ul#links li .code { font-weight: 600; }
ul#links li .dest {
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
ul#links li .clicks { color: #999; }
ul#links li button { padding: 4px 8px; font-size: .8rem; }

/* the per-link stats drawer */
.stats {
  flex-basis: 100%;
  margin: 6px 0 4px;
  padding: 10px 12px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  color: #444;
}
.stats .sum { margin: 0 0 10px; font-weight: 600; color: #111; }
.stats .bd { margin: 0 0 12px; }
.stats .bd h4 {
  margin: 0 0 5px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #999;
}

/* each breakdown row: a faint bar behind the label + count */
.stats .bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
  margin-bottom: 2px;
}
.stats .bar span {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: #e6eefc;
  border-radius: 3px;
  z-index: 0;
}
.stats .bar em { position: relative; z-index: 1; font-style: normal; }
.stats .bar b { position: relative; z-index: 1; margin-left: auto; color: #666; font-weight: 600; }

/* 30 day sparkline */
.stats .spark, #dash .spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
}
.stats .spark span, #dash .spark span {
  flex: 1;
  min-height: 1px;
  background: #4f7cd6;
  border-radius: 1px 1px 0 0;
}

.topbtns { display: flex; gap: 8px; }

/* the all-links dashboard drawer */
#dash {
  margin: 0 0 20px;
  padding: 12px 14px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  color: #444;
}

/* dashboard + per-link share the same breakdown / chart styling */
#dash .bd { margin: 0 0 12px; }
#dash .bd h4 {
  margin: 0 0 5px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #999;
}
#dash .bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
  margin-bottom: 2px;
}
#dash .bar span {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: #e6eefc;
  border-radius: 3px;
  z-index: 0;
}
#dash .bar em { position: relative; z-index: 1; font-style: normal; }
#dash .bar b { position: relative; z-index: 1; margin-left: auto; color: #666; font-weight: 600; }

/* the little number tiles up top */
.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 14px;
}
.kpi { display: flex; flex-direction: column; line-height: 1.1; }
.kpi b { font-size: 1.3rem; color: #111; }
.kpi em { font-style: normal; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #999; }

/* hour-of-day heat strip */
.heat {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}
.heat span {
  height: 18px;
  border-radius: 2px;
}

.tools { margin-top: 4px; }
.tools button { padding: 4px 8px; font-size: .8rem; }
