@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f9f2e9;
  --bg-card:     #ffffff;
  --bg-muted:    #f1e9de;
  --border:      #e2d5c6;
  --border-soft: #ede5d8;

  --ink:         #1a1a1a;
  --ink-mid:     #555555;
  --ink-soft:    #999999;

  --accent:      #1a1a1a;
  --accent-hover:#333333;

  --red:         #a83228;
  --red-dark:    #8c2820;
  --green:       #2d6a4a;

  --radius:      4px;
  --radius-lg:   8px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.08);
}

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--ink-mid); }

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .85em;
  background: var(--bg-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: .1em .4em;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.site-nav { display: flex; gap: 1.75rem; align-items: center; }

.site-nav a {
  color: var(--ink-soft);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: .01em;
  transition: color .15s;
}

.site-nav a.active { color: var(--ink); }
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.nav-logout { color: var(--ink-soft) !important; font-size: .8rem !important; }

.nav-user { display: flex; align-items: center; gap: .6rem; padding-left: .5rem; border-left: 1px solid var(--border); }
.nav-user-name { font-size: .8rem; color: var(--ink-mid); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

/* ── Main ────────────────────────────────────────────────────────────────── */
.main-content { max-width: 960px; margin: 0 auto; padding: 2.5rem 2rem 5rem; }

/* ── Auth wrap (login) ───────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  text-align: center;
  color: var(--ink);
  letter-spacing: -.01em;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.header-meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding-top: .25rem; }

.back-link { display: block; font-size: .8rem; color: var(--ink-soft); margin-bottom: .35rem; text-decoration: none; }
.back-link:hover { color: var(--ink-mid); }

.poc-url { font-size: .8rem; color: var(--ink-soft); display: block; margin-top: .15rem; text-decoration: none; }
.poc-url:hover { color: var(--ink); text-decoration: underline; }
.meta-text { font-size: .775rem; color: var(--ink-soft); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.card h2 { font-size: .9rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin-bottom: .6rem; }
.card-desc { font-size: .825rem; color: var(--ink-soft); margin-bottom: 1.25rem; line-height: 1.5; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-mid);
  margin-top: 1rem;
  margin-bottom: .35rem;
}

input[type=text],
input[type=password],
input[type=email],
input[type=date] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .8rem;
  font-size: .875rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg-card);
  transition: border-color .15s, box-shadow .15s;
}

input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(26,26,26,.1);
}

.hint { font-weight: 400; color: var(--ink-soft); font-size: .775rem; text-transform: none; letter-spacing: 0; }

.stack { display: flex; flex-direction: column; gap: 0; }
.stack label { margin-top: .75rem; }
.stack button { margin-top: 1.25rem; align-self: flex-start; }

.pass-row { display: flex; gap: .5rem; align-items: stretch; }
.pass-input { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  font-size: .8rem;
  line-height: 1;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .03em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-muted); text-decoration: none; }

.btn--primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--danger { background: var(--bg-card); color: var(--red); border-color: #e0c4c0; }
.btn--danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn--sm { padding: .35rem .75rem; font-size: .75rem; }
.btn--full { width: 100%; justify-content: center; margin-top: 1rem; }

.btn--google {
  width: 100%;
  justify-content: center;
  margin-top: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  padding: .7rem 1rem;
  box-shadow: var(--shadow);
}
.btn--google:hover { background: var(--bg-muted); text-decoration: none; }

button:disabled { opacity: .4; cursor: not-allowed; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: .8rem 1.1rem;
  font-size: .85rem;
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
}

.alert--success { background: #edf5f0; color: #2d6a4a; border-color: #c0ddd0; }
.alert--error   { background: #f8efed; color: #a83228; border-color: #e0c4c0; }
.alert--info    { background: var(--bg-muted); color: var(--ink-mid); border-color: var(--border); }

.error-box { background: #f8efed; color: #a83228; border: 1px solid #e0c4c0; border-radius: var(--radius); padding: .8rem 1.1rem; font-size: .875rem; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .2rem .55rem;
  border-radius: 2px;
  white-space: nowrap;
}

.badge--protected { background: var(--ink); color: #fff; }
.badge--open      { background: var(--bg-muted); color: var(--ink-mid); border: 1px solid var(--border); }
.badge--expires   { background: #edf5f0; color: #2d6a4a; }
.badge--expiring  { background: #f5f0e6; color: #7a5c20; border: 1px solid #ddd0b8; }
.badge--expired   { background: #f8efed; color: #a83228; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead { background: var(--bg-muted); }
th { text-align: left; padding: .75rem 1.1rem; font-weight: 700; color: var(--ink-mid); border-bottom: 1px solid var(--border); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
td { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border-soft); color: var(--ink); vertical-align: middle; background: var(--bg-card); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-muted); }
.actions { display: flex; gap: .5rem; }

.empty-state { color: var(--ink-soft); text-align: center; padding: 3rem 1rem; font-size: .875rem; }

.table-name { display: block; font-weight: 500; text-decoration: none; color: var(--ink); }
.table-name:hover { text-decoration: underline; }
.table-url  { display: block; font-size: .775rem; color: var(--ink-soft); text-decoration: none; margin-top: .15rem; }
.table-url:hover { color: var(--ink); text-decoration: underline; }

/* ── Modal (dialog) ──────────────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  padding: 0;
  max-width: 440px;
  width: 90vw;
  margin: auto;
  background: var(--bg-card);
}

dialog::backdrop { background: rgba(26,26,26,.45); }

.modal-inner { padding: 2rem; }
.modal-inner h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--ink); letter-spacing: -.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; gap: .75rem; margin: .75rem 0; }

.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--ink); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Auth fields ─────────────────────────────────────────────────────────── */
.hidden { display: none; }

.auth-toggle-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: .5rem;
}
.auth-toggle-text { display: flex; flex-direction: column; gap: .15rem; }
.auth-toggle-title { font-size: .875rem; font-weight: 600; color: var(--ink); }
.auth-toggle-sub   { font-size: .775rem; color: var(--ink-soft); }

.auth-fields {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

/* ── Info row (settings) ─────────────────────────────────────────────────── */
.info-row { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.info-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-mid); }

/* ── File drop zone ──────────────────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: .85rem;
  transition: border-color .15s, background .15s, color .15s;
  margin-top: 1rem;
}
.file-drop:hover, .file-drop.dragging { border-color: var(--ink); background: var(--bg-muted); color: var(--ink); }
.file-limits { font-size: .775rem; color: var(--ink-soft); margin-top: .5rem; }
#upload-btn { margin-top: 1rem; }

/* ── Expired row ─────────────────────────────────────────────────────────── */
.row--expired td { opacity: .45; }

/* ── Expiry selector ─────────────────────────────────────────────────────── */
.expiry-selector {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .5rem;
}

.expiry-option {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .7rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: .775rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  cursor: pointer;
  color: var(--ink-mid);
  background: var(--bg-card);
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}

.expiry-option input[type=radio] { display: none; }

.expiry-option:has(input:checked) {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.expiry-date-input {
  margin-top: .6rem;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .8rem;
  font-size: .875rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg-card);
}

/* ── File tree ───────────────────────────────────────────────────────────── */
.file-tree-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border-soft);
  padding-top: .75rem;
}

