/* Docketstone app — clean stone theme (v2: light, neutral, smooth) */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --sidebar: #fbfaf7;
  --ink: #2b323b;        /* neutral charcoal, no blue cast */
  --ink-2: #3a424c;
  --text: #3d454f;
  --muted: #8a9099;
  --brass: #a8862f;
  --brass-bright: #c2a04d;
  --brass-dark: #8a6e26;
  --brass-soft: rgba(168, 134, 47, 0.10);
  --line: #e7e4dc;
  --line-soft: #efece5;
  --good: #3c8a5e;
  --good-soft: #e9f3ed;
  --bad: #b3382e;
  --bad-soft: #f9ecea;
  --warn-soft: #f9f3e3;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(43, 50, 59, 0.04), 0 8px 24px rgba(43, 50, 59, 0.05);
  --shadow-hover: 0 2px 4px rgba(43, 50, 59, 0.05), 0 12px 32px rgba(43, 50, 59, 0.09);
  /* legacy aliases used by standalone pages */
  --paper: #f6f5f2;
  --line-2: #d8d4c9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: Georgia, "Times New Roman", serif; }

/* ---- App shell ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding: 1.4rem 0.85rem;
}

.wordmark {
  font-family: Georgia, serif;
  font-size: 1.32rem;
  color: var(--ink);
  letter-spacing: 0.01em;
  padding: 0 0.55rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 0.9rem;
  display: block;
  text-decoration: none;
}
.wordmark .mark { color: var(--brass); }

.nav a {
  display: block;
  padding: 0.5rem 0.85rem;
  margin: 1px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  transition: background 0.14s, color 0.14s;
}
.nav a:hover { background: rgba(43, 50, 59, 0.045); color: var(--ink); }
.nav a.active {
  background: var(--brass-soft);
  color: var(--brass-dark);
  font-weight: 600;
}
.nav .nav-label {
  padding: 1.05rem 0.85rem 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
}

.sidebar .foot {
  margin-top: auto;
  padding: 0.9rem 0.85rem 0;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--muted);
}
.sidebar .foot a { text-decoration: none; }
.sidebar .foot a:hover { color: var(--brass-dark); }
.sidebar .foot button {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
}
.sidebar .foot button:hover { color: var(--brass-dark); }

.main { flex: 1; padding: 2.1rem 2.6rem; max-width: 1220px; }

/* ---- Type & structure ---- */
h1 { font-family: Georgia, serif; font-size: 1.55rem; font-weight: 600; color: var(--ink); margin-bottom: 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; font-weight: 650; color: var(--ink-2); margin: 1.6rem 0 0.75rem; }

.topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.topline h1 { margin-bottom: 0; }

.btn {
  display: inline-block;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(43, 50, 59, 0.04);
}
.btn:hover { border-color: var(--brass); color: var(--brass-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn.brass { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn.brass:hover { background: var(--brass-dark); border-color: var(--brass-dark); color: #fff; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.statrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.stat:hover { box-shadow: var(--shadow-hover); }
.stat .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.stat .value { font-family: Georgia, serif; font-size: 1.7rem; color: var(--ink); margin-top: 0.15rem; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
th, td { text-align: left; padding: 0.62rem 0.95rem; border-bottom: 1px solid var(--line-soft); font-size: 0.9rem; }
th { background: #faf9f5; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: #faf9f6; }
td a { color: var(--ink-2); font-weight: 550; text-decoration: none; }
td a:hover { color: var(--brass-dark); }
table table { box-shadow: none; }

.amount { font-variant-numeric: tabular-nums; text-align: right; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.pill { display: inline-block; padding: 0.12rem 0.6rem; border-radius: 999px; font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.pill.open, .pill.active { background: var(--good-soft); color: var(--good); }
.pill.pending, .pill.prospect { background: var(--warn-soft); color: var(--brass-dark); }
.pill.closed, .pill.inactive { background: #eeece6; color: var(--muted); }

/* ---- Forms ---- */
form .field { margin-bottom: 1rem; max-width: 480px; }
label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); margin-bottom: 0.3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], input[type="file"], select, textarea {
  width: 100%;
  padding: 0.52rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a9099' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(168, 134, 47, 0.14);
}
.error { color: var(--bad); font-size: 0.82rem; margin-top: 0.25rem; }
.flash { background: var(--good-soft); border: 1px solid #cbe2d4; color: var(--good); border-radius: var(--radius-sm); padding: 0.65rem 1rem; margin-bottom: 1rem; font-size: 0.9rem; }

.searchbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.searchbar input { max-width: 320px; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.pagination { margin-top: 1rem; display: flex; gap: 0.35rem; font-size: 0.9rem; }
.pagination a, .pagination span { padding: 0.28rem 0.65rem; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; color: var(--ink-2); background: var(--surface); }
.pagination a:hover { border-color: var(--brass); color: var(--brass-dark); }
.pagination .current { background: var(--brass); color: #fff; border-color: var(--brass); }

/* ---- Dropdown menus ---- */
.dd { position: relative; display: inline-block; }
.dd-toggle {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.28rem 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
  transition: all 0.14s;
}
.dd-toggle:hover, .dd.on .dd-toggle { border-color: var(--brass); color: var(--brass-dark); }
.dd-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  min-width: 185px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 0.35rem;
  z-index: 40;
  text-align: left;
}
.dd.on .dd-menu { display: block; }
.dd-menu a, .dd-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.45rem 0.7rem;
  font-size: 0.87rem;
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-weight: 450;
  transition: background 0.12s;
}
.dd-menu a:hover, .dd-menu button:hover { background: var(--brass-soft); color: var(--brass-dark); }
.dd-menu .dd-danger { color: var(--bad); }
.dd-menu .dd-danger:hover { background: var(--bad-soft); color: var(--bad); }
.dd-menu .dd-sep { height: 1px; background: var(--line-soft); margin: 0.3rem 0.4rem; }
.dd-menu form { margin: 0; }

/* ---- Calendar ---- */
.cal-nav { display: flex; align-items: center; }
.calgrid { table-layout: fixed; margin-bottom: 1.5rem; }
.calgrid td { vertical-align: top; height: 94px; padding: 0.32rem 0.42rem; }
.calgrid td.other-month { background: #faf9f5; }
.calgrid td.other-month .daynum { color: #cdc9bf; }
.calgrid td.today { background: #fdfaf1; box-shadow: inset 0 0 0 2px var(--brass); }
.calgrid .daynum { font-size: 0.76rem; font-weight: 600; color: var(--muted); margin-bottom: 0.22rem; }
.cal-item { font-size: 0.72rem; line-height: 1.3; background: #f1f0ea; border-left: 3px solid var(--ink-2); border-radius: 5px; padding: 0.14rem 0.34rem; margin-bottom: 0.2rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-item.critical { background: var(--bad-soft); border-left-color: var(--bad); }
.cal-item.done { background: var(--good-soft); border-left-color: var(--good); text-decoration: line-through; color: var(--muted); }
.cal-type { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* ---- Login & standalone pages ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, #f6f5f2 0%, #efece4 60%, #eae5d8 100%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2.6rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(43, 50, 59, 0.05), 0 24px 60px rgba(43, 50, 59, 0.10);
}
.login-card .wordmark { color: var(--ink); border: none; padding: 0 0 0.25rem; font-size: 1.6rem; }
.login-card .tagline { color: var(--muted); font-size: 0.88rem; margin-bottom: 1.5rem; }
.login-card .btn { width: 100%; padding: 0.68rem; margin-top: 0.5rem; text-align: center; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .main { padding: 1.25rem; }
}
