/* KP Service — macOS WebUI style */
:root {
  --bg1: #f5f2ec;
  --bg2: #ece7de;
  --ink: #1d1d1f;
  --ink2: #6e6e73;
  --accent: #0a84ff;
  --accent-d: #0060df;
  --ok: #30a14e;
  --err: #e5484d;
  --card: rgba(255, 255, 255, .72);
  --line: rgba(0, 0, 0, .08);
  --shadow: 0 20px 60px rgba(31, 26, 18, .14), 0 2px 8px rgba(31, 26, 18, .06);
  --radius: 18px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55; }
.b1 { width: 560px; height: 560px; background: #f6c98f; top: -160px; left: -120px; }
.b2 { width: 480px; height: 480px; background: #b7d3f7; bottom: -140px; right: -100px; }
.b3 { width: 380px; height: 380px; background: #f2b8c6; top: 40%; left: 55%; opacity: .35; }

.shell { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 28px 20px 40px; }

/* ── top bar ─────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 8px 24px rgba(31,26,18,.08);
}
.traffic { display: flex; gap: 8px; }
.t { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.t-red { background: #ff5f57; } .t-yellow { background: #febc2e; } .t-green { background: #28c840; }
.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: .1px; }
.topbar-badge {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ink2);
  border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.5);
}

/* ── hero ─────────────────────────────── */
.hero { text-align: center; padding: 44px 10px 26px; }
.hero h1 { margin: 0 0 12px; font-size: 40px; font-weight: 700; letter-spacing: -.5px; }
.subtitle { margin: 0 auto; max-width: 560px; color: var(--ink2); font-size: 16px; line-height: 1.5; }

/* ── card ─────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  padding: 28px; max-width: 760px; margin: 0 auto;
}

/* ── dropzone ─────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 44px 20px; text-align: center; cursor: pointer;
  border: 1.5px dashed rgba(0,0,0,.18); border-radius: 14px;
  background: rgba(255,255,255,.45); transition: all .18s ease;
}
.dropzone:hover { background: rgba(255,255,255,.7); border-color: var(--accent); }
.dropzone.drag {
  background: rgba(10,132,255,.08); border-color: var(--accent);
  transform: scale(1.01);
}
.dz-icon {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-size: 24px; background: linear-gradient(180deg, rgba(10,132,255,.14), rgba(10,132,255,.05));
  color: var(--accent);
}
.dz-title { font-size: 17px; font-weight: 600; }
.dz-hint { color: var(--ink2); font-size: 13px; }

/* file chip */
.selected { margin-top: 14px; }
.file-chip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.7); border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 12px;
}
.fc-icon { font-size: 20px; }
.fc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-size { color: var(--ink2); font-size: 13px; margin-left: auto; }
.fc-remove {
  border: 0; background: rgba(0,0,0,.06); color: var(--ink2);
  width: 24px; height: 24px; border-radius: 50%; font-size: 15px; cursor: pointer;
}
.fc-remove:hover { background: rgba(0,0,0,.12); color: var(--ink); }

/* ── options ─────────────────────────────── */
.options { margin-top: 16px; }
.options summary {
  cursor: pointer; color: var(--ink2); font-size: 14px; font-weight: 500;
  user-select: none; padding: 4px 0;
}
.opt-grid { display: grid; grid-template-columns: 132px minmax(0,1fr) minmax(0,1fr); gap: 14px; margin-top: 10px; align-items: start; }
.opt { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink2); }
.opt-wide { grid-column: 1 / -1; }
.opt input, .opt select, .opt textarea {
  font: inherit; color: var(--ink); padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.75);
  outline: none; resize: vertical;
}
#valid_days { width: 100%; max-width: 110px; }
.opt input:focus, .opt select:focus, .opt textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,132,255,.18);
}

/* macOS segmented control */
.seg {
  display: inline-flex; gap: 2px; padding: 2px; align-self: flex-start;
  background: rgba(0,0,0,.06); border-radius: 9px;
}
.seg-btn {
  border: 0; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--ink); background: transparent; border-radius: 7px; cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease, color .15s ease;
  white-space: nowrap;
}
.seg-btn:hover:not(.active) { background: rgba(0,0,0,.05); }
.seg-btn.active {
  background: #fff; color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 0 0 .5px rgba(0,0,0,.06);
}

/* ── buttons ─────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 20px; width: 100%; padding: 13px 22px;
  font: inherit; font-size: 16px; font-weight: 600; color: #fff; text-decoration: none;
  background: linear-gradient(180deg, #2f97ff, var(--accent));
  border: 0; border-radius: 12px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(10,132,255,.35);
  transition: transform .12s ease, filter .12s ease;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn-primary:active:not(:disabled) { transform: scale(.99); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  margin-top: 20px; width: 100%; padding: 12px 22px;
  font: inherit; font-size: 15px; font-weight: 500; color: var(--ink);
  background: rgba(255,255,255,.6); border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,.85); }
.legal { color: var(--ink2); font-size: 12px; text-align: center; margin: 14px 0 0; }

/* ── progress ─────────────────────────────── */
.progress-wrap { display: flex; flex-direction: column; align-items: center; padding: 30px 0; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid rgba(10,132,255,.15); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-title { margin: 16px 0 18px; font-size: 15px; font-weight: 500; color: var(--ink2); }
.bar { width: 100%; max-width: 420px; height: 6px; background: rgba(0,0,0,.07); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }

/* ── result ─────────────────────────────── */
.result-head { display: flex; gap: 14px; align-items: center; }
.ok-badge {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(48,161,78,.14); color: var(--ok); font-size: 22px; font-weight: 700;
}
.result-title { font-size: 20px; font-weight: 700; }
.result-sub { color: var(--ink2); font-size: 14px; }
.totals {
  display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0 6px;
}
.total-chip {
  background: rgba(255,255,255,.7); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; min-width: 150px;
}
.tc-label { font-size: 12px; color: var(--ink2); }
.tc-value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.table-wrap { margin-top: 12px; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  position: sticky; top: 0; text-align: left; font-weight: 600; font-size: 12px;
  color: var(--ink2); background: rgba(246,244,240,.95); backdrop-filter: blur(8px);
  padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.tbl th:not(:first-child), .tbl td:not(:first-child) { text-align: right; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid rgba(0,0,0,.05); font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .sum-row td { font-weight: 700; background: rgba(10,132,255,.06); }
.warn {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-size: 13px;
  background: rgba(254,188,46,.12); border: 1px solid rgba(254,188,46,.4); color: #7a5a00;
}
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions .btn-primary, .actions .btn-ghost { margin-top: 18px; }

/* ── error ─────────────────────────────── */
.err-box { text-align: center; padding: 16px 6px; }
.err-title { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.err-msg { color: var(--err); font-size: 14px; margin-bottom: 6px; }

.foot { text-align: center; color: var(--ink2); font-size: 12.5px; margin-top: 26px; }

@media (max-width: 900px) and (min-width: 641px) {
  .seg-btn { padding: 6px 10px; font-size: 12px; }
}
@media (max-width: 640px) {
  .hero h1 { font-size: 30px; }
  .opt-grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .card { padding: 20px; }
}