.file-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
  user-select: none;
}
.file-tree-header:hover { color: var(--ink); }
.tree-chevron { transition: transform .2s; flex-shrink: 0; }


.file-tree {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: .5rem;
  max-height: 260px;
  overflow-y: auto;
}
.file-tree.hidden { display: none; }

.file-subtree {
  list-style: none;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.file-subtree.hidden { display: none; }

.file-tree-dir-wrapper { display: flex; flex-direction: column; }

.file-tree-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--ink);
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: .2rem .4rem;
  border-radius: var(--radius);
  cursor: default;
}
.file-tree-item:hover { background: var(--bg-muted); }
.file-tree-item svg { color: var(--ink-soft); flex-shrink: 0; }
.file-tree-item-label { word-break: break-all; }
.file-tree-item--dir { font-weight: 600; color: var(--ink); cursor: pointer; user-select: none; }
.file-tree-item--dir svg:not(.dir-chevron) { color: var(--ink); }
.dir-chevron { color: var(--ink-soft); flex-shrink: 0; transition: transform .15s ease; }

/* ── Tag input ───────────────────────────────────────────────────────────── */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .5rem;
  background: var(--bg-card);
  cursor: text;
  min-height: 2.5rem;
  align-items: center;
  margin-top: .35rem;
  transition: border-color .15s, box-shadow .15s;
}
.tag-input:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(26,26,26,.1);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: .2rem .55rem;
  font-size: .775rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .01em;
}
.tag-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 0;
  line-height: 1;
  font-size: 1rem;
  display: flex;
  align-items: center;
  transition: color .1s;
}
.tag-remove:hover { color: var(--red); }
.tag-text-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  flex: 1;
  min-width: 140px;
  width: auto !important;
  font-size: .875rem;
  font-family: inherit;
  background: transparent;
  padding: .1rem .2rem;
  color: var(--ink);
  margin: 0 !important;
}

/* ── Danger zone ─────────────────────────────────────────────────────────── */
.danger-zone {
  border: 1px solid #e0c4c0;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.75rem;
  margin-top: 1.5rem;
}
.danger-zone h3 { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--red); margin-bottom: .75rem; }
