:root {
  --ink: #17223b;
  --ink-soft: #536077;
  --paper: #f7f5f0;
  --panel: #fffdfa;
  --line: #e7e2d8;
  --indigo: #4f46a5;
  --indigo-dark: #27255f;
  --coral: #ef755f;
  --teal: #2e9c91;
  --sun: #e9ae43;
  --danger: #bb3d45;
  --shadow: 0 16px 40px rgba(32, 38, 58, .07);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
a { color: inherit; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 700;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 12px 4px 12px 4px;
  background: var(--coral);
  color: white;
  font-family: Georgia, serif;
  font-size: 21px;
}
.eyebrow {
  margin: 0 0 7px;
  color: var(--indigo);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}
.muted { color: var(--ink-soft); }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 10;
  inset: 0 auto 0 0;
  display: flex;
  width: 238px;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.1);
  background: var(--ink);
  color: white;
  padding: 28px 20px 20px;
}
.sidebar .brand { color: white; margin: 0 8px 43px; }
.side-nav { display: grid; gap: 7px; }
.side-nav a, .sidebar-footer a, .sidebar-footer button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #cbd1dd;
  padding: 11px 12px;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.side-nav a span, .sidebar-footer a span, .sidebar-footer button span { width: 18px; color: #99a5ba; font-size: 18px; }
.side-nav a:hover, .side-nav a.active, .sidebar-footer a:hover, .sidebar-footer button:hover {
  background: rgba(255,255,255,.09);
  color: white;
}
.side-nav a.active { box-shadow: inset 3px 0 var(--coral); }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 16px; }
.sidebar-footer form { margin: 0; }
.sidebar-footer p { margin: 18px 12px 0; color: #9ba6ba; font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #63c6a5; box-shadow: 0 0 0 4px rgba(99,198,165,.12); }

.main-content { margin-left: 238px; padding: 38px clamp(24px, 4vw, 62px) 26px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.topbar h1, .panel h2, .section-heading h2 { margin: 0; font-family: Georgia, serif; font-weight: 500; }
.topbar h1 { font-size: clamp(28px, 3vw, 39px); }
.mobile-menu { display: none; border: 0; background: transparent; color: var(--ink); font-size: 25px; }
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.button-primary { background: var(--indigo); color: white; box-shadow: 0 8px 20px rgba(79,70,165,.2); }
.button-primary:hover { background: var(--indigo-dark); transform: translateY(-1px); }
.button-wide { width: 100%; }

.alert { margin: -8px 0 22px; border-radius: 11px; padding: 13px 16px; font-size: 14px; }
.alert-success { border: 1px solid #b9ddd6; background: #effaf7; color: #176c61; }
.alert-error { border: 1px solid #f0bec1; background: #fff2f2; color: #9d2f38; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card {
  display: flex;
  min-height: 118px;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  border-top: 4px solid var(--indigo);
  border-radius: 13px;
  background: var(--panel);
  padding: 18px 18px 16px;
  box-shadow: 0 6px 22px rgba(32,38,58,.04);
}
.stat-card p { margin: 0 0 5px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.stat-card strong { font-family: Georgia, serif; font-size: 34px; font-weight: 500; }
.stat-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: #eeecfb; color: var(--indigo); font-size: 20px; }
.stat-coral { border-top-color: var(--coral); }
.stat-coral .stat-icon { background: #fff0ed; color: var(--coral); }
.stat-teal { border-top-color: var(--teal); }
.stat-teal .stat-icon { background: #e6f6f3; color: var(--teal); }
.stat-sun { border-top-color: var(--sun); }
.stat-sun .stat-icon { background: #fff5df; color: #b47b12; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 23px 25px 18px; }
.panel-heading h2 { font-size: 25px; }
.panel-number { color: #d5d0c7; font-family: Georgia, serif; font-size: 25px; font-style: italic; }
.create-form { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; padding: 23px 25px 25px; }
.create-form label, .form-stack label { display: grid; gap: 8px; color: #303b50; font-size: 12px; font-weight: 750; }
.create-form label > span small { color: #9299a5; font-weight: 500; }
.create-form label > span b { color: var(--coral); }
.field-full { grid-column: 1 / -1; }
input {
  width: 100%;
  height: 44px;
  border: 1px solid #dcd7cd;
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
}
input::placeholder { color: #a6abb5; }
input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,165,.1); }
.prefix-input { display: flex; height: 44px; overflow: hidden; border: 1px solid #dcd7cd; border-radius: 9px; background: #f2efe9; }
.prefix-input:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,165,.1); }
.prefix-input > span { display: flex; align-items: center; padding-left: 12px; color: #747c8b; font-size: 12px; font-weight: 500; white-space: nowrap; }
.prefix-input input { height: 42px; border: 0; border-radius: 0; box-shadow: none; }
.create-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px dashed #dfdacf; margin-top: 3px; padding-top: 18px; }
.create-actions p { max-width: 440px; margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }

.chart-panel { min-height: 363px; }
.bar-chart { display: flex; height: 210px; align-items: end; justify-content: space-between; gap: 7px; padding: 27px 22px 12px; }
.bar-column { display: grid; width: 100%; height: 100%; grid-template-rows: 18px 1fr 18px; align-items: end; justify-items: center; gap: 5px; }
.bar-value { color: var(--ink-soft); font-size: 10px; }
.bar-track { display: flex; width: min(24px, 65%); height: 100%; align-items: end; overflow: hidden; border-radius: 5px 5px 3px 3px; background: #eeeae3; }
.bar-fill { width: 100%; min-height: 3px; border-radius: 5px 5px 3px 3px; background: linear-gradient(180deg, var(--coral), #ee9d73); transition: height .5s ease; }
.bar-h-0 { height: 0; }
.bar-h-10 { height: 10%; }
.bar-h-20 { height: 20%; }
.bar-h-30 { height: 30%; }
.bar-h-40 { height: 40%; }
.bar-h-50 { height: 50%; }
.bar-h-60 { height: 60%; }
.bar-h-70 { height: 70%; }
.bar-h-80 { height: 80%; }
.bar-h-90 { height: 90%; }
.bar-h-100 { height: 100%; }
.bar-column small { color: #777f8e; font-size: 10px; }
.chart-caption { margin: 0 23px; border-top: 1px solid var(--line); padding-top: 13px; color: #8a909b; font-size: 10px; line-height: 1.5; }

.links-section { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-heading h2 { font-size: 28px; }
.search-form { display: flex; width: min(270px, 100%); align-items: center; border: 1px solid #ddd8cf; border-radius: 9px; background: white; padding-left: 12px; }
.search-form span { color: #9299a5; }
.search-form input { border: 0; box-shadow: none; background: transparent; }
.link-list { display: grid; gap: 11px; }
.link-card {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) 105px 118px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(32,38,58,.035);
}
.link-card:hover { border-color: #d5cec0; box-shadow: 0 9px 24px rgba(32,38,58,.06); }
.link-accent { background: var(--teal); }
.link-accent-off { background: #aeb4be; }
.link-primary { min-width: 0; padding: 16px 20px; }
.link-title-row, .short-url-row { display: flex; align-items: center; gap: 9px; }
.link-title-row h3 { overflow: hidden; margin: 0; font-family: Georgia, serif; font-size: 17px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.pill { flex: 0 0 auto; border-radius: 999px; background: #f5efe2; color: #8b651f; padding: 3px 7px; font-size: 9px; font-weight: 750; }
.pill-live { background: #e8f6f1; color: #25776c; }
.pill-off { background: #eceef1; color: #747b87; }
.short-url-row { margin-top: 8px; }
.short-url-row a { overflow: hidden; color: var(--indigo); font-size: 13px; font-weight: 750; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { border: 0; border-radius: 5px; background: #efedf9; color: var(--indigo); padding: 4px 7px; font-size: 9px; font-weight: 800; cursor: pointer; }
.destination { display: block; overflow: hidden; margin-top: 7px; color: #848b98; font-size: 10px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.link-note { margin: 8px 0 0; color: #676f7e; font-size: 11px; }
.link-meta { display: flex; align-items: center; justify-content: center; flex-direction: column; border-left: 1px solid var(--line); color: #71798a; font-size: 10px; }
.link-meta strong { color: var(--ink); font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.link-meta small { margin-top: 5px; color: #999fa9; font-size: 8px; }
.link-actions { display: flex; align-items: center; justify-content: center; gap: 6px; border-left: 1px solid var(--line); padding: 10px; }
.link-actions form { margin: 0; }
.icon-button { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid #ded9d0; border-radius: 7px; background: white; color: #626b7b; font-size: 13px; text-decoration: none; cursor: pointer; }
.icon-button:hover { border-color: var(--indigo); color: var(--indigo); }
.danger-button:hover { border-color: var(--danger); color: var(--danger); }
.empty-state { border: 1px dashed #d3cdc1; border-radius: 16px; background: rgba(255,255,255,.45); padding: 45px 20px; text-align: center; }
.empty-state > span { display: grid; width: 48px; height: 48px; place-items: center; margin: 0 auto 12px; border-radius: 50%; background: #eeecfb; color: var(--indigo); font-size: 22px; }
.empty-state h3 { margin: 0; font-family: Georgia, serif; font-size: 21px; }
.empty-state p { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.page-footer { padding: 28px 0 0; color: #9b9da3; font-size: 10px; text-align: center; }
.toast { position: fixed; z-index: 50; right: 25px; bottom: 25px; transform: translateY(20px); border-radius: 9px; background: var(--ink); color: white; padding: 12px 16px; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

.login-body { min-height: 100vh; background: white; }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(370px, 1.05fr) minmax(400px, .95fr); }
.login-art { position: relative; overflow: hidden; background: var(--ink); color: white; padding: 38px clamp(35px, 6vw, 90px); }
.brand-light { color: white; }
.login-copy { position: relative; z-index: 2; max-width: 580px; margin-top: clamp(110px, 18vh, 210px); }
.eyebrow-light { color: #f3a28f; }
.login-copy h1 { margin: 9px 0 24px; font-family: Georgia, serif; font-size: clamp(50px, 6vw, 82px); font-weight: 400; line-height: .98; letter-spacing: -.035em; }
.login-copy p { max-width: 510px; color: #c1c9d8; font-size: 17px; line-height: 1.65; }
.path-art { position: absolute; right: -80px; bottom: -30px; width: 520px; height: 310px; opacity: .65; transform: rotate(-8deg); }
.path-line { position: absolute; inset: 40px; border: 2px dashed rgba(255,255,255,.2); border-radius: 50% 15% 48% 22%; transform: rotate(12deg); }
.path-dot { position: absolute; z-index: 2; width: 19px; height: 19px; border: 5px solid var(--ink); border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 3px rgba(239,117,95,.25); }
.path-dot-one { left: 42px; top: 142px; }
.path-dot-two { left: 255px; top: 43px; background: var(--sun); }
.path-dot-three { right: 47px; bottom: 49px; background: var(--teal); }
.login-panel { display: grid; place-items: center; padding: 40px; background: var(--paper); }
.login-card { width: min(430px, 100%); }
.login-card h2 { margin: 0 0 12px; font-family: Georgia, serif; font-size: 34px; font-weight: 500; }
.login-card > .muted { margin-bottom: 25px; font-size: 14px; line-height: 1.55; }
.mobile-brand { display: none; }
.form-stack { display: grid; gap: 18px; }
.form-stack input { height: 49px; }
.form-stack .button { margin-top: 3px; height: 49px; }
.privacy-note { margin: 25px 0 0; color: #969ca7; font-size: 11px; text-align: center; }
.privacy-note span { color: var(--teal); }

.not-found-body { display: grid; min-height: 100vh; place-items: center; background: var(--paper); padding: 25px; }
.not-found-card { width: min(560px, 100%); border: 1px solid var(--line); border-radius: 24px; background: var(--panel); padding: 45px; box-shadow: var(--shadow); text-align: center; }
.not-found-card .brand { margin-bottom: 50px; }
.not-found-symbol { display: grid; width: 72px; height: 72px; place-items: center; margin: 0 auto 25px; border-radius: 50%; background: #fff0ed; color: var(--coral); font-size: 33px; }
.not-found-card h1 { margin: 8px 0 12px; font-family: Georgia, serif; font-size: 38px; font-weight: 500; }
.not-found-card > p:last-child { color: var(--ink-soft); }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .chart-panel { min-height: auto; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 15px 0 40px rgba(12,19,33,.25); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 25px 16px; }
  .mobile-menu { display: block; }
  .topbar { align-items: center; }
  .topbar .button { display: none; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 100px; padding: 14px; }
  .stat-card strong { font-size: 29px; }
  .stat-icon { width: 34px; height: 34px; }
  .create-form { grid-template-columns: 1fr; padding: 20px; }
  .field-full { grid-column: auto; }
  .create-actions { align-items: stretch; flex-direction: column; }
  .panel-heading { padding: 20px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search-form { width: 100%; }
  .link-card { grid-template-columns: 5px minmax(0, 1fr) 75px; }
  .link-meta { border-left: 1px solid var(--line); }
  .link-actions { grid-column: 2 / -1; justify-content: flex-end; border-top: 1px solid var(--line); border-left: 0; }
  .login-shell { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-panel { padding: 28px 20px; }
  .mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 65px; font-family: Georgia, serif; font-size: 21px; font-weight: 700; }
}

@media (max-width: 430px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card p { font-size: 10px; }
  .stat-icon { display: none; }
  .prefix-input > span { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
  .link-card { grid-template-columns: 4px minmax(0, 1fr); }
  .link-meta { grid-column: 2; align-items: baseline; justify-content: flex-start; flex-direction: row; gap: 5px; border-top: 1px solid var(--line); border-left: 0; padding: 9px 18px 0; }
  .link-meta strong { font-size: 18px; }
  .link-meta small { margin: 0 0 0 auto; }
  .link-actions { grid-column: 2; padding-top: 9px; }
}
