/* ============================================================
   Cloudy Cotton Sales Manager — design system
   Soft sky + cotton aesthetic. Brand colour is injected as
   --brand from Settings (see header.php).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #3FA7E0;
  --brand-deep: #2b7fb0;
  --ink: #1d3a4a;
  --ink-soft: #5a7180;
  --cloud: #f3f8fc;
  --surface: #ffffff;
  --line: #e3edf4;
  --sand: #f6efe3;
  --good: #2f9e6f;
  --warn: #d98324;
  --bad: #d65a5a;
  --shadow: 0 10px 30px -12px rgba(31, 76, 104, .25);
  --shadow-sm: 0 4px 14px -8px rgba(31, 76, 104, .3);
  --radius: 18px;
  --radius-sm: 12px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 500px at 110% -10%, #eaf4fb 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 110%, #eef6fc 0%, transparent 55%),
    var(--cloud);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-deep); text-decoration: none; }
h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }

.wordmark {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  line-height: 1;
}

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 246px; flex-shrink: 0;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sidebar .brand img { width: 38px; height: 38px; object-fit: contain; border-radius: 9px; }
.sidebar .brand .puff {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--brand));
  box-shadow: inset 0 -4px 8px rgba(0,0,0,.08);
}
.sidebar .brand .name { font-size: 22px; color: var(--brand-deep); }
.sidebar .brand .sub { font-size: 10px; color: var(--ink-soft); letter-spacing: .12em; text-transform: uppercase; }

.nav-group { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin: 18px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--ink); font-weight: 500; font-size: 14px; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; stroke: var(--ink-soft); flex-shrink: 0; }
.nav a:hover { background: var(--cloud); }
.nav a.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.nav a.active svg { stroke: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-soft); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.content { padding: 26px 28px 60px; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 20px; }
.card h2 { font-size: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------------- Stat tiles ---------------- */
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--brand));
  opacity: .12;
}
.stat .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .08em; }
.stat .value { font-size: 25px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat .value.sm { font-size: 20px; }
.stat .sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.stat.accent { background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: #fff; border: none; }
.stat.accent .label, .stat.accent .sub { color: rgba(255,255,255,.85); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 11px 14px; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-soft); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--cloud); }
tbody tr:last-child td { border-bottom: none; }
.t-right { text-align: right; }
.t-center { text-align: center; }
.muted { color: var(--ink-soft); }
.nowrap { white-space: nowrap; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge.green { background: #e4f5ed; color: var(--good); }
.badge.amber { background: #fbf0df; color: var(--warn); }
.badge.red { background: #fbe6e6; color: var(--bad); }
.badge.blue { background: #e6f2fb; color: var(--brand-deep); }
.badge.grey { background: #eef2f5; color: var(--ink-soft); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; transition: filter .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--cloud); }
.btn.danger { background: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn-link { background: none; border: none; color: var(--brand-deep); cursor: pointer; font: inherit; padding: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field .hint { font-weight: 400; color: var(--ink-soft); font-size: 12px; }
input, select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(63,167,224,.15);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---------------- Flash ---------------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; font-weight: 500; }
.flash.success { background: #e4f5ed; color: var(--good); }
.flash.error { background: #fbe6e6; color: var(--bad); }
.flash.info { background: #e6f2fb; color: var(--brand-deep); }

/* ---------------- Login ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 26px; box-shadow: var(--shadow); padding: 38px 34px; border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.login-card .clouds { position: absolute; inset: 0; pointer-events: none; opacity: .5; }
.login-logo { text-align: center; margin-bottom: 6px; }
.login-logo .puff {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--brand));
  box-shadow: inset 0 -6px 12px rgba(0,0,0,.08), var(--shadow-sm);
}
.login-logo img { max-width: 130px; max-height: 70px; object-fit: contain; margin-bottom: 8px; }
.login-logo .name { font-size: 34px; color: var(--brand-deep); }
.login-logo .sub { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); }
.login-card form { margin-top: 22px; position: relative; }

/* ---------------- Misc ---------------- */
.page-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.page-tools .spacer { flex: 1; }
.search-inline { max-width: 280px; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty .puff { width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 12px; background: radial-gradient(circle at 35% 30%, #fff, #cfe6f5); }
.line-items td { padding: 8px; }
.line-items input, .line-items select { padding: 8px 10px; }
.totals { max-width: 320px; margin-left: auto; }
.totals .row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.totals .row.grand { border-top: 2px solid var(--line); margin-top: 6px; padding-top: 12px; font-size: 18px; font-weight: 800; }
.hidden { display: none !important; }
.mobile-toggle { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform .25s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px;
    border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
  .backdrop { position: fixed; inset: 0; background: rgba(20,40,55,.35); z-index: 55; }
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
}
