:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --line: #d7dde5;
  --line-soft: #e7ebf0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b91c1c;
  --success: #047857;
  --shadow: 0 18px 45px rgba(15, 23, 42, .09);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,0)),
    radial-gradient(circle at 15% 0%, rgba(37, 99, 235, .10), transparent 30rem),
    var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button, input, select { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  font-weight: 650;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
button.secondary:hover { background: var(--panel-soft); }
button.secondary.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37, 99, 235, .08);
}
button.danger { color: var(--danger); }

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus {
  outline: 3px solid rgba(37, 99, 235, .16);
  border-color: var(--accent);
}

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-panel {
  width: min(100%, 390px);
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(215, 221, 229, .9);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 30px;
  backdrop-filter: blur(18px);
}
.auth-panel h1 {
  margin: 0 0 24px;
  font-size: 28px;
  line-height: 1.12;
  font-weight: 750;
}
.login-form {
  display: grid;
  gap: 15px;
}
.login-form label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.form-error, .form-success, .hint {
  margin: 0;
  font-size: 14px;
}
.form-error { color: var(--danger); }
.form-success { color: var(--success); }
.hint { color: var(--muted); line-height: 1.45; }

.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar strong { font-size: 17px; }
#user-meta {
  margin-left: 10px;
  color: var(--muted);
  font-size: 14px;
}

.shell {
  width: min(1160px, calc(100% - 32px));
  margin: 26px auto 56px;
  display: grid;
  gap: 18px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
  padding: 20px;
}
.panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}
.panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.upload-panel, .section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
#upload-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.upload-target {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.upload-target select {
  width: auto;
  min-width: 220px;
}
#file-input { width: min(360px, 100%); }
.selection-status {
  color: var(--muted);
  font-size: 14px;
  min-width: 130px;
}
.password-panel form, .inline-form, .toolbar, .reset-output {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.password-panel input, .inline-form input, .inline-form select, .toolbar input, .reset-output input {
  width: auto;
  min-width: 220px;
}
.toolbar select {
  width: auto;
  min-width: 190px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}
.breadcrumb button {
  padding: 4px 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
}
.breadcrumb button:hover {
  background: transparent;
  color: var(--accent-dark);
  text-decoration: underline;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
td:first-child {
  white-space: normal;
  min-width: 230px;
  font-weight: 600;
}
td:last-child {
  text-align: right;
}
.folder-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-weight: 750;
}
.folder-link:hover {
  background: transparent;
  color: var(--accent);
}
.folder-icon {
  width: 18px;
  height: 14px;
  display: inline-block;
  border: 1.5px solid #d6a11f;
  border-radius: 3px;
  background: #f8c84b;
  position: relative;
  flex: 0 0 auto;
}
.folder-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: -5px;
  width: 8px;
  height: 5px;
  border: 1.5px solid #d6a11f;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: #f8c84b;
}
.row-actions {
  display: inline-flex;
  gap: 8px;
}
.row-actions a, .row-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  font-weight: 650;
}
.row-actions a:hover, .row-actions button:hover { background: var(--panel-soft); }
.reset-output {
  margin-top: 14px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
#reset-link { flex: 1; min-width: min(520px, 100%); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  max-width: min(520px, calc(100% - 32px));
}
#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .upload-panel, .section-head { align-items: stretch; flex-direction: column; }
  #upload-form, .toolbar { justify-content: flex-start; }
  .panel { padding: 16px; }
  .auth-panel { padding: 24px; }
  .auth-panel h1 { font-size: 24px; }
}